Open joaquimrcarvalho opened 8 months ago
see #22
Comment in the Java code:
class RealEntity(Entity):
id: str
name: str
status: enum # one of U=linked (single occurrence), A=Automatic, S=Source, M=Manual linked, V=Valid
obs
# Methods
def same_as(id1:str , id2:str, user="user", status="M", real_id=None) -> str:
""" Returns a real entity id linking id1 and id2.
if id1 and id2 are both unliked occurrences then a new real entity is created
associated with user. if real_id is given is not given a random id is generated.
if id1 is a real entity and id2 is not, then id2 is added to id1 and id1 returned
if id2 is a real entity and id1 is not, swap and do as above.
if both id1 and id2 are real entities, merge them and keep the id of the real
entity with higher status V->M->S->A->U
in all the cases linking two id2 of different types or inheriting from a common type not equal to Entity is an error."""
return None
def make_real(id1,user="user",,status="U")-> str:
""" Make id1 a real entity, return new real id"""
return None
def not_same_as(id1,rid, silent=False):
""" detach id1 from rid.
detaches id from rid, returns error if id1 not in rid and silent=False"""
return None
def get_users(self) -> List[str]:
""" Returns the list of users currently in the database """
return []
@classmethod
def get(id)-> RealEntity:
""" return a real entity """
class RealRelations(Entity):
""" Represents a relation between real entities
A real relation is:
1. (U) unlinked relations: any relation between the occurrences of real entities
2. (A) automatically linked relations: relations that consolidate several
relations between the occurrences of the real entities, inferred_date_start
and inferred_date_end register the extreme dates of the relations between
the occurrences. The consolidation was done automatically.
3. (M) same as (A) but the occurrences were consolidated manually.
"""
id: str
user: str
status : enum. # U,A,M
r_origin: str # id of the real entity origin of the relation
r_destination: str
the_type: str
the_value: str
the_date: str
inferred_start: date # first date on the occs relas between the real entities
inferred_start_type: enum # D=at the date, B=before the date, A=after the date
inferred_end: date
inferred_end_type: enum
class link(Base): # sqlalchemy base form
rid: str
user: str # link to users
occ:str. # id of the occurrence
status: enum. # M=Manual, S=Source (same as), A=Automatic, U=unliked (single link)
Copy from the MHK java implementation