diff options
Diffstat (limited to 'catalog-ui/src/app/models')
29 files changed, 394 insertions, 137 deletions
diff --git a/catalog-ui/src/app/models/capability.ts b/catalog-ui/src/app/models/capability.ts index 79cf425d92..2f2e3a8de6 100644 --- a/catalog-ui/src/app/models/capability.ts +++ b/catalog-ui/src/app/models/capability.ts @@ -23,7 +23,9 @@ */ 'use strict'; import {PropertyModel} from "./properties"; +import {Requirement} from "./requirement"; +export interface RequirementCapabilityModel{}; //this is an object contains keys, when each key has matching array. // for example: key = tosca.capabilities.network.Linkable and the match array is array of capabilities objects export class CapabilitiesGroup { @@ -44,7 +46,7 @@ export class CapabilitiesGroup { } } -export class Capability { +export class Capability implements RequirementCapabilityModel{ //server data name:string; @@ -53,11 +55,12 @@ export class Capability { type:string; uniqueId:string; capabilitySources:Array<String>; + leftOccurrences:string; minOccurrences:string; maxOccurrences:string; - properties:Array<PropertyModel>; description:string; validSourceTypes:Array<string>; + properties:Array<PropertyModel>; //custom selected:boolean; filterTerm:string; @@ -72,6 +75,7 @@ export class Capability { this.type = capability.type; this.uniqueId = capability.uniqueId; this.capabilitySources = capability.capabilitySources; + this.leftOccurrences = capability.leftOccurrences; this.minOccurrences = capability.minOccurrences; this.maxOccurrences = capability.maxOccurrences; this.properties = capability.properties; @@ -83,9 +87,13 @@ export class Capability { } } + public getTitle():string { + return this.ownerName + ': ' + this.name; + } + public getFullTitle():string { let maxOccurrences:string = this.maxOccurrences === 'UNBOUNDED' ? '∞' : this.maxOccurrences; - return this.ownerName + ': ' + this.name + ': [' + this.minOccurrences + ', ' + maxOccurrences + ']'; + return this.getTitle() + ': [' + this.minOccurrences + ', ' + maxOccurrences + ']'; } public toJSON = ():any => { @@ -110,6 +118,10 @@ export class Capability { }); } } + + public isFulfilled() { + return parseInt(this.leftOccurrences) === 0; + } } diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts index 53e8f05cbe..daa4a19e19 100644 --- a/catalog-ui/src/app/models/components/component.ts +++ b/catalog-ui/src/app/models/components/component.ts @@ -29,6 +29,8 @@ import {CommonUtils} from "../../utils/common-utils"; import {QueueUtils} from "../../utils/functions"; import {ArtifactGroupType} from "../../utils/constants"; import {ComponentMetadata} from "../component-metadata"; +import {Capability} from "../capability"; +import {Requirement} from "../requirement"; // import {} export interface IComponent { @@ -82,6 +84,7 @@ export interface IComponent { createRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>; deleteRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>; + fetchRelation(linkId:string):ng.IPromise<RelationshipModel>; //Modules @@ -356,7 +359,6 @@ export abstract class Component implements IComponent { // find exist instance property in parent component for update the new value ( find bu uniqueId ) let existProperty:PropertyModel = <PropertyModel>_.find(this.properties, {uniqueId: newProperty.uniqueId}); let propertyIndex = this.properties.indexOf(existProperty); - newProperty.readonly = this.uniqueId != newProperty.parentUniqueId; this.properties[propertyIndex] = newProperty; deferred.resolve(newProperty); }; @@ -607,6 +609,58 @@ export abstract class Component implements IComponent { }; + public syncComponentByRelation(relation:RelationshipModel) { + relation.relationships.forEach((rel) => { + if (rel.capability) { + const toComponentInstance:ComponentInstance = this.componentInstances.find((inst) => inst.uniqueId === relation.toNode); + const toComponentInstanceCapability:Capability = toComponentInstance.findCapability( + rel.capability.type, rel.capability.uniqueId, rel.capability.ownerId, rel.capability.name); + const isCapabilityFulfilled:boolean = rel.capability.isFulfilled(); + if (isCapabilityFulfilled && toComponentInstanceCapability) { + // if capability is fulfilled and in component, then remove it + console.log('Capability is fulfilled', rel.capability.getFullTitle(), rel.capability.leftOccurrences); + toComponentInstance.capabilities[rel.capability.type].splice( + toComponentInstance.capabilities[rel.capability.type].findIndex((cap) => cap === toComponentInstanceCapability), 1 + ) + } else if (!isCapabilityFulfilled && !toComponentInstanceCapability) { + // if capability is unfulfilled and not in component, then add it + console.log('Capability is unfulfilled', rel.capability.getFullTitle(), rel.capability.leftOccurrences); + toComponentInstance.capabilities[rel.capability.type].push(rel.capability); + } + } + if (rel.requirement) { + const fromComponentInstance:ComponentInstance = this.componentInstances.find((inst) => inst.uniqueId === relation.fromNode); + const fromComponentInstanceRequirement:Requirement = fromComponentInstance.findRequirement( + rel.requirement.capability, rel.requirement.uniqueId, rel.requirement.ownerId, rel.requirement.name); + const isRequirementFulfilled:boolean = rel.requirement.isFulfilled(); + if (isRequirementFulfilled && fromComponentInstanceRequirement) { + // if requirement is fulfilled and in component, then remove it + console.log('Requirement is fulfilled', rel.requirement.getFullTitle(), rel.requirement.leftOccurrences); + fromComponentInstance.requirements[rel.requirement.capability].splice( + fromComponentInstance.requirements[rel.requirement.capability].findIndex((req) => req === fromComponentInstanceRequirement), 1 + ) + } else if (!isRequirementFulfilled && !fromComponentInstanceRequirement) { + // if requirement is unfulfilled and not in component, then add it + console.log('Requirement is unfulfilled', rel.requirement.getFullTitle(), rel.requirement.leftOccurrences); + fromComponentInstance.requirements[rel.requirement.capability].push(rel.requirement); + } + } + }); + } + + public fetchRelation = (linkId:string):ng.IPromise<RelationshipModel> => { + let deferred = this.$q.defer<RelationshipModel>(); + let onSuccess = (relation:RelationshipModel):void => { + this.syncComponentByRelation(relation); + deferred.resolve(relation); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.fetchRelation(this.uniqueId, linkId).then(onSuccess, onFailed); + return deferred.promise; + }; + public createRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => { let deferred = this.$q.defer(); let onSuccess = (relation:RelationshipModel):void => { @@ -615,6 +669,7 @@ export abstract class Component implements IComponent { this.componentInstancesRelations = []; } this.componentInstancesRelations.push(new RelationshipModel(relation)); + this.syncComponentByRelation(relation); deferred.resolve(relation); }; let onFailed = (error:any):void => { @@ -627,11 +682,11 @@ export abstract class Component implements IComponent { public deleteRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => { let deferred = this.$q.defer(); - let onSuccess = (responseRelation:RelationshipModel):void => { + let onSuccess = (relation:RelationshipModel):void => { console.log("Link Deleted In Server"); let relationToDelete = _.find(this.componentInstancesRelations, (item) => { return item.fromNode === relation.fromNode && item.toNode === relation.toNode && _.some(item.relationships, (relationship)=> { - return angular.equals(relation.relationships[0], relationship); + return angular.equals(relation.relationships[0].relation, relationship.relation); }); }); let index = this.componentInstancesRelations.indexOf(relationToDelete); @@ -640,11 +695,14 @@ export abstract class Component implements IComponent { this.componentInstancesRelations.splice(index, 1); } else { this.componentInstancesRelations[index].relationships = - _.reject(this.componentInstancesRelations[index].relationships, relation.relationships[0]); + _.reject(this.componentInstancesRelations[index].relationships, (relationship) => { + return angular.equals(relation.relationships[0].relation, relationship.relation); + }); } } else { console.error("Error while deleting relation - the return delete relation from server was not found in UI") } + this.syncComponentByRelation(relation); deferred.resolve(relation); }; let onFailed = (error:any):void => { @@ -658,8 +716,8 @@ export abstract class Component implements IComponent { public updateRequirementsCapabilities = ():ng.IPromise<any> => { let deferred = this.$q.defer(); let onSuccess = (response:any):void => { - this.capabilities = response.capabilities; - this.requirements = response.requirements; + this.capabilities = new CapabilitiesGroup(response.capabilities); + this.requirements = new RequirementsGroup(response.requirements); deferred.resolve(response); }; let onFailed = (error:any):void => { diff --git a/catalog-ui/src/app/models/componentsInstances/componentInstance.ts b/catalog-ui/src/app/models/componentsInstances/componentInstance.ts index 06939a7a9e..59521ccfc8 100644 --- a/catalog-ui/src/app/models/componentsInstances/componentInstance.ts +++ b/catalog-ui/src/app/models/componentsInstances/componentInstance.ts @@ -23,7 +23,9 @@ */ 'use strict'; import {ArtifactGroupModel, CapabilitiesGroup,RequirementsGroup, PropertyModel, InputModel, Module} from "../../models"; -import {ResourceType} from "../../utils/constants"; +import {ResourceType,ComponentType} from "../../utils/constants"; +import {Capability} from "../capability"; +import {Requirement} from "../requirement"; export class ComponentInstance { @@ -46,6 +48,10 @@ export class ComponentInstance { public capabilities:CapabilitiesGroup; public requirements:RequirementsGroup; public customizationUUID:string; + public sourceModelInvariant:string; + public sourceModelName:string; + public sourceModelUid:string; + public sourceModelUuid:string; //custom properties public certified:boolean; public iconSprite:string; @@ -79,6 +85,10 @@ export class ComponentInstance { this.updatePosition(componentInstance.posX, componentInstance.posY); this.groupInstances = componentInstance.groupInstances; this.invariantName = componentInstance.invariantName; + this.sourceModelInvariant = componentInstance.sourceModelInvariant; + this.sourceModelName = componentInstance.sourceModelName; + this.sourceModelUid = componentInstance.sourceModelUid; + this.sourceModelUuid = componentInstance.sourceModelUuid; } } @@ -97,6 +107,10 @@ export class ComponentInstance { return this.originType === ResourceType.VF || this.originType === ResourceType.PNF || this.originType === ResourceType.CVFC ; } + public isServiceProxy = () :boolean => { + return this.originType === ComponentType.SERVICE_PROXY; + } + public setInstanceRC = ():void=> { _.forEach(this.requirements, (requirementValue:Array<any>, requirementKey)=> { _.forEach(requirementValue, (requirement)=> { @@ -121,6 +135,30 @@ export class ComponentInstance { this.posY = posY; } + public findRequirement(reqType:string, uniqueId:string, ownerId:string, name:string):Requirement|undefined { + let requirement:Requirement = undefined; + const searchGroup = (reqType) ? [this.requirements[reqType]] : this.requirements; + _.some(_.keys(searchGroup), (searchType) => { + requirement = _.find<Requirement>(searchGroup[searchType], (req:Requirement) => ( + req.uniqueId === uniqueId && req.ownerId === ownerId && req.name === name + )); + return requirement; + }); + return requirement; + } + + public findCapability(capType:string, uniqueId:string, ownerId:string, name:string):Capability|undefined { + let capability:Capability = undefined; + const searchGroup = (capType) ? [this.capabilities[capType]] : this.capabilities; + _.some(_.keys(searchGroup), (searchType) => { + capability = _.find<Capability>(searchGroup[searchType], (cap:Capability) => ( + cap.uniqueId === uniqueId && cap.ownerId === ownerId && cap.name === name + )); + return capability; + }); + return capability; + } + public toJSON = ():any => { let temp = angular.copy(this); temp.certified = undefined; diff --git a/catalog-ui/src/app/models/componentsInstances/serviceProxyInstance.ts b/catalog-ui/src/app/models/componentsInstances/serviceProxyInstance.ts new file mode 100644 index 0000000000..a035a17db8 --- /dev/null +++ b/catalog-ui/src/app/models/componentsInstances/serviceProxyInstance.ts @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {ComponentInstance} from "./componentInstance"; + +export class ServiceProxyInstance extends ComponentInstance { + + constructor(componentInstance?:ServiceProxyInstance) { + super(componentInstance); + this.iconSprite = "sprite-proxy-services-icons"; + //this.originType = "ServiceProxy"; + } +} + diff --git a/catalog-ui/src/app/models/graph/relationMenuObjects.ts b/catalog-ui/src/app/models/graph/connectRelationModel.ts index 37b7cee349..af9732fa59 100644 --- a/catalog-ui/src/app/models/graph/relationMenuObjects.ts +++ b/catalog-ui/src/app/models/graph/connectRelationModel.ts @@ -18,12 +18,11 @@ * ============LICENSE_END========================================================= */ 'use strict'; -import {MatchReqToReq, MatchBase} from "./match-relation"; +import {Match} from "./match-relation"; import {CompositionCiNodeBase} from "./nodes/composition-graph-nodes/composition-ci-node-base"; -import {Component} from "../components/component"; import {ComponentInstance} from "../componentsInstances/componentInstance"; -export class RelationMenuDirectiveObj { +export class ConnectRelationModel { fromNode:CompositionCiNodeBase; toNode:CompositionCiNodeBase; @@ -31,17 +30,16 @@ export class RelationMenuDirectiveObj { rightSideLink:GraphLinkMenuSide; leftSideLink:GraphLinkMenuSide; selectionText:string; - vlType:string; + possibleRelations:Array<Match>; - constructor(fromNode:CompositionCiNodeBase, toNode:CompositionCiNodeBase, menuPosition:Cy.Position, possibleRelations:Array<MatchBase>) { + constructor(fromNode:CompositionCiNodeBase, toNode:CompositionCiNodeBase, possibleRelations:Array<Match>) { this.fromNode = fromNode; this.toNode = toNode; - // this.modelLinks = modelLinks; - this.menuPosition = menuPosition; + this.leftSideLink = new GraphLinkMenuSide(this.fromNode.componentInstance); this.rightSideLink = new GraphLinkMenuSide(this.toNode.componentInstance); this.selectionText = ''; - this.vlType = null; + this.possibleRelations = possibleRelations; possibleRelations.forEach((match:any) => { @@ -57,20 +55,13 @@ export class RelationMenuDirectiveObj { //push the match to fromNode object (from node is always the requirement) this.leftSideLink.requirements[reqObjKey].push(match); - if (match instanceof MatchReqToReq) { - //init the right side requirements Array - if (!this.rightSideLink.requirements[capObjKey]) { - this.rightSideLink.requirements[capObjKey] = []; - } - this.rightSideLink.requirements[capObjKey].push(match); - } else { - //init the right side capabilities Array - if (!this.rightSideLink.capabilities[capObjKey]) { - this.rightSideLink.capabilities[capObjKey] = []; - } - //add to array - this.rightSideLink.capabilities[capObjKey].push(match); + //init the right side capabilities Array + if (!this.rightSideLink.capabilities[capObjKey]) { + this.rightSideLink.capabilities[capObjKey] = []; } + //add to array + this.rightSideLink.capabilities[capObjKey].push(match); + } else { if (!this.rightSideLink.requirements[reqObjKey]) { @@ -100,7 +91,7 @@ export class GraphLinkMenuSide { this.requirements = {}; } - public selectMatchArr(matchArr:Array<MatchBase>):void { + public selectMatchArr(matchArr:Array<Match>):void { if (this.selectedMatch === matchArr) { this.selectedMatch = undefined; } else { diff --git a/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts index 6b2e12a215..42cce998f1 100644 --- a/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts @@ -29,7 +29,7 @@ export class CompositionCiUcpeLink extends CompositionCiLinkBase { super(relation, singleRelation); this.isFromUcpe = from; this.target = relation.toNode; - this.source = singleRelation.requirementOwnerId; + this.source = singleRelation.relation.requirementOwnerId; this.relation.relationships = [singleRelation]; this.color = GraphColors.BASE_LINK; } diff --git a/catalog-ui/src/app/models/graph/graph-links/links-factory.ts b/catalog-ui/src/app/models/graph/graph-links/links-factory.ts index 0be5d6faf6..88c5323330 100644 --- a/catalog-ui/src/app/models/graph/graph-links/links-factory.ts +++ b/catalog-ui/src/app/models/graph/graph-links/links-factory.ts @@ -46,7 +46,7 @@ export class LinksFactory { // newRelation = new CompositionCiUcpeLink(relation, fromNode.isUcpePart, singleRelation); // } // } else - if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { + if (singleRelation.relation.relationship.type && _.includes(singleRelation.relation.relationship.type.toLowerCase(), 'link')) { newRelation = new CompositionCiVLink(relation, singleRelation); } else { newRelation = new CompositionCiSimpleLink(relation, singleRelation); @@ -68,7 +68,7 @@ export class LinksFactory { let newRelation:ModuleCiLinkBase; - if (_.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { + if (_.includes(singleRelation.relation.relationship.type.toLowerCase(), 'link')) { newRelation = new ModuleCiVlLink(relation, singleRelation); } else { newRelation = new ModuleCiLinkBase(relation, singleRelation); diff --git a/catalog-ui/src/app/models/graph/match-relation.ts b/catalog-ui/src/app/models/graph/match-relation.ts index 4fb073d579..8d139d6405 100644 --- a/catalog-ui/src/app/models/graph/match-relation.ts +++ b/catalog-ui/src/app/models/graph/match-relation.ts @@ -20,80 +20,49 @@ 'use strict'; import {Requirement} from "../requirement"; import {Capability} from "../capability"; -import {Relationship, RelationshipModel, RelationType} from "./relationship"; +import {Relationship, RelationshipModel} from "./relationship"; +import {PropertyModel} from "../properties"; -export class MatchBase { +export class Match { requirement:Requirement; + capability:Capability; isFromTo:boolean; fromNode:string; toNode:string; + capabilityProperties:Array<PropertyModel>; // use this to store the capability properties, since there are times the capability itself is not available (when fulfilled). + private _relationship:Relationship; - constructor(requirement:Requirement, isFromTo:boolean, fromNode:string, toNode:string) { + constructor(requirement:Requirement, capability:Capability, isFromTo:boolean, fromNode:string, toNode:string) { this.requirement = requirement; + this.capability = capability; this.isFromTo = isFromTo; this.fromNode = fromNode; this.toNode = toNode; } - public getDisplayText = (menuSide:string):string => { - return ''; - }; - - public isOwner = (id:string):boolean => { - return false; - } - -} - -export class MatchReqToReq extends MatchBase { - - secondRequirement:Requirement; - - constructor(requirement:Requirement, secondRequirement:Requirement, isFromTo:boolean, fromNode:string, toNode:string) { - super(requirement, isFromTo, fromNode, toNode); - this.secondRequirement = secondRequirement; - } - - public getDisplayText = (menuSide:string):string => { - if ('left' == menuSide) { - return this.requirement.getFullTitle(); + // NOTE: Hold the relationship instance for cases capability / requirement are not available (when fulfilled). + // In case relationship instance is not manually saved to here, then build the relationship from the given capability and requirement. + public get relationship():Relationship { + if (!this._relationship) { + this._relationship = this.matchToRelation(); } - return this.secondRequirement.getFullTitle(); - }; - - public isOwner = (id:string):boolean => { - return this.secondRequirement.ownerId === id || this.requirement.ownerId === id; + return this._relationship; } -} - -export class MatchReqToCapability extends MatchBase { - - capability:Capability; - - constructor(requirement:Requirement, capability:Capability, isFromTo:boolean, fromNode:string, toNode:string) { - super(requirement, isFromTo, fromNode, toNode); - this.capability = capability; + public set relationship(relationship) { + this._relationship = relationship; } public matchToRelation = ():Relationship => { - let relationship:Relationship = new Relationship(); - relationship.capability = this.capability.name; - relationship.capabilityOwnerId = this.capability.ownerId; - relationship.capabilityUid = this.capability.uniqueId; - relationship.relationship = new RelationType(this.capability.type); - relationship.requirement = this.requirement.name; - relationship.requirementOwnerId = this.requirement.ownerId; - relationship.requirementUid = this.requirement.uniqueId; + const relationship:Relationship = new Relationship(); + relationship.setRelationProperties(this.capability, this.requirement); return relationship; }; - public getDisplayText = (menuSide:string):string => { if (this.isFromTo && 'left' == menuSide || !this.isFromTo && 'right' == menuSide) { return this.requirement.getFullTitle(); } return this.capability.getFullTitle(); - }; public isOwner = (id:string):boolean => { @@ -108,4 +77,3 @@ export class MatchReqToCapability extends MatchBase { }; } - diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts index 681cebc8d2..3b634b1f6e 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts @@ -48,7 +48,6 @@ export abstract class CompositionCiNodeBase extends CommonCINodeBase implements this.isGroup = false; this.isUcpePart = false; this.isInsideGroup = false; - } public initUncertifiedImage(node:Cy.Collection, nodeMinSize:number):string { @@ -61,8 +60,10 @@ export abstract class CompositionCiNodeBase extends CommonCINodeBase implements uncertifiedCanvasWidth = nodeWidth + uncertifiedIconWidth/2; //expand canvas so that only half of the icon overlaps with the node } - this.imageCreator.getImageBase64(this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png', - this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'uncertified.png', nodeWidth, uncertifiedCanvasWidth, uncertifiedIconWidth) + + + this.imageCreator.getImageBase64(this.imagesPath + this.componentInstance.icon + '.png', + this.imagesPath + 'uncertified.png', nodeWidth, uncertifiedCanvasWidth, uncertifiedIconWidth) .then(imageBase64 => { this.img = imageBase64; node.style({ diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-configuration.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-configuration.ts new file mode 100644 index 0000000000..1182f5e664 --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-configuration.ts @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants"; +import {ComponentInstance, CompositionCiNodeBase} from "../../../../models"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +export class CompositionCiNodeConfiguration extends CompositionCiNodeBase { + + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initConfiguration(); + } + + private initConfiguration():void { + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; + this.img = this.imagesPath + this.componentInstance.icon + '.png'; + this.imgWidth = GraphUIObjects.SMALL_RESOURCE_WIDTH; + this.type = "basic-small-node"; + this.classes = 'configuration-node'; + } +} diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts index cded0ea104..3bd57695ec 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts @@ -34,7 +34,8 @@ export class CompositionCiNodeCp extends CompositionCiNodeBase { private initCp():void { let sdcConfig = AngularJSBridge.getAngularConfig(); - this.img = sdcConfig.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; + this.img = this.imagesPath + this.componentInstance.icon + '.png'; this.imgWidth = GraphUIObjects.SMALL_RESOURCE_WIDTH; this.type = "basic-small-node"; //if the cp from type cpEndPointInstances create with another template diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service-proxy.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service-proxy.ts new file mode 100644 index 0000000000..b993490043 --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service-proxy.ts @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants"; +import {ComponentInstance, CompositionCiNodeBase} from "../../../../models"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +export class CompositionCiNodeServiceProxy extends CompositionCiNodeBase { + + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initService(); + } + + private initService():void { + this.imagesPath = this.imagesPath + ImagesUrl.SERVICE_PROXY_ICONS; + this.img = this.imagesPath + this.componentInstance.icon + '.png'; + this.imgWidth = GraphUIObjects.DEFAULT_RESOURCE_WIDTH; + this.classes = 'service-node' + if (!this.certified) { + this.classes = this.classes + ' not-certified'; + } + + } +} diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts index 81ee61a14f..b4e6ac354a 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts @@ -30,7 +30,7 @@ export class CompositionCiNodeService extends CompositionCiNodeBase { } private initService():void { - + this.imagesPath = this.imagesPath + ImagesUrl.SERVICE_ICONS; this.img = this.imagesPath + ImagesUrl.SERVICE_ICONS + this.componentInstance.icon + '.png'; this.imgWidth = GraphUIObjects.DEFAULT_RESOURCE_WIDTH; this.classes = 'service-node' diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts index 5013e52457..a79b183db4 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts @@ -20,6 +20,7 @@ import {CompositionCiNodeCp, ComponentInstance} from "./../../../../models"; import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +import { ImagesUrl} from "../../../../utils/constants"; export class CompositionCiNodeUcpeCp extends CompositionCiNodeCp { @@ -31,5 +32,6 @@ export class CompositionCiNodeUcpeCp extends CompositionCiNodeCp { this.parent = instance.uniqueId; this.type = 'ucpe-cp-node'; //the type is for the handle (plus icon) extension this.isDraggable = false; + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; } } diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts index b8f844cba8..3dd6a4e238 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts @@ -21,6 +21,7 @@ import {ComponentInstance} from "../../../componentsInstances/componentInstance"; import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; import {CompositionCiNodeBase} from "./composition-ci-node-base"; +import { ImagesUrl} from "../../../../utils/constants"; export class NodeUcpe extends CompositionCiNodeBase { constructor(instance:ComponentInstance, @@ -36,6 +37,7 @@ export class NodeUcpe extends CompositionCiNodeBase { this.classes = 'ucpe-node'; this.type = 'ucpe-node'; this.allowConnection = false; + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; if (!this.certified) { this.classes = this.classes + ' not-certified-ucpe'; diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts index 005804c11f..b5ad57a5c3 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts @@ -31,7 +31,8 @@ export class CompositionCiNodeVf extends CompositionCiNodeBase { } private initVf():void { - this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; + this.img = this.imagesPath + this.componentInstance.icon + '.png'; this.imgWidth = GraphUIObjects.DEFAULT_RESOURCE_WIDTH; this.classes = 'vf-node'; if (!this.certified) { diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts index c8ae004003..5f07986d5c 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts @@ -29,6 +29,7 @@ export class CompositionCiNodeVfc extends CompositionCiNodeBase { } private initVfc():void { - this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; + this.img = this.imagesPath + this.componentInstance.icon + '.png'; } } diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts index bf52ec0408..29cd9256d9 100644 --- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts @@ -48,6 +48,7 @@ export class CompositionCiNodeVl extends CompositionCiNodeBase { } this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'vl.png'; this.imgWidth = GraphUIObjects.SMALL_RESOURCE_WIDTH; + this.imagesPath = this.imagesPath + ImagesUrl.RESOURCE_ICONS; this.classes = 'vl-node'; if (!this.certified) { diff --git a/catalog-ui/src/app/models/graph/nodes/modules-graph-nodes/module-node-base.ts b/catalog-ui/src/app/models/graph/nodes/modules-graph-nodes/module-node-base.ts index ccc8ed4afa..4e9fb0b0ab 100644 --- a/catalog-ui/src/app/models/graph/nodes/modules-graph-nodes/module-node-base.ts +++ b/catalog-ui/src/app/models/graph/nodes/modules-graph-nodes/module-node-base.ts @@ -24,6 +24,7 @@ import {ImagesUrl} from "../../../../utils/constants"; import {Module} from "../../../modules/base-module"; import {CommonNodeBase} from "../base-common-node"; +import {AngularJSBridge} from "../../../../services/angular-js-bridge-service"; export interface IModuleNodeBase { } @@ -44,7 +45,7 @@ export class ModuleNodeBase extends CommonNodeBase implements IModuleNodeBase { this.name = this.module.name; this.displayName = this.module.name; this.isGroup = true; - this.img = ImagesUrl.MODULE_ICON; + this.img = AngularJSBridge.getAngularConfig().imagesPath + ImagesUrl.MODULE_ICON; this.classes = "module-node"; } diff --git a/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts b/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts index c7f8eaa126..245f2e10d9 100644 --- a/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts +++ b/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts @@ -19,8 +19,8 @@ */ 'use strict'; -import {CompositionCiNodeUcpeCp, Module, ModuleNodeBase, CompositionCiNodeVf, CompositionCiNodeVl, CompositionCiNodeCp, - NodeUcpe, CompositionCiNodeService, CompositionCiNodeBase, ComponentInstance} from "./../../../models"; +import {CompositionCiNodeUcpeCp, Module, ModuleNodeBase, CompositionCiNodeVf, CompositionCiNodeVl, CompositionCiNodeCp, CompositionCiNodeConfiguration, + NodeUcpe, CompositionCiNodeService,CompositionCiNodeServiceProxy, CompositionCiNodeBase, ComponentInstance} from "./../../../models"; import {ComponentType, ResourceType} from "../../../utils/constants"; import {ImageCreatorService} from "../../../directives/graphs-v2/image-creator/image-creator.service"; @@ -37,12 +37,18 @@ export class NodesFactory { if (instance.originType === ComponentType.SERVICE) { return new CompositionCiNodeService(instance, this.imageCreator); } + if (instance.originType === ComponentType.SERVICE_PROXY) { + return new CompositionCiNodeServiceProxy(instance, this.imageCreator); + } if (instance.originType === ResourceType.CP) { return new CompositionCiNodeCp(instance, this.imageCreator); } if (instance.originType === ResourceType.VL) { return new CompositionCiNodeVl(instance, this.imageCreator); } + if (instance.originType === ResourceType.CONFIGURATION) { + return new CompositionCiNodeConfiguration(instance, this.imageCreator); + } return new CompositionCiNodeVf(instance, this.imageCreator); }; diff --git a/catalog-ui/src/app/models/graph/relationship.ts b/catalog-ui/src/app/models/graph/relationship.ts index 67a5488b59..57ff45ef00 100644 --- a/catalog-ui/src/app/models/graph/relationship.ts +++ b/catalog-ui/src/app/models/graph/relationship.ts @@ -58,7 +58,8 @@ export class RelationType { } } -export class Relationship { +export class RelationshipType { + id:string; capability:string; capabilityOwnerId:string; capabilityUid:string; @@ -67,8 +68,9 @@ export class Relationship { requirementOwnerId:string; requirementUid:string; - constructor(relationship?:Relationship) { + constructor(relationship?:RelationshipType) { if (relationship) { + this.id = relationship.id; this.capability = relationship.capability; this.capabilityOwnerId = relationship.capabilityOwnerId; this.capabilityUid = relationship.capabilityUid; @@ -79,17 +81,41 @@ export class Relationship { } else { this.relationship = new RelationType(); } - } - public setRelationProperties = (capability:Capability, requirement:Requirement)=> { - this.capability = capability.name; - this.capabilityOwnerId = capability.ownerId; - this.capabilityUid = capability.uniqueId; - this.relationship = new RelationType(capability.type); - this.requirement = requirement.name; - this.requirementOwnerId = requirement.ownerId; - this.requirementUid = requirement.uniqueId; + public setRelationProperties = (capability?:Capability, requirement?:Requirement)=> { + if (capability) { + this.capability = capability.name; + this.capabilityOwnerId = capability.ownerId; + this.capabilityUid = capability.uniqueId; + this.relationship = new RelationType(capability.type); + } + if (requirement) { + this.requirement = requirement.name; + this.requirementOwnerId = requirement.ownerId; + this.requirementUid = requirement.uniqueId; + } }; +} + +export class Relationship { + relation: RelationshipType; + capability?: Capability; + requirement?: Requirement; + + constructor(fullRelationship?:Relationship) { + if (fullRelationship) { + this.relation = new RelationshipType(fullRelationship.relation); + this.capability = fullRelationship.capability && new Capability(fullRelationship.capability); + this.requirement = fullRelationship.requirement && new Requirement(fullRelationship.requirement); + } else { + this.relation = new RelationshipType(); + } + } + public setRelationProperties(capability?:Capability, requirement?:Requirement) { + this.relation.setRelationProperties(capability, requirement); + this.capability = capability; + this.requirement = requirement; + }; } diff --git a/catalog-ui/src/app/models/heat-parameters.ts b/catalog-ui/src/app/models/heat-parameters.ts index a199c9d847..153108a5f4 100644 --- a/catalog-ui/src/app/models/heat-parameters.ts +++ b/catalog-ui/src/app/models/heat-parameters.ts @@ -31,6 +31,7 @@ export class HeatParameterModel { currentValue:string; defaultValue:string; + filterTerm:string; constructor(parameter?:HeatParameterModel) { } diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts index c46c8ad28d..14b6385f2f 100644 --- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts +++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts @@ -55,7 +55,7 @@ export class PropertyBEModel { this.schema = property.schema; this.type = property.type; this.uniqueId = property.uniqueId; - this.value = property.value ? property.value : property.defaultValue; + this.value = property.value; this.definition = property.definition; this.getInputValues = property.getInputValues; } diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts index b35bb27b65..6faa6ada84 100644 --- a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts +++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts @@ -38,6 +38,7 @@ export class PropertyFEModel extends PropertyBEModel { constructor(property: PropertyBEModel){ super(property); + this.value = property.value ? property.value : property.defaultValue;//In FE if a property doesn't have value - display the default value this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1; this.setNonDeclared(); this.derivedDataType = this.getDerivedPropertyType(); diff --git a/catalog-ui/src/app/models/properties.ts b/catalog-ui/src/app/models/properties.ts index f46bf8beb0..7a1f1a39ef 100644 --- a/catalog-ui/src/app/models/properties.ts +++ b/catalog-ui/src/app/models/properties.ts @@ -21,6 +21,7 @@ 'use strict'; import {SchemaPropertyGroupModel, SchemaProperty} from "./aschema-property"; import {InputPropertyBase} from "./input-property-base"; +import {PropertyBEModel} from "./properties-inputs/property-be-model"; export class PropertiesGroup { constructor(propertiesObj?:PropertiesGroup) { @@ -54,8 +55,7 @@ export interface IPropertyModel extends InputPropertyBase { simpleType:string; } -export class PropertyModel implements IPropertyModel { - +export class PropertyModel extends PropertyBEModel implements IPropertyModel { //server data uniqueId:string; name:string; @@ -90,19 +90,10 @@ export class PropertyModel implements IPropertyModel { constructor(property?:PropertyModel) { + super(property); if (property) { - this.uniqueId = property.uniqueId; - this.name = property.name; this.constraints = property.constraints; - this.defaultValue = property.defaultValue; - this.description = property.description; - this.password = property.password; - this.required = property.required; - this.type = property.type; this.source = property.source; - this.parentUniqueId = property.parentUniqueId; - this.schema = property.schema; - this.value = property.value ? property.value : property.defaultValue; this.valueUniqueUid = property.valueUniqueUid; this.path = property.path; this.rules = property.rules; diff --git a/catalog-ui/src/app/models/radio-button.ts b/catalog-ui/src/app/models/radio-button.ts new file mode 100644 index 0000000000..e907b26bce --- /dev/null +++ b/catalog-ui/src/app/models/radio-button.ts @@ -0,0 +1,11 @@ +/** + * Created by rc2122 on 9/5/2017. + */ +export class RadioButtonModel{ + key: string; + value: any; + constructor(key: string, value: any){ + this.key = key; + this.value = value; + } +} diff --git a/catalog-ui/src/app/models/requirement.ts b/catalog-ui/src/app/models/requirement.ts index 53e870679d..d880456b06 100644 --- a/catalog-ui/src/app/models/requirement.ts +++ b/catalog-ui/src/app/models/requirement.ts @@ -22,6 +22,7 @@ * Created by obarda on 4/20/2016. */ 'use strict'; +import {RequirementCapabilityModel} from "./capability"; //this is an object contains keys, when each key has matching array. // for example: key = tosca.capabilities.network. and the match array is array of requirements objects export class RequirementsGroup { @@ -36,7 +37,7 @@ export class RequirementsGroup { } } -export class Requirement { +export class Requirement implements RequirementCapabilityModel{ //server data capability:string; @@ -46,6 +47,7 @@ export class Requirement { node:string; uniqueId:string; relationship:string; + leftOccurrences:string; minOccurrences:string; maxOccurrences:string; //custom @@ -61,6 +63,7 @@ export class Requirement { this.node = requirement.node; this.uniqueId = requirement.uniqueId; this.relationship = requirement.relationship; + this.leftOccurrences = requirement.leftOccurrences; this.minOccurrences = requirement.minOccurrences; this.maxOccurrences = requirement.maxOccurrences; this.initFilterTerm(); @@ -68,9 +71,12 @@ export class Requirement { } } + public getTitle():string { + return this.ownerName + ': ' + this.name; + } + public getFullTitle():string { - return this.ownerName + ': ' + this.name + - ': [' + this.minOccurrences + ', ' + this.maxOccurrences + ']'; + return this.getTitle() + ': [' + this.minOccurrences + ', ' + this.maxOccurrences + ']'; } public toJSON = ():any => { @@ -86,6 +92,10 @@ export class Requirement { (this.relationship ? (this.relationship.substring("tosca.relationships.".length) + " ") : "") + this.minOccurrences + "," + this.maxOccurrences; } + + public isFulfilled() { + return parseInt(this.leftOccurrences) === 0; + } } diff --git a/catalog-ui/src/app/models/user.ts b/catalog-ui/src/app/models/user.ts index 54ddf1e5f6..0fb5364290 100644 --- a/catalog-ui/src/app/models/user.ts +++ b/catalog-ui/src/app/models/user.ts @@ -19,7 +19,6 @@ */ 'use strict'; -import {IUserResource} from "../services/user-resource-service"; export enum UserRole { ADMIN, @@ -46,7 +45,7 @@ export interface IUserProperties extends IUserManager { } export interface IUser { - resource:IUserResource; + userInfo:IUserProperties; getRole():UserRole; getRoleToView():string; getName():string; @@ -56,32 +55,32 @@ export interface IUser { export class User implements IUser { - constructor(public resource:IUserResource) { + constructor(public userInfo:IUserProperties) { } public getLastName = () => { - return this.resource.lastName; - } + return this.userInfo.lastName; + }; public getFirstName = () => { - return this.resource.firstName; - } + return this.userInfo.firstName; + }; public getName = () => { - return this.resource.firstName + ' ' + this.resource.lastName; - } + return this.userInfo.firstName + ' ' + this.userInfo.lastName; + }; public getLastLogin = () => { - if (!this.resource.lastLoginTime || this.resource.lastLoginTime === "0") { + if (!this.userInfo.lastLoginTime || this.userInfo.lastLoginTime === "0") { return ""; } else { - return this.resource.lastLoginTime; + return this.userInfo.lastLoginTime; } - } + }; public getRole = ():UserRole => { let role:UserRole; - switch (UserRole[this.resource.role.toUpperCase()]) { + switch (UserRole[this.userInfo.role.toUpperCase()]) { case UserRole.ADMIN: role = UserRole.ADMIN; break; @@ -99,10 +98,10 @@ export class User implements IUser { break; } return role; - } + }; public getRoleToView = ():string => { - let role:string = this.resource.role.toLowerCase().replace('governor', 'governance_Rep'); + let role:string = this.userInfo.role.toLowerCase().replace('governor', 'governance_Rep'); return role.charAt(0).toUpperCase() + role.slice(1).replace('_', ' '); } } diff --git a/catalog-ui/src/app/models/wizard-step.ts b/catalog-ui/src/app/models/wizard-step.ts new file mode 100644 index 0000000000..b8484b2dd6 --- /dev/null +++ b/catalog-ui/src/app/models/wizard-step.ts @@ -0,0 +1,19 @@ +/** + * Created by rc2122 on 8/16/2017. + */ + +import {Type} from "@angular/core"; + +export interface IStepComponent { + preventNext():boolean; + preventBack():boolean; +} + +export class StepModel{ + title: string; + component: Type<IStepComponent>; + constructor(title: string, component: Type<IStepComponent>){ + this.title = title; + this.component = component; + } +} |