|
22 | 22 |
|
23 | 23 | from .interaction_style import InteractionStyle |
24 | 24 | from .model_item import ModelItem, ModelItemIO |
| 25 | +from .tags import Tags |
25 | 26 |
|
26 | 27 |
|
27 | 28 | if TYPE_CHECKING: |
@@ -88,10 +89,45 @@ def __init__( |
88 | 89 | """Initialize a relationship between two elements.""" |
89 | 90 | super().__init__(**kwargs) |
90 | 91 | self.source = source |
91 | | - self.source_id = source_id |
| 92 | + self._source_id = source_id |
92 | 93 | self.destination = destination |
93 | | - self.destination_id = destination_id |
| 94 | + self._destination_id = destination_id |
94 | 95 | self.description = description |
95 | 96 | self.technology = technology |
96 | | - self.interaction_style = interaction_style |
97 | 97 | self.linked_relationship_id = linked_relationship_id |
| 98 | + |
| 99 | + self.tags.add(Tags.RELATIONSHIP) |
| 100 | + self.tags.add( |
| 101 | + Tags.SYNCHRONOUS |
| 102 | + if interaction_style == InteractionStyle.Synchronous |
| 103 | + else Tags.ASYNCHRONOUS |
| 104 | + ) |
| 105 | + |
| 106 | + @property |
| 107 | + def source_id(self) -> str: |
| 108 | + if self.source is not None: |
| 109 | + return self.source.id |
| 110 | + |
| 111 | + return self._source_id |
| 112 | + |
| 113 | + @property |
| 114 | + def destination_id(self) -> str: |
| 115 | + if self.destination is not None: |
| 116 | + return self.destination.id |
| 117 | + |
| 118 | + return self._destination_id |
| 119 | + |
| 120 | + @classmethod |
| 121 | + def hydrate(cls, relationship_io: RelationshipIO) -> "Relationship": |
| 122 | + """""" |
| 123 | + return cls( |
| 124 | + id=relationship_io.id, |
| 125 | + tags=relationship_io.tags, |
| 126 | + properties=relationship_io.properties, |
| 127 | + perspectives=relationship_io.perspectives, |
| 128 | + source_id=relationship_io.source_id, |
| 129 | + destination_id=relationship_io.destination_id, |
| 130 | + description=relationship_io.description, |
| 131 | + technology=relationship_io.technology, |
| 132 | + interaction_style=relationship_io.interaction_style, |
| 133 | + ) |
0 commit comments