You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by av...@apache.org on 2017/05/24 13:17:48 UTC
incubator-ariatosca git commit: Add input many-to-one relationships
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-180-convert-parameter-to-one-to-many ff9dc08e6 -> 08bec1792
Add input many-to-one relationships
To service template, service, interface template, interface, operation
template, operation, execution, task.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/08bec179
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/08bec179
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/08bec179
Branch: refs/heads/ARIA-180-convert-parameter-to-one-to-many
Commit: 08bec1792e7c88421b614bbdc5f6a09604c16d44
Parents: ff9dc08
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Wed May 24 16:16:37 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Wed May 24 16:16:37 2017 +0300
----------------------------------------------------------------------
aria/modeling/orchestration.py | 4 +-
aria/modeling/service_changes.py | 12 ---
aria/modeling/service_common.py | 140 ++++++++++++++++++++++++++-------
aria/modeling/service_instance.py | 41 +++-------
aria/modeling/service_template.py | 46 +++--------
5 files changed, 137 insertions(+), 106 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/08bec179/aria/modeling/orchestration.py
----------------------------------------------------------------------
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index b65ca62..4bd0d85 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -115,7 +115,7 @@ class ExecutionBase(ModelMixin):
@declared_attr
def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
+ return relationship.one_to_many(cls, 'input', dict_key='name')
# region foreign keys
@@ -301,7 +301,7 @@ class TaskBase(ModelMixin):
@declared_attr
def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
+ return relationship.one_to_many(cls, 'input', dict_key='name')
implementation = Column(String)
max_attempts = Column(Integer, default=1)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/08bec179/aria/modeling/service_changes.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_changes.py b/aria/modeling/service_changes.py
index 1974424..f632fef 100644
--- a/aria/modeling/service_changes.py
+++ b/aria/modeling/service_changes.py
@@ -105,10 +105,6 @@ class ServiceUpdateBase(ModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
def to_dict(self, suppress_error=False, **kwargs):
dep_update_dict = super(ServiceUpdateBase, self).to_dict(suppress_error) #pylint: disable=no-member
# Taking care of the fact the DeploymentSteps are _BaseModels
@@ -180,10 +176,6 @@ class ServiceUpdateStepBase(ModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
def __hash__(self):
return hash((getattr(self, self.id_column_name()), self.entity_id))
@@ -266,7 +258,3 @@ class ServiceModificationBase(ModelMixin):
return relationship.many_to_one(cls, 'service', back_populates='modifications')
# endregion
-
- # region many_to_many relationships
-
- # endregion
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/08bec179/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index fec837a..9a8dbdf 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -594,6 +594,86 @@ class InputBase(TemplateModelMixin, caching.HasCachedMethods):
def value(self, value):
self._value = value
+ # region foreign keys
+
+ @declared_attr
+ def service_template_fk(cls):
+ """For Input many-to-one to ServiceTemplate"""
+ return relationship.foreign_key('service_template', nullable=True)
+
+ @declared_attr
+ def service_fk(cls):
+ """For Input many-to-one to Service"""
+ return relationship.foreign_key('service', nullable=True)
+
+ @declared_attr
+ def interface_fk(cls):
+ """For Input many-to-one to Interface"""
+ return relationship.foreign_key('interface', nullable=True)
+
+ @declared_attr
+ def operation_fk(cls):
+ """For Input many-to-one to Operation"""
+ return relationship.foreign_key('operation', nullable=True)
+
+ @declared_attr
+ def interface_template_fk(cls):
+ """For Input many-to-one to InterfaceTemplate"""
+ return relationship.foreign_key('interface_template', nullable=True)
+
+ @declared_attr
+ def operation_template_fk(cls):
+ """For Input many-to-one to OperationTemplate"""
+ return relationship.foreign_key('operation_template', nullable=True)
+
+ @declared_attr
+ def execution_fk(cls):
+ """For Input many-to-one to Execution"""
+ return relationship.foreign_key('execution', nullable=True)
+
+ @declared_attr
+ def task_fk(cls):
+ """For Input many-to-one to Task"""
+ return relationship.foreign_key('task', nullable=True)
+
+ # endregion
+
+ # region many_to_one relationships
+
+ @declared_attr
+ def service_template(cls):
+ return relationship.many_to_one(cls, 'service_template')
+
+ @declared_attr
+ def service(cls):
+ return relationship.many_to_one(cls, 'service')
+
+ @declared_attr
+ def interface(cls):
+ return relationship.many_to_one(cls, 'interface')
+
+ @declared_attr
+ def operation(cls):
+ return relationship.many_to_one(cls, 'operation')
+
+ @declared_attr
+ def interface_template(cls):
+ return relationship.many_to_one(cls, 'interface_template')
+
+ @declared_attr
+ def operation_template(cls):
+ return relationship.many_to_one(cls, 'operation_template')
+
+ @declared_attr
+ def execution(cls):
+ return relationship.many_to_one(cls, 'execution')
+
+ @declared_attr
+ def task(cls):
+ return relationship.many_to_one(cls, 'task')
+
+ # endregion
+
@property
@caching.cachedmethod
def owner(self):
@@ -662,36 +742,36 @@ class InputBase(TemplateModelMixin, caching.HasCachedMethods):
raise ValueError('orphaned input: does not have a container: {0}'.format(self.name))
- @property
- @caching.cachedmethod
- def service(self):
- """
- The :class:`Service` containing this parameter, or None if not contained in a service.
- """
-
- from . import models
- container = self.container
- if isinstance(container, models.Service):
- return container
- elif hasattr(container, 'service'):
- return container.service
- return None
-
- @property
- @caching.cachedmethod
- def service_template(self):
- """
- The :class:`ServiceTemplate` containing this parameter, or None if not contained in a
- service template.
- """
-
- from . import models
- container = self.container
- if isinstance(container, models.ServiceTemplate):
- return container
- elif hasattr(container, 'service_template'):
- return container.service_template
- return None
+ # @property
+ # @caching.cachedmethod
+ # def service(self):
+ # """
+ # The :class:`Service` containing this parameter, or None if not contained in a service.
+ # """
+ #
+ # from . import models
+ # container = self.container
+ # if isinstance(container, models.Service):
+ # return container
+ # elif hasattr(container, 'service'):
+ # return container.service
+ # return None
+ #
+ # @property
+ # @caching.cachedmethod
+ # def service_template(self):
+ # """
+ # The :class:`ServiceTemplate` containing this parameter, or None if not contained in a
+ # service template.
+ # """
+ #
+ # from . import models
+ # container = self.container
+ # if isinstance(container, models.ServiceTemplate):
+ # return container
+ # elif hasattr(container, 'service_template'):
+ # return container.service_template
+ # return None
@property
def as_raw(self):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/08bec179/aria/modeling/service_instance.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py
index 594a531..15b1718 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -125,6 +125,10 @@ class ServiceBase(InstanceModelMixin):
return relationship.one_to_many(cls, 'output', dict_key='name')
@declared_attr
+ def inputs(cls):
+ return relationship.one_to_many(cls, 'input', dict_key='name')
+
+ @declared_attr
def updates(cls):
return relationship.one_to_many(cls, 'service_update')
@@ -170,10 +174,6 @@ class ServiceBase(InstanceModelMixin):
return relationship.many_to_many(cls, 'metadata', dict_key='name')
@declared_attr
- def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
-
- @declared_attr
def plugins(cls):
return relationship.many_to_many(cls, 'plugin', dict_key='name')
@@ -509,6 +509,7 @@ class NodeBase(InstanceModelMixin):
# endregion
# region many_to_many relationships
+
@declared_attr
def properties(cls):
return relationship.many_to_many(cls, 'property', dict_key='name')
@@ -1012,10 +1013,6 @@ class SubstitutionBase(InstanceModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
@property
def as_raw(self):
return collections.OrderedDict((
@@ -1120,10 +1117,6 @@ class SubstitutionMappingBase(InstanceModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
@property
def as_raw(self):
return collections.OrderedDict((
@@ -1550,6 +1543,10 @@ class InterfaceBase(InstanceModelMixin):
# region one_to_many relationships
@declared_attr
+ def inputs(cls):
+ return relationship.one_to_many(cls, 'input', dict_key='name')
+
+ @declared_attr
def operations(cls):
return relationship.one_to_many(cls, 'operation', dict_key='name')
@@ -1579,14 +1576,6 @@ class InterfaceBase(InstanceModelMixin):
# endregion
- # region many_to_many relationships
-
- @declared_attr
- def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
-
- # endregion
-
description = Column(Text)
def configure_operations(self):
@@ -1704,6 +1693,10 @@ class OperationBase(InstanceModelMixin):
# region one_to_many relationships
+ @declared_attr
+ def inputs(cls):
+ return relationship.one_to_many(cls, 'input', dict_key='name')
+
# endregion
# region many_to_one relationships
@@ -1722,14 +1715,6 @@ class OperationBase(InstanceModelMixin):
# endregion
- # region many_to_many relationships
-
- @declared_attr
- def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
-
- # endregion
-
description = Column(Text)
relationship_edge = Column(Boolean)
implementation = Column(Text)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/08bec179/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index 9ba352d..3598bb5 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -219,6 +219,10 @@ class ServiceTemplateBase(TemplateModelMixin):
return relationship.one_to_many(cls, 'output', dict_key='name')
@declared_attr
+ def inputs(cls):
+ return relationship.one_to_many(cls, 'input', dict_key='name')
+
+ @declared_attr
def group_templates(cls):
return relationship.one_to_many(cls, 'group_template', dict_key='name')
@@ -247,10 +251,6 @@ class ServiceTemplateBase(TemplateModelMixin):
# Warning! We cannot use the attr name "metadata" because it's used by SQLAlchemy!
return relationship.many_to_many(cls, 'metadata', dict_key='name')
- @declared_attr
- def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
-
# endregion
@property
@@ -937,10 +937,6 @@ class SubstitutionTemplateBase(TemplateModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
@property
def as_raw(self):
return collections.OrderedDict((
@@ -1052,10 +1048,6 @@ class SubstitutionTemplateMappingBase(TemplateModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
@property
def as_raw(self):
return collections.OrderedDict((
@@ -1220,10 +1212,6 @@ class RequirementTemplateBase(TemplateModelMixin):
# endregion
- # region many_to_many relationships
-
- # endregion
-
target_capability_name = Column(Text)
target_node_template_constraints = Column(PickleType)
@@ -1638,7 +1626,6 @@ class InterfaceTemplateBase(TemplateModelMixin):
'group_template_fk',
'relationship_template_fk']
-
# region foreign keys
@declared_attr
@@ -1663,7 +1650,6 @@ class InterfaceTemplateBase(TemplateModelMixin):
# endregion
-
# region association proxies
# endregion
@@ -1675,6 +1661,10 @@ class InterfaceTemplateBase(TemplateModelMixin):
# region one_to_many relationships
@declared_attr
+ def inputs(cls):
+ return relationship.one_to_many(cls, 'input', dict_key='name')
+
+ @declared_attr
def interfaces(cls):
return relationship.one_to_many(cls, 'interface')
@@ -1704,14 +1694,6 @@ class InterfaceTemplateBase(TemplateModelMixin):
# endregion
- # region many_to_many relationships
-
- @declared_attr
- def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
-
- # endregion
-
description = Column(Text)
@property
@@ -1832,6 +1814,10 @@ class OperationTemplateBase(TemplateModelMixin):
# region one_to_many relationships
@declared_attr
+ def inputs(cls):
+ return relationship.one_to_many(cls, 'input', dict_key='name')
+
+ @declared_attr
def operations(cls):
return relationship.one_to_many(cls, 'operation')
@@ -1850,14 +1836,6 @@ class OperationTemplateBase(TemplateModelMixin):
# endregion
- # region many_to_many relationships
-
- @declared_attr
- def inputs(cls):
- return relationship.many_to_many(cls, 'input', dict_key='name')
-
- # endregion
-
description = Column(Text)
relationship_edge = Column(Boolean)
implementation = Column(Text)