Loading src/context/service/database/Link.py +2 −1 Original line number Diff line number Diff line Loading @@ -64,13 +64,14 @@ def link_set(db_engine : Engine, request : Link) -> Tuple[Dict, bool]: topology_uuids : Set[str] = set() related_topologies : List[Dict] = list() link_endpoints_data : List[Dict] = list() for endpoint_id in request.link_endpoint_ids: for i,endpoint_id in enumerate(request.link_endpoint_ids): endpoint_topology_uuid, _, endpoint_uuid = endpoint_get_uuid( endpoint_id, allow_random=False) link_endpoints_data.append({ 'link_uuid' : link_uuid, 'endpoint_uuid': endpoint_uuid, 'position' : i, }) if endpoint_topology_uuid not in topology_uuids: Loading src/context/service/database/models/LinkModel.py +8 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. from sqlalchemy import Column, DateTime, ForeignKey, String import operator from sqlalchemy import CheckConstraint, Column, DateTime, ForeignKey, Integer, String from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from typing import Dict Loading @@ -38,7 +39,7 @@ class LinkModel(_Base): 'name' : self.link_name, 'link_endpoint_ids': [ link_endpoint.endpoint.dump_id() for link_endpoint in self.link_endpoints for link_endpoint in sorted(self.link_endpoints, key=operator.attrgetter('position')) ], } Loading @@ -47,6 +48,11 @@ class LinkEndPointModel(_Base): link_uuid = Column(ForeignKey('link.link_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) position = Column(Integer, nullable=False) link = relationship('LinkModel', back_populates='link_endpoints', lazy='joined') endpoint = relationship('EndPointModel', lazy='joined') # back_populates='link_endpoints' __table_args__ = ( CheckConstraint(position >= 0, name='check_position_value'), ) Loading
src/context/service/database/Link.py +2 −1 Original line number Diff line number Diff line Loading @@ -64,13 +64,14 @@ def link_set(db_engine : Engine, request : Link) -> Tuple[Dict, bool]: topology_uuids : Set[str] = set() related_topologies : List[Dict] = list() link_endpoints_data : List[Dict] = list() for endpoint_id in request.link_endpoint_ids: for i,endpoint_id in enumerate(request.link_endpoint_ids): endpoint_topology_uuid, _, endpoint_uuid = endpoint_get_uuid( endpoint_id, allow_random=False) link_endpoints_data.append({ 'link_uuid' : link_uuid, 'endpoint_uuid': endpoint_uuid, 'position' : i, }) if endpoint_topology_uuid not in topology_uuids: Loading
src/context/service/database/models/LinkModel.py +8 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. from sqlalchemy import Column, DateTime, ForeignKey, String import operator from sqlalchemy import CheckConstraint, Column, DateTime, ForeignKey, Integer, String from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from typing import Dict Loading @@ -38,7 +39,7 @@ class LinkModel(_Base): 'name' : self.link_name, 'link_endpoint_ids': [ link_endpoint.endpoint.dump_id() for link_endpoint in self.link_endpoints for link_endpoint in sorted(self.link_endpoints, key=operator.attrgetter('position')) ], } Loading @@ -47,6 +48,11 @@ class LinkEndPointModel(_Base): link_uuid = Column(ForeignKey('link.link_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) position = Column(Integer, nullable=False) link = relationship('LinkModel', back_populates='link_endpoints', lazy='joined') endpoint = relationship('EndPointModel', lazy='joined') # back_populates='link_endpoints' __table_args__ = ( CheckConstraint(position >= 0, name='check_position_value'), )