2021-07-02 16:30:30 +10:00
|
|
|
# Note: it is the intent for you to override these with your own functions
|
2021-09-20 10:17:16 +10:00
|
|
|
users = {}
|
2021-07-02 16:30:30 +10:00
|
|
|
|
|
|
|
|
|
2021-03-29 16:53:11 +11:00
|
|
|
def get_person(ifc):
|
2021-07-04 09:54:49 +10:00
|
|
|
people = ifc.by_type("IfcPerson") or [None]
|
2021-09-09 21:27:23 +10:00
|
|
|
return people[0]
|
2021-03-25 16:32:43 +11:00
|
|
|
|
|
|
|
|
|
2021-03-29 16:53:11 +11:00
|
|
|
def get_organisation(ifc):
|
2021-07-04 09:54:49 +10:00
|
|
|
organisations = ifc.by_type("IfcOrganization") or [None]
|
|
|
|
|
return organisations[0]
|
2021-03-25 16:32:43 +11:00
|
|
|
|
2021-03-25 11:42:12 +11:00
|
|
|
|
2021-03-29 16:53:11 +11:00
|
|
|
def get_application(ifc):
|
2021-07-04 09:54:49 +10:00
|
|
|
applications = ifc.by_type("IfcApplication") or [None]
|
|
|
|
|
return applications[0]
|
2021-09-20 10:17:16 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_user(ifc):
|
|
|
|
|
person = get_person(ifc)
|
|
|
|
|
organisation = get_organisation(ifc)
|
|
|
|
|
if not person or not organisation:
|
|
|
|
|
return
|
|
|
|
|
key = f"{person.id()}-{organisation.id()}"
|
|
|
|
|
user = users.get(key)
|
|
|
|
|
if not user:
|
|
|
|
|
for element in ifc.by_type("IfcPersonAndOrganization"):
|
|
|
|
|
if element.ThePerson == person and element.TheOrganization == organisation:
|
|
|
|
|
users[key] = element
|
|
|
|
|
user = element
|
|
|
|
|
if not user:
|
|
|
|
|
return ifc.create_entity("IfcPersonAndOrganization", ThePerson=person, TheOrganization=organisation)
|
|
|
|
|
return user
|