Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 10FFA200C7F for ; Wed, 24 May 2017 16:09:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0F8E7160BB4; Wed, 24 May 2017 14:09:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D571D160B9C for ; Wed, 24 May 2017 16:09:12 +0200 (CEST) Received: (qmail 53268 invoked by uid 500); 24 May 2017 14:09:12 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 53257 invoked by uid 99); 24 May 2017 14:09:12 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 May 2017 14:09:12 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AAE64C02FE for ; Wed, 24 May 2017 14:09:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.222 X-Spam-Level: X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 2KQpaTsCn7cc for ; Wed, 24 May 2017 14:09:09 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 1981D5F306 for ; Wed, 24 May 2017 14:09:07 +0000 (UTC) Received: (qmail 51944 invoked by uid 99); 24 May 2017 14:09:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 May 2017 14:09:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9CBF3DFB8A; Wed, 24 May 2017 14:09:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: avia@apache.org To: dev@ariatosca.incubator.apache.org Message-Id: <9a18a1e354fc4344b55f7816934d546e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-ariatosca git commit: Add input many-to-one relationships [Forced Update!] Date: Wed, 24 May 2017 14:09:06 +0000 (UTC) archived-at: Wed, 24 May 2017 14:09:14 -0000 Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-180-convert-parameter-to-one-to-many 08bec1792 -> 0cbe5f969 (forced update) 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/0cbe5f96 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/0cbe5f96 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/0cbe5f96 Branch: refs/heads/ARIA-180-convert-parameter-to-one-to-many Commit: 0cbe5f96981918d88e56909b0e133b1b1df13032 Parents: ff9dc08 Author: Avia Efrat Authored: Wed May 24 16:16:37 2017 +0300 Committer: Avia Efrat Committed: Wed May 24 17:08:57 2017 +0300 ---------------------------------------------------------------------- aria/modeling/orchestration.py | 4 +- aria/modeling/service_changes.py | 12 -- aria/modeling/service_common.py | 202 +++++++++++++++++++++++---------- aria/modeling/service_instance.py | 41 +++---- aria/modeling/service_template.py | 46 ++------ 5 files changed, 168 insertions(+), 137 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0cbe5f96/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/0cbe5f96/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/0cbe5f96/aria/modeling/service_common.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py index fec837a..3f3d99d 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): @@ -608,7 +688,7 @@ class InputBase(TemplateModelMixin, caching.HasCachedMethods): for the_relationship in self.__mapper__.relationships: v = getattr(self, the_relationship.key) if v: - return v[0] # because we are many-to-many, the back reference will be a list + return v # because we are many-to-many, the back reference will be a list raise ValueError('orphaned input: does not have an owner: {0}'.format(self.name)) @@ -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): @@ -859,36 +939,36 @@ class PropertyBase(TemplateModelMixin, caching.HasCachedMethods): raise ValueError('orphaned property: 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/0cbe5f96/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/0cbe5f96/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)