ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: relationship interfaces changed from many-to-many to many-to-one type relationship
Date Mon, 06 Feb 2017 17:08:53 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-44-Merge-parser-and-storage-models c73edeb96 -> 5230ae6e4


relationship interfaces changed from many-to-many to many-to-one type relationship


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/5230ae6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/5230ae6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/5230ae6e

Branch: refs/heads/ARIA-44-Merge-parser-and-storage-models
Commit: 5230ae6e49ee6d64c54d9084a125dd6f40c6550c
Parents: c73edeb
Author: mxmrlv <mxmrlv@gmail.com>
Authored: Mon Feb 6 19:08:41 2017 +0200
Committer: mxmrlv <mxmrlv@gmail.com>
Committed: Mon Feb 6 19:08:41 2017 +0200

----------------------------------------------------------------------
 aria/storage/modeling/instance_elements.py | 39 +++++++++++++------------
 1 file changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5230ae6e/aria/storage/modeling/instance_elements.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/instance_elements.py b/aria/storage/modeling/instance_elements.py
index 4d73a79..7273ff0 100644
--- a/aria/storage/modeling/instance_elements.py
+++ b/aria/storage/modeling/instance_elements.py
@@ -264,7 +264,11 @@ class InterfaceBase(structure.ModelMixin):
         return cls.foreign_key('node', nullable=True)
 
     @declared_attr
-    def relationship_fk(cls):
+    def relationship_source_fk(cls):
+        return cls.foreign_key('relationship', nullable=True)
+
+    @declared_attr
+    def relationship_target_fk(cls):
         return cls.foreign_key('relationship', nullable=True)
 
     # endregion
@@ -278,9 +282,21 @@ class InterfaceBase(structure.ModelMixin):
     def node(cls):
         return cls.many_to_one_relationship('node')
 
+    @property
+    def relationship(self):
+        return self.relationship_source or self.relationship_target
+
     @declared_attr
-    def relationship(cls):
-        return cls.many_to_one_relationship('relationship')
+    def relationship_source(cls):
+        return cls.many_to_one_relationship('relationship',
+                                            foreign_key_column='relationship_source_fk',
+                                            backreference='source_interfaces')
+
+    @declared_attr
+    def relationship_target(cls):
+        return cls.many_to_one_relationship('relationship',
+                                            foreign_key_column='relationship_target_fk',
+                                            backreference='target_interfaces')
 
     @declared_attr
     def group(cls):
@@ -288,11 +304,6 @@ class InterfaceBase(structure.ModelMixin):
 
     # endregion
 
-
-    # endregion
-
-
-
     # region many-to-many relationships
 
     @declared_attr
@@ -1191,17 +1202,7 @@ class RelationshipBase(structure.ModelMixin):
     def properties(cls):
         return cls.many_to_many_relationship('parameter', table_prefix='properties')
 
-    @declared_attr
-    def source_interfaces(cls):
-        return cls.many_to_many_relationship('interface',
-                                             table_prefix='source_interfaces',
-                                             relationship_kwargs=dict(lazy='dynamic'))
-
-    @declared_attr
-    def target_interfaces(cls):
-        return cls.many_to_many_relationship('interface',
-                                             table_prefix='target_interfaces',
-                                             relationship_kwargs=dict(lazy='dynamic'))
+    # endregion
 
     @property
     def as_raw(self):


Mime
View raw message