[Modeling-cvs] ProjectModeling/Modeling CHANGES,1.134,1.135 Entity.py,1.15,1.16 Relationship.py,1.12
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-07-24 17:02:37
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv14424
Modified Files:
CHANGES Entity.py Relationship.py
Log Message:
Fixed bug #776996: RelationshipManipulation methods misbehaving w/
inheritance. Implied fixing: Relationship.inverseRelationship().
Also added: entity.parentEntities()
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -d -r1.134 -r1.135
*** CHANGES 24 Jul 2003 13:34:06 -0000 1.134
--- CHANGES 24 Jul 2003 17:02:34 -0000 1.135
***************
*** 8,11 ****
--- 8,15 ----
--------------------------------------------------------
+ * Fixed bug #776996: RelationshipManipulation methods misbehaving w/
+ inheritance. Implied fixing: Relationship.inverseRelationship(). Also
+ added: entity.parentEntities()
+
* Fixed bug #776592: was impossible to add raw '*' and '?' characters in a
LIKE statement
Index: Entity.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Entity.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Entity.py 23 Jul 2003 12:17:41 -0000 1.15
--- Entity.py 24 Jul 2003 17:02:34 -0000 1.16
***************
*** 54,57 ****
--- 54,58 ----
'newOrOverriddenPythonProperties(), '\
'newOrOverriddenPythonPropertiesNames(), parentEntity(), '\
+ 'parentEntities(), '\
'parentEntityName(), rootEntity(), removeSubEntity(), '\
'subEntities()'
***************
*** 568,571 ****
--- 569,587 ----
return self._name
+ def parentEntities(self):
+ """Returns the parent entities (à la super-class, cf. inheritance)
+
+ The returned set is ordered: it begins with the direct parent, and ends
+ with the rootEntity().
+
+ See also: %(inheritance_methods)s
+ """
+ parents=[]
+ parent=self.parentEntity()
+ while parent:
+ parents.append(parent)
+ parent=parent.parentEntity()
+ return parents
+
def parentEntity(self):
"""Returns the parent entity (à la super-class, cf. inheritance)
Index: Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Relationship.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Relationship.py 24 Jul 2003 11:13:27 -0000 1.12
--- Relationship.py 24 Jul 2003 17:02:34 -0000 1.13
***************
*** 457,485 ****
"""
#import pdb ; pdb.set_trace()
! myDestEntity=self.destinationEntity()
! sameDestination=lambda rel, dst=self.entity(): rel.destinationEntity()==dst
! possibleInverse=filter(sameDestination, myDestEntity.relationships())
if not possibleInverse: return None
# Check all possible relationships
! for inverseRel in possibleInverse:
! _self_joins=list(self.joins())
! _inverse_joins=list(inverseRel.joins())
! if len(_self_joins)!=len(_inverse_joins): continue
! isInverse=1
! index=0
! while _inverse_joins:
! #for index in range(0, len(_inverse_joins)):
! # Test each join of the relation against the set of joins in self
! reciprocical=map(lambda j, join=_inverse_joins[index]: \
! j.isReciprocicalToJoin(join),
! _self_joins)
! isInverse=reduce(lambda a,b:a+b, reciprocical)
! if not isInverse: break # cannot be reciprocical
! del _self_joins[reciprocical.index(1)]
! del _inverse_joins[index]
! index+=1
! if isInverse:
! return inverseRel
return None
#if not self.destinationEntity(): return None
--- 457,507 ----
"""
#import pdb ; pdb.set_trace()
! search_in_entities=[]
!
!
! # Search all possible relationships, i.e. relationships in the
! # destinationEntity() pointing to self.entity() or to one of its
! # parent entities:
! src_entities=self.entity().parentEntities()
! src_entities.insert(0, self.entity())
! sameDestination=lambda rel, src=src_entities: rel.destinationEntity() in src
! #dest_entities=self.destinationEntity().parentEntities()
! dest_entities=[]
! dest_entities.insert(0, self.destinationEntity())
!
! possibleInverse=[]
! for destEntity in dest_entities:
! l=filter(sameDestination, destEntity.relationships())
! possibleInverse.extend(l)
if not possibleInverse: return None
# Check all possible relationships
! #import pdb ; pdb.set_trace()
!
! # if you can't find an inverse on self.entity, we'd probably find one
! # in parent entities:
! self_rels=[e.relationshipNamed(self.name()) for e in src_entities]
!
! for self_rel in self_rels:
! if self_rel is None: continue
! for inverseRel in possibleInverse:
! _self_joins=list(self_rel.joins())
! _inverse_joins=list(inverseRel.joins())
! if len(_self_joins)!=len(_inverse_joins): continue
! isInverse=1
! index=0
! while _inverse_joins:
! #for index in range(0, len(_inverse_joins)):
! # Test each join of the relation against the set of joins in self
! reciprocical=map(lambda j, join=_inverse_joins[index]: \
! j.isReciprocicalToJoin(join),
! _self_joins)
! isInverse=reduce(lambda a,b:a+b, reciprocical)
! if not isInverse: break # cannot be reciprocical
! del _self_joins[reciprocical.index(1)]
! del _inverse_joins[index]
! index+=1
! if isInverse:
! return inverseRel
return None
#if not self.destinationEntity(): return None
|