2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 * Created by obarda on 5/1/2016.
24 import * as _ from "lodash";
25 import {RelationshipModel, Relationship, CompositionCiLinkBase, CompositionCiNodeBase, LinkUcpeHost, CompositionCiUcpeLink,
26 CompositionCiVlUcpeLink, CompositionCiSimpleLink, ModuleCiLinkBase, ModuleCiVlLink, CompositionCiVLink} from "../../../models";
28 export class LinksFactory {
33 public createGraphLink = (cy:Cy.Instance, relation:RelationshipModel, singleRelation:Relationship):CompositionCiLinkBase => {
35 let newRelation:CompositionCiLinkBase;
37 // let fromNode:CompositionCiNodeBase = cy.getElementById(relation.fromNode).data();
38 // let toNode:CompositionCiNodeBase = cy.getElementById(relation.toNode).data();
40 // if ((relation.fromNode && fromNode.isUcpePart) || (relation.toNode && toNode.isUcpePart )) { //Link from or to node inside ucpe
42 // if (singleRelation && singleRelation.relationship.type && singleRelation.relationship.type == 'tosca.relationships.HostedOn') {
43 // newRelation = new LinkUcpeHost(relation, singleRelation);
44 // } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) {
45 // newRelation = new CompositionCiVlUcpeLink(relation, fromNode.isUcpePart, singleRelation);
47 // newRelation = new CompositionCiUcpeLink(relation, fromNode.isUcpePart, singleRelation);
50 if (singleRelation.relation.relationship.type && _.includes(singleRelation.relation.relationship.type.toLowerCase(), 'link')) {
51 newRelation = new CompositionCiVLink(relation, singleRelation);
53 newRelation = new CompositionCiSimpleLink(relation, singleRelation);
59 public createUcpeHostLink = (relation:RelationshipModel):LinkUcpeHost => {
60 return new LinkUcpeHost(relation);
63 public createVLLink = (relation:RelationshipModel):CompositionCiVLink => {
64 return new CompositionCiVLink(relation);
68 public createModuleGraphLinks = (relation:RelationshipModel, singleRelation:Relationship):ModuleCiLinkBase => {
70 let newRelation:ModuleCiLinkBase;
72 if (_.includes(singleRelation.relation.relationship.type.toLowerCase(), 'link')) {
73 newRelation = new ModuleCiVlLink(relation, singleRelation);
75 newRelation = new ModuleCiLinkBase(relation, singleRelation);