From 3ca7cc310b1bc40b53c8e0ae92b3aec2ffdc10fa Mon Sep 17 00:00:00 2001 From: visi Date: Thu, 20 Jun 2024 16:23:38 -0400 Subject: [PATCH] WIP: Add relationship model convention --- synapse/models/base.py | 19 +++++++++++++++++++ synapse/models/orgs.py | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/synapse/models/base.py b/synapse/models/base.py index f217d18841..6e8f41cb58 100644 --- a/synapse/models/base.py +++ b/synapse/models/base.py @@ -105,6 +105,25 @@ def getModelDefs(self): 'doc': 'A sophistication score with named values: very low, low, medium, high, and very high.'}), ), 'interfaces': ( + ('meta:relationship', { + 'doc': 'Properties common to relationships between specific forms.', + 'props': ( + ('source', ('guid', {}), { + 'doc': 'The node that is related to the target node.'}), + + ('target', ('guid', {}), { + 'doc': 'The node that the source node is related to.'}), + + ('type', ('taxonomy', {}), { + 'doc': 'The type of relationship that the source node has to the target node.'}), + + ('status', ('str', {'enums': 'TODO'}), { + 'doc': 'The latest known status of the relationship.'}), + + ('period', ('ival', {}), { + 'doc': 'The time period that the relationship existed.'}), + ), + }), ('meta:taxonomy', { 'doc': 'Properties common to taxonomies.', 'props': ( diff --git a/synapse/models/orgs.py b/synapse/models/orgs.py index 4d0addb62d..0452bd92a7 100644 --- a/synapse/models/orgs.py +++ b/synapse/models/orgs.py @@ -45,6 +45,18 @@ def getModelDefs(self): ), }}), + ('ou:relationship:type:taxonomy', ('taxonomy', {}), {}), + + ('ou:relationship', ('guid', {}), { + 'doc': 'A relationship between two organizations.', + 'display': { + 'columns': ( + {'type': 'prop', 'opts': {'name': 'source::name'}}, + {'type': 'prop', 'opts': {'name': 'type'}}, + {'type': 'prop', 'opts': {'name': 'target::name'}}, + ), + }}), + ('ou:orgtype', ('taxonomy', {}), { 'doc': 'An org type taxonomy.', 'interfaces': ('meta:taxonomy',), @@ -721,6 +733,18 @@ def getModelDefs(self): ('org', ('ou:org', {}), {}), ('name', ('ou:name', {}), {}), )), + ('ou:relationship:type:taxonomy', {}, ()), + ('ou:relationship', {}, ( + + ('source', ('ou:org', {}), { + 'doc': 'The organization which is related to the target organization.'}), + + ('target', ('ou:org', {}), { + 'doc': 'The organization which the source organization is related to.'}), + + ('type', ('ou:relationship:type:taxonomy', {}), { + 'doc': 'The type of relationship.'}), + )), ('ou:position', {}, ( ('org', ('ou:org', {}), { 'doc': 'The org which has the position.',