aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/components
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-03-04 14:53:33 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 13:19:05 +0000
commita5445100050e49e83f73424198d73cd72d672a4d (patch)
treecacf4df817df31be23e4e790d1dda857bdae061e /catalog-ui/src/app/models/components
parent51157f92c21976cba4914c378aaa3cba49826931 (diff)
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74 Issue-ID: SDC-977 Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/models/components')
-rw-r--r--catalog-ui/src/app/models/components/component.ts67
-rw-r--r--catalog-ui/src/app/models/components/displayComponent.ts74
-rw-r--r--catalog-ui/src/app/models/components/resource.ts3
-rw-r--r--catalog-ui/src/app/models/components/service.ts3
4 files changed, 130 insertions, 17 deletions
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index daa4a19e19..b7f57227ca 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.ts
@@ -20,6 +20,7 @@
'use strict';
+import * as _ from "lodash";
import {AsdcComment, ArtifactModel, ArtifactGroupModel, IFileDownload, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance,
InputModel, DisplayModule, Module, IValidate, RelationshipModel, IMainCategory, RequirementsGroup, CapabilitiesGroup, AdditionalInformationModel,
Resource, IAppMenu, Service} from "../../models";
@@ -31,6 +32,9 @@ import {ArtifactGroupType} from "../../utils/constants";
import {ComponentMetadata} from "../component-metadata";
import {Capability} from "../capability";
import {Requirement} from "../requirement";
+import {Relationship} from "../graph/relationship";
+import { PolicyInstance } from "app/models/graph/zones/policy-instance";
+
// import {}
export interface IComponent {
@@ -57,7 +61,7 @@ export interface IComponent {
//Property API
addOrUpdateProperty(property:PropertyModel):ng.IPromise<PropertyModel>;
deleteProperty(propertyId:string):ng.IPromise<PropertyModel>;
- updateInstanceProperty(property:PropertyModel):ng.IPromise<PropertyModel>;
+ updateInstanceProperties(componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]>;
//Attribute API
deleteAttribute(attributeId:string):ng.IPromise<AttributeModel>;
@@ -73,6 +77,7 @@ export interface IComponent {
addOrUpdateInstanceArtifact(artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
deleteInstanceArtifact(artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel>;
uploadInstanceEnvFile(artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
+ checkComponentInstanceVersionChange(componentUid:string):ng.IPromise<any>;
changeComponentInstanceVersion(componentUid:string):ng.IPromise<Component>;
updateComponentInstance(componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>;
updateMultipleComponentInstances(instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>>;
@@ -131,6 +136,8 @@ export abstract class Component implements IComponent {
public toscaArtifacts:ArtifactGroupModel;
public distributionStatus:string;
public categories:Array<IMainCategory>;
+ public categoryNormalizedName: string;
+ public subCategoryNormalizedName: string;
public componentInstancesProperties:PropertiesGroup;
public componentInstancesAttributes:AttributesGroup;
public componentInstancesRelations:Array<RelationshipModel>;
@@ -149,6 +156,7 @@ export abstract class Component implements IComponent {
public normalizedName:string;
public systemName:string;
public projectCode:string;
+ public policies:Array<PolicyInstance>;
public groups:Array<Module>;
//custom properties
public componentService:IComponentService;
@@ -172,6 +180,8 @@ export abstract class Component implements IComponent {
this.toscaArtifacts = new ArtifactGroupModel(component.toscaArtifacts);
this.contactId = component.contactId;
this.categories = component.categories;
+ this.categoryNormalizedName = component.categoryNormalizedName;
+ this.subCategoryNormalizedName = component.subCategoryNormalizedName;
this.creatorUserId = component.creatorUserId;
this.creationDate = component.creationDate;
this.creatorFullName = component.creatorFullName;
@@ -423,23 +433,25 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public updateInstanceProperty = (property:PropertyModel):ng.IPromise<PropertyModel> => {
- let deferred = this.$q.defer();
- let onSuccess = (newProperty:PropertyModel):void => {
- // find exist instance property in parent component for update the new value ( find bu uniqueId & path)
- let existProperty:PropertyModel = <PropertyModel>_.find(this.componentInstancesProperties[newProperty.resourceInstanceUniqueId], {
- uniqueId: newProperty.uniqueId,
- path: newProperty.path
+ public updateInstanceProperties = (componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]> => {
+ let deferred = this.$q.defer<PropertyModel[]>();
+ let onSuccess = (newProperties:PropertyModel[]):void => {
+ newProperties.forEach((newProperty) => {
+ // find exist instance property in parent component for update the new value ( find bu uniqueId & path)
+ let existProperty: PropertyModel = <PropertyModel>_.find(this.componentInstancesProperties[newProperty.resourceInstanceUniqueId], {
+ uniqueId: newProperty.uniqueId,
+ path: newProperty.path
+ });
+ let index = this.componentInstancesProperties[newProperty.resourceInstanceUniqueId].indexOf(existProperty);
+ this.componentInstancesProperties[newProperty.resourceInstanceUniqueId][index] = newProperty;
});
- let index = this.componentInstancesProperties[newProperty.resourceInstanceUniqueId].indexOf(existProperty);
- this.componentInstancesProperties[newProperty.resourceInstanceUniqueId][index] = newProperty;
- deferred.resolve(newProperty);
+ deferred.resolve(newProperties);
};
let onFailed = (error:any):void => {
console.log('Failed to update property value');
deferred.reject(error);
};
- this.componentService.updateInstanceProperty(this.uniqueId, property).then(onSuccess, onFailed);
+ this.componentService.updateInstanceProperties(this.uniqueId, componentInstanceId, properties).then(onSuccess, onFailed);
return deferred.promise;
};
@@ -534,6 +546,10 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
+ public checkComponentInstanceVersionChange = (componentUid:string):ng.IPromise<any> => {
+ return this.componentService.checkResourceInstanceVersionChange(this.uniqueId, this.selectedInstance.uniqueId, componentUid);
+ };
+
public createComponentInstance = (componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer();
let onSuccess = (instance:ComponentInstance):void => {
@@ -713,6 +729,33 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
+ public getRelationRequirementCapability(relationship: Relationship, sourceNode:ComponentInstance, targetNode:ComponentInstance): Promise<{requirement:Requirement, capability:Capability}> {
+ // try find the requirement and capability in the source and target component instances:
+ let capability:Capability = targetNode.findCapability(undefined,
+ relationship.relation.capabilityUid,
+ relationship.relation.capabilityOwnerId,
+ relationship.relation.capability);
+ let requirement:Requirement = sourceNode.findRequirement(undefined,
+ relationship.relation.requirementUid,
+ relationship.relation.requirementOwnerId,
+ relationship.relation.requirement);
+
+ return new Promise<{requirement:Requirement, capability:Capability}>((resolve, reject) => {
+ if (capability && requirement) {
+ resolve({capability, requirement});
+ }
+ else {
+ // if requirement and/or capability is missing, then fetch the full relation with its requirement and capability:
+ this.fetchRelation(relationship.relation.id).then((fetchedRelation) => {
+ resolve({
+ capability: capability || fetchedRelation.relationships[0].capability,
+ requirement: requirement || fetchedRelation.relationships[0].requirement
+ });
+ }, reject);
+ }
+ });
+ }
+
public updateRequirementsCapabilities = ():ng.IPromise<any> => {
let deferred = this.$q.defer();
let onSuccess = (response:any):void => {
diff --git a/catalog-ui/src/app/models/components/displayComponent.ts b/catalog-ui/src/app/models/components/displayComponent.ts
index 3a9cbfdaf3..c89490306c 100644
--- a/catalog-ui/src/app/models/components/displayComponent.ts
+++ b/catalog-ui/src/app/models/components/displayComponent.ts
@@ -7,9 +7,9 @@
* 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.
@@ -22,14 +22,23 @@
*/
'use strict';
+import * as _ from "lodash";
import {ComponentType} from "../../utils/constants";
import {ComponentMetadata} from "../component-metadata";
+import {PolicyMetadata} from "../policy-metadata";
+import {GroupMetadata} from "../group-metadata";
import {RequirementsGroup} from "../requirement";
import {CapabilitiesGroup} from "../capability";
-export class LeftPaletteComponent {
+export enum LeftPaletteMetadataTypes {
+ Component,
+ Group,
+ Policy
+}
+export class LeftPaletteComponent {
uniqueId:string;
+ type:string;
displayName:string;
version:string;
mainCategory:string;
@@ -48,10 +57,33 @@ export class LeftPaletteComponent {
componentType:string;
systemName:string;
+ invariantUUID:string;
+
capabilities:CapabilitiesGroup;
requirements:RequirementsGroup;
- constructor(public component:ComponentMetadata) {
+ categoryType:LeftPaletteMetadataTypes;
+
+ constructor(metadataType: LeftPaletteMetadataTypes, item: ComponentMetadata | PolicyMetadata) {
+ if (metadataType === LeftPaletteMetadataTypes.Policy) {
+ this.initPolicy(item as PolicyMetadata);
+ return;
+ }
+
+ if (metadataType === LeftPaletteMetadataTypes.Group) {
+ this.initGroup(item as GroupMetadata);
+ return;
+ }
+
+ if (metadataType === LeftPaletteMetadataTypes.Component) {
+ this.initComponent(item as ComponentMetadata);
+ return;
+ }
+ }
+
+ private initComponent(component:ComponentMetadata): void {
+ this.categoryType = LeftPaletteMetadataTypes.Component;
+
this.icon = component.icon;
this.version = component.version;
this.uniqueId = component.uniqueId;
@@ -61,6 +93,7 @@ export class LeftPaletteComponent {
this.allVersions = component.allVersions;
this.componentType = component.componentType;
this.systemName = component.systemName;
+ this.invariantUUID = component.invariantUUID;
if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) {
this.mainCategory = component.categories[0].name;
@@ -71,6 +104,7 @@ export class LeftPaletteComponent {
}
this.componentSubType = component.resourceType ? component.resourceType: 'SERVICE';
+
this.initDisplayName(component.name);
this.searchFilterTerms = (this.displayName + ' ' + component.description + ' ' + component.tags.join(' ')).toLowerCase() + ' ' + component.version;
this.initIconSprite(component.icon);
@@ -80,6 +114,38 @@ export class LeftPaletteComponent {
}
}
+ private initGroup(group:GroupMetadata): void {
+ this.categoryType = LeftPaletteMetadataTypes.Group;
+
+ this.uniqueId = group.uniqueId;
+ this.displayName = group.type;
+ this.mainCategory = "Groups";
+ this.subCategory = "Groups";
+ this.iconClass = "sprite-group-icons group";
+ this.version = group.version;
+
+ this.type = group.type;
+ this.componentSubType = 'GROUP';
+
+ this.searchFilterTerms = this.displayName + ' ' + group.description + ' ' + group.version;
+ }
+
+ private initPolicy(policy:PolicyMetadata): void {
+ this.categoryType = LeftPaletteMetadataTypes.Policy;
+
+ this.uniqueId = policy.uniqueId;
+ this.displayName = policy.type;
+ this.mainCategory = "Policies";
+ this.subCategory = "Policies";
+ this.iconClass = "sprite-policy-icons policy";
+ this.version = policy.version;
+
+ this.type = policy.type;
+ this.componentSubType = 'POLICY';
+
+ this.searchFilterTerms = this.displayName + ' ' + policy.description + ' ' + policy.version;
+ }
+
public initDisplayName = (name:string):void => {
let newName =
_.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.'))
diff --git a/catalog-ui/src/app/models/components/resource.ts b/catalog-ui/src/app/models/components/resource.ts
index cd839786c5..5bd80e3b72 100644
--- a/catalog-ui/src/app/models/components/resource.ts
+++ b/catalog-ui/src/app/models/components/resource.ts
@@ -22,6 +22,7 @@
* Created by obarda on 2/3/2016.
*/
'use strict';
+import * as _ from "lodash";
import {InstancesInputsOrPropertiesMapData} from "../instance-inputs-properties-map";
import {PropertyModel} from "../properties";
import {DisplayModule} from "../modules/base-module";
@@ -91,7 +92,7 @@ export class Resource extends Component {
};
public isComplex = ():boolean => {
- return this.resourceType === ResourceType.VF || this.resourceType === ResourceType.PNF || this.resourceType === ResourceType.CVFC;
+ return this.resourceType === ResourceType.VF || this.resourceType === ResourceType.PNF || this.resourceType === ResourceType.CVFC || this.resourceType === ResourceType.CR;
};
public isVl = ():boolean => {
diff --git a/catalog-ui/src/app/models/components/service.ts b/catalog-ui/src/app/models/components/service.ts
index ce6921b1bb..439925f062 100644
--- a/catalog-ui/src/app/models/components/service.ts
+++ b/catalog-ui/src/app/models/components/service.ts
@@ -22,11 +22,13 @@
* Created by obarda on 2/4/2016.
*/
'use strict';
+import * as _ from "lodash";
import {IServiceService} from "../../services/components/service-service";
import {Component, PropertyModel, DisplayModule, InputsAndProperties, InputModel, InstancesInputsOrPropertiesMapData, InstancesInputsPropertiesMap,
Distribution, DistributionComponent, ArtifactGroupModel} from "../../models";
import {ArtifactGroupType} from "../../utils/constants";
import {ComponentMetadata} from "../component-metadata";
+import {ForwardingPath} from "app/models/forwarding-path";
export class Service extends Component {
@@ -37,6 +39,7 @@ export class Service extends Component {
public serviceType:string;
public serviceRole:string;
public environmentContext:string;
+ public forwardingPaths:{ [key:string]:ForwardingPath } = {};
constructor(componentService:IServiceService, $q:ng.IQService, component?:Service) {
super(componentService, $q, component);