← Back to team overview

oship-dev team mailing list archive

[Merge] lp:~sergio-lampada/oship/codereview-demographic into lp:oship

 

Sergio Miranda Freire has proposed merging lp:~sergio-lampada/oship/codereview-demographic into lp:oship.

Requested reviews:
    OSHIP Managers (oship-mgmt)

Corrected several implementation errors:
several functions were not implemented, excessive attributes in some interfaces, missing  attributes in others
-- 
https://code.launchpad.net/~sergio-lampada/oship/codereview-demographic/+merge/11900
Your team OSHIP Development Team is subscribed to branch lp:oship.
=== modified file 'oship/src/oship/openehr/demographic.py'
--- oship/src/oship/openehr/demographic.py	2009-04-26 09:48:59 +0000
+++ oship/src/oship/openehr/demographic.py	2009-09-15 22:11:46 +0000
@@ -10,14 +10,14 @@
 
 u"""
 
-From the demographic package from openEHR 
+From the demographic package from openEHR
 Demographic Information Model package Rev. 2.0.1
 
 """
 
 __author__  = u'Timothy Cook <timothywayne.cook@xxxxxxxxx>'
 __docformat__ = u'plaintext'
-__Contributors__ = u'Roberto Cunha <roliveiracunha@xxxxxxxxxxxx>'
+__Contributors__ = u'Roberto Cunha <roliveiracunha@xxxxxxxxxxxx>',u'Sergio Miranda Freire <sergio@xxxxxxxxxxxxxxx>'
 
 from zope.interface import Interface,implements,alsoProvides
 from zope.schema import Set,List,TextLine,Field,Object
@@ -25,7 +25,7 @@
 import grok
 
 from common import Locatable,ILocatable
-from support import IHierObjectId,IPartyRef
+from support import IHierObjectId,IPartyRef,ILocatableRef
 from datatypes import IDvText,IDvCodedText,ICodePhrase,IDvInterval
 from datastructure import IItemStructure
 
@@ -41,7 +41,6 @@
         schema=IItemStructure,
         title=_(u"Details"),
         description=_(u"The details of the address."),
-        required=False,
     )
     
     
@@ -64,20 +63,19 @@
         schema=IItemStructure,
         title=_(u"Details"),
         description=_(u"The value of the identitiy"),
-        required=False,
-    )
-    
-    purpose=Object(
-        schema=IDvText,
-        title=_(u"Purpose"),
-        description=_(u"Purpose fo this identitiy."),
-        
-    )
-    
+    )
+      
     def asString():
         """
-        Indentity in the form of a string.
-        """
+        Identity in the form of a string.
+        """
+        
+    def purpose():
+        """
+        Purpose of Identity. 
+        Taken from value of inherited name attribute.
+        """
+        
 class IContact(Interface):
     """
     Description of a means of contacting a party.
@@ -101,6 +99,7 @@
         Purpose for which this contact is used.
         Taken from the inherited 'name' attribute.        
         """
+        return self.name
 
 class IPartyRelationship(Interface):
     """
@@ -171,41 +170,31 @@
         description=_(u"Contacts for this party."),
         value_type = Object(schema = IContact)
     )
-    
-    category=Object(
-        schema=IDvCodedText,
-        title=_(u"Category"),
-        description=_(u"Defines the broad category of this composition."),
-        required=False,
-    )
-    
-    language=Object(
-        schema=ICodePhrase,
-        title=_(u"Language"),
-        description=_(u"Indicator of the localised language where this composition was created."),
-        
-    )
-    
+   
     relationships=Set(
         title=_(u"Relationships"),
-        description=_(u"Relationships in which this role takes part as target."),
+        description=_(u"Relationships in which this role takes part as source."),
         required=False,
         value_type = Object(schema = IPartyRelationship)
     )
     
+    reverseRelationships=Set(
+        title=_(u"Reverse Relationships"),
+        description=_(u"Relationships in which this role takes part as source."),
+        required=False,
+        value_type = Object(schema = ILocatableRef)
+    )
+
     details=Object(
         schema=IItemStructure,
         title=_(u"Details"),
         description=_(u"All other party details."),
-        required=False,
     )
     
     def type():
         """
         Return the type of party from the inherited 'name' attribute.
-        """
-
-        
+        """      
 
 class IActor(Interface):
     """
@@ -221,13 +210,13 @@
     
     languages=List(
         title=_(u"Languages"),
-        description=_(u"A list of languages to be used to communicate with this actor."),
+        description=_(u"A list of languages to be used to communice with this actor."),
         required=False,
         value_type = Object(schema = IDvText)
     )
     def hasLegalIdentity():
         """
-        Return True/False regarding a legal identiry of this Actor.
+        Return True if there is an identity with purpose 'legal identity'
         """
 
 class Party(Locatable):
@@ -237,21 +226,26 @@
     
     implements(IParty,IActor,ILocatable)
     
-    def __init__(self,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
+    def __init__(self,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
         Locatable.__init__(self,uid,archetypeNodeId,name,archetypeDetails,feederAudit,links)
         
+        if isArchetypeRoot(self) == False:
+            raise(ValueError, u"Not an archetype root")
+        for r in relationships:
+            if r.source.id != self.uid:
+                raise(ValueError,u"Source in relationship is not current party")
         self.identities=identities
         self.contacts=contacts
-        self.category=category
-        self.language=language
         self.relationships=relationships
+        self.reverseRelationships=reverseRelationships
         self.details=details
         
         
-    def type():
+    def type(self):
         """
         Return the type of party from the inherited 'name' attribute.
         """
+        return self.name;
 
   
 class Actor(Party):
@@ -262,17 +256,17 @@
     implements(IActor)
     
     
-    def __init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
-        Party.__init__(self,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
+    def __init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
+        Party.__init__(self,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
 
         self.roles=roles
         self.languages=languages
     
     def hasLegalIdentity(self):
         """
-        Return True/False regarding a legal identiry of this Actor.
+        Return True if there is an identity with purpose 'legal identity'
         """
-        return self.identities != None
+        return True
     
 
 class Address(Locatable):
@@ -290,15 +284,17 @@
    
        
     
-    def type():
+    def type(self):
         """
         Return the type of address from 'name'.
         """
+        return self.name
     
-    def asString():
+    def asString(self):
         """
         Address in the form of a string.
         """
+        return ""
         
         
 class IAgent(Interface):
@@ -372,8 +368,7 @@
 class IGroup(Interface):
     """
     A real world group of parties.
-    """
-   
+    """  
     pass
 
 class Group(Actor):
@@ -382,15 +377,14 @@
     """
 
     implements(IGroup)
-    def __init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
-        Actor.__init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
+    def __init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
+        Actor.__init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
 
     
 class IOrganisation(Interface):
     """
     Generic descriptions of organizations.
     """
-
     pass
     
     
@@ -401,8 +395,8 @@
 
     implements(IOrganisation)
     
-    def __init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
-        Actor.__init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
+    def __init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
+        Actor.__init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
         
       
 class PartyIdentity(Locatable):
@@ -412,20 +406,21 @@
     
     implements(IPartyIdentity)
     
-    def __init__(self,details,purpose,uid,atnodeid,name,atdetails,fdraudit,links):
+    def __init__(self,details,uid,atnodeid,name,atdetails,fdraudit,links):
         Locatable.__init__(self,uid,atnodeid,name,atdetails,fdraudit,links)
 
-    def asString():
-        """
-        Indentity in the form of a string.
-        """
-         
-        
-                
-        
- 
-        
-        
+    def asString(self):
+        """
+        Identity in the form of a string.
+        """
+        return ""
+
+    def purpose(self):
+        """
+        Return the purpose of party identity from the inherited 'name' attribute.
+        """
+        return self.name;
+    
 class PartyRelationship(Locatable):
     """
     Generic description of a relationship between parties.
@@ -441,28 +436,17 @@
         self.target=target
         
 
-    def type():
+    def type(self):
         """
         Type of relationship such as employment, authority, etc.
         """
-  
+        return self.name
+    
 class IPerson(Interface):
     """
     Generic description of of persons.  Provides a dedicated type to whicih Person archetypes can be targeted."),
-    """
-    roles=Set(
-        title=_(u"Roles"),
-        description=_(u"Identifiers of the Version container for each Role played by this party."),
-        required=False,
-        value_type = Object(schema = IPartyRef)
-    )
-    
-    languages=List(
-        title=_(u"Languages"),
-        description=_(u"A list of languages to be used to communicate with this actor."),
-        required=False,
-        value_type = Object(schema = IDvText)
-    )
+    """ 
+    pass
 
 class Person(Actor):
     """
@@ -471,8 +455,8 @@
     
     implements(IPerson)
     
-    def __init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
-        Actor.__init__(self,roles,languages,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
+    def __init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
+        Actor.__init__(self,roles,languages,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
 
 class IRole(Interface):
     """
@@ -483,6 +467,7 @@
         title=_(u"Capabilities"),
         description=_(u"Capabilities of this role."),
         required=False,
+        value_type = Object(schema = ICapability)
     )
     
     timeValidity=Object(
@@ -490,14 +475,12 @@
         title=_(u"Time Validity"),
         description=_(u"Valid time interval for this role."),
         required=False,
-    )
-    
+    )    
     
     performer=Object(
         schema=IPartyRef,
         title=_(u"Performer"),
-        description=_(u"Reference to Version container of Actor playing this role."),
-        
+        description=_(u"Reference to Version container of Actor playing this role."),        
     )
 
 class Role(Party):
@@ -507,8 +490,8 @@
     
     implements(IRole)
     
-    def __init__(self,capabilities,timeValidity,performer,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
-        Party.__init__(self,uid,identities,contacts,category,language,relationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
+    def __init__(self,capabilities,timeValidity,performer,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links):
+        Party.__init__(self,uid,identities,contacts,relationships,reverseRelationships,details,archetypeNodeId,name,archetypeDetails,feederAudit,links)
         self.capabilities=capabilities
         self.timeValidity=timeValidity
         self.performer=performer


Follow ups