summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/components
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models/components')
-rw-r--r--catalog-ui/src/app/models/components/component.ts514
-rw-r--r--catalog-ui/src/app/models/components/displayComponent.ts139
-rw-r--r--catalog-ui/src/app/models/components/service.ts8
3 files changed, 59 insertions, 602 deletions
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index 8f0fa33c42..b76d29c8c6 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.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.
@@ -48,67 +48,33 @@ export interface IComponent {
createComponentOnServer():ng.IPromise<Component>;
changeLifecycleState(state:string, commentObj:AsdcComment):ng.IPromise<Component>;
validateName(newName:string):ng.IPromise<IValidate>;
- updateRequirementsCapabilities():ng.IPromise<any>;
//Artifacts API
addOrUpdateArtifact(artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- updateMultipleArtifacts(artifacts:Array<ArtifactModel>):ng.IPromise<any>;
deleteArtifact(artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel>;
downloadInstanceArtifact(artifactId:string):ng.IPromise<IFileDownload>;
downloadArtifact(artifactId:string):ng.IPromise<IFileDownload>;
- getArtifactByGroupType(artifactGroupType:string):ng.IPromise<ArtifactGroupModel>;
-
//Property API
addOrUpdateProperty(property:PropertyModel):ng.IPromise<PropertyModel>;
deleteProperty(propertyId:string):ng.IPromise<PropertyModel>;
- updateInstanceProperties(componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]>;
//Attribute API
deleteAttribute(attributeId:string):ng.IPromise<AttributeModel>;
addOrUpdateAttribute(attribute:AttributeModel):ng.IPromise<AttributeModel>;
- updateInstanceAttribute(attribute:AttributeModel):ng.IPromise<AttributeModel>;
-
-
-
-
- //Component Instance API
- createComponentInstance(componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>;
- deleteComponentInstance(componentInstanceId:string):ng.IPromise<ComponentInstance>;
- 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>>;
-
- //Inputs API
- getComponentInstanceInputProperties(componentInstanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>>
- getComponentInstanceProperties(componentInstanceId:string):ng.IPromise<Array<PropertyModel>>
- getComponentInputs(componentId:string):ng.IPromise<Array<InputModel>>;
-
- createRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>;
- deleteRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>;
- fetchRelation(linkId:string):ng.IPromise<RelationshipModel>;
-
//Modules
getModuleForDisplay(moduleId:string):ng.IPromise<DisplayModule>;
getModuleInstanceForDisplay(componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule>;
updateGroupMetadata(group:Module):ng.IPromise<Module>;
-
//---------------------------------------------- HELP FUNCTIONS ----------------------------------------------------//
-
-
getComponentSubType():string;
isAlreadyCertified():boolean;
isService():boolean;
isResource():boolean;
isComplex():boolean;
- getAdditionalInformation():Array<AdditionalInformationModel>;
getAllVersionsAsSortedArray():Array<any>;
getStatus(sdcMenu:IAppMenu):string;
}
@@ -161,7 +127,6 @@ export abstract class Component implements IComponent {
public interfaces:any;
public normalizedName:string;
public systemName:string;
- public projectCode:string;
public policies:Array<PolicyInstance>;
public groupInstances:Array<GroupInstance>
public modules:Array<Module>;
@@ -176,6 +141,7 @@ export abstract class Component implements IComponent {
public showMenu:boolean;
public archived:boolean;
public vspArchived: boolean;
+ public componentMetadata: ComponentMetadata;
constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) {
if (component) {
@@ -220,7 +186,6 @@ export abstract class Component implements IComponent {
this.interfaces = component.interfaces;
this.normalizedName = component.normalizedName;
this.systemName = component.systemName;
- this.projectCode = component.projectCode;
this.inputs = component.inputs;
this.componentInstances = CommonUtils.initComponentInstances(component.componentInstances);
this.properties = CommonUtils.initProperties(component.properties, this.uniqueId);
@@ -243,11 +208,6 @@ export abstract class Component implements IComponent {
this.uniqueId = uniqueId;
};
- public setSelectedInstance = (componentInstance:ComponentInstance):void => {
- this.selectedInstance = componentInstance;
- };
-
-
//------------------------------------------ API Calls ----------------------------------------------------------------//
public changeLifecycleState = (state:string, commentObj:AsdcComment):ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
@@ -302,23 +262,6 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public updateMultipleArtifacts = (artifacts:Array<ArtifactModel>):ng.IPromise<any>=> {
- let deferred = this.$q.defer();
- let onSuccess = (response:any):void => {
- deferred.resolve(response);
- };
- let onError = (error:any):void => {
- deferred.reject(error);
- };
- let q = new QueueUtils(this.$q);
-
- _.forEach(artifacts, (artifact)=> {
- q.addBlockingUIAction(()=> this.addOrUpdateArtifact(artifact).then(onSuccess, onError));
- });
- return deferred.promise;
- };
-
-
public deleteArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
let onSuccess = (artifactObj:ArtifactModel):void => {
@@ -336,32 +279,6 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public getArtifactByGroupType = (artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => {
-
- let deferred = this.$q.defer<ArtifactGroupModel>();
- let onSuccess = (response:ArtifactGroupModel):void => {
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getArtifactByGroupType(this.uniqueId, artifactGroupType).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- public getComponentInstanceArtifactsByGroupType = (componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => {
-
- let deferred = this.$q.defer<ArtifactGroupModel>();
- let onSuccess = (response:ArtifactGroupModel):void => {
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getComponentInstanceArtifactsByGroupType(this.uniqueId, componentInstanceId, artifactGroupType).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
public addOrUpdateProperty = (property:PropertyModel):ng.IPromise<PropertyModel> => {
let deferred = this.$q.defer<PropertyModel>();
@@ -446,348 +363,10 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
-
- public updateInstancePropertiesSuccess = (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;
- });
- }
-
- public updateInstanceProperties = (componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]> => {
- let deferred = this.$q.defer<PropertyModel[]>();
- let onSuccess = (newProperties:PropertyModel[]):void => {
- this.updateInstancePropertiesSuccess(newProperties);
- deferred.resolve(newProperties);
- };
- let onFailed = (error:any):void => {
- console.log('Failed to update property value');
- deferred.reject(error);
- };
- this.componentService.updateInstanceProperties(this.uniqueId, componentInstanceId, properties).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- public updateInstanceAttribute = (attribute:AttributeModel):ng.IPromise<AttributeModel> => {
- let deferred = this.$q.defer<AttributeModel>();
- let onSuccess = (newAttribute:AttributeModel):void => {
- let existAttribute:AttributeModel = <AttributeModel>_.find(this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId], {uniqueId: newAttribute.uniqueId});
- let index = this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId].indexOf(existAttribute);
- this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId][index] = newAttribute;
- deferred.resolve(newAttribute);
- };
- let onFailed = (error:any):void => {
- console.log('Failed to update attribute value');
- deferred.reject(error);
- };
- this.componentService.updateInstanceAttribute(this.uniqueId, attribute).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
public downloadInstanceArtifact = (artifactId:string):ng.IPromise<IFileDownload> => {
return this.componentService.downloadInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifactId);
};
- public deleteInstanceArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => {
- let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
- let newArtifact = new ArtifactModel(artifactObj);
- let artifacts = this.selectedInstance.deploymentArtifacts;
- if (newArtifact.mandatory || newArtifact.serviceApi) {//?????????
- artifacts[newArtifact.artifactLabel] = newArtifact;
- }
- else {
- delete artifacts[artifactLabel];
- }
- deferred.resolve(newArtifact);
- };
- this.componentService.deleteInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifactId, artifactLabel).then(onSuccess);
- return deferred.promise;
- };
-
- public addOrUpdateInstanceArtifact = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
- let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
- switch (artifactObj.artifactGroupType) {
- case ArtifactGroupType.DEPLOYMENT:
- this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj;
- break;
- case ArtifactGroupType.INFORMATION:
- this.selectedInstance.artifacts[artifactObj.artifactLabel] = artifactObj;
- break;
- }
- deferred.resolve(artifactObj);
- };
- let onError = (error:any):void => {
- deferred.reject(error);
- };
- if (artifact.uniqueId) {
- this.componentService.updateInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError);
- } else {
- this.componentService.addInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError);
- }
- return deferred.promise;
- };
-
- public uploadInstanceEnvFile = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
- let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
- this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj;
- deferred.resolve(artifactObj);
- };
- let onError = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.uploadInstanceEnvFile(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError);
- return deferred.promise;
- };
-
- //this function will update the instance version than the function call getComponent to update the current component and return the new instance version
- public changeComponentInstanceVersion = (componentUid:string):ng.IPromise<Component> => {
- let deferred = this.$q.defer<Component>();
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- let onSuccess = (componentInstance:ComponentInstance):void => {
- let onSuccess = (component:Component):void => {
- component.setSelectedInstance(componentInstance);
- deferred.resolve(component);
- };
- this.getComponent().then(onSuccess, onFailed);
- };
- this.componentService.changeResourceInstanceVersion(this.uniqueId, this.selectedInstance.uniqueId, componentUid).then(onSuccess, onFailed);
- 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<ComponentInstance>();
- let onSuccess = (instance:ComponentInstance):void => {
- this.componentInstances.push(instance);
- deferred.resolve(instance);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.createComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- public updateComponentInstance = (componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => {
- let deferred = this.$q.defer<ComponentInstance>();
- let onSuccess = (updatedInstance:ComponentInstance):void => {
- let componentInstance:ComponentInstance = _.find(this.componentInstances, (instance:ComponentInstance) => {
- return instance.uniqueId === updatedInstance.uniqueId;
- });
-
- let index = this.componentInstances.indexOf(componentInstance);
- this.componentInstances[index] = componentInstance;
- deferred.resolve(updatedInstance);
-
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.updateComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- public updateMultipleComponentInstances = (instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>> => {
- let deferred = this.$q.defer<Array<ComponentInstance>>();
- let onSuccess = (updatedInstances:Array<ComponentInstance>):void => {
- _.forEach(updatedInstances, (updatedComponentInstance) => {
- let componentInstance:ComponentInstance = _.find(this.componentInstances, (instance:ComponentInstance) => {
- return instance.uniqueId === updatedComponentInstance.uniqueId;
- });
-
- let index = this.componentInstances.indexOf(componentInstance);
- this.componentInstances[index] = componentInstance;
-
- });
- deferred.resolve(updatedInstances);
-
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.updateMultipleComponentInstances(this.uniqueId, instances).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- public deleteComponentInstance = (componentInstanceId:string):ng.IPromise<ComponentInstance> => {
- let deferred = this.$q.defer<ComponentInstance>();
- let onSuccess = ():void => {
- let onSuccess = (component:Component):void => {
- this.componentInstances = CommonUtils.initComponentInstances(component.componentInstances);
- this.componentInstancesProperties = new PropertiesGroup(component.componentInstancesProperties);
- this.componentInstancesAttributes = new AttributesGroup(component.componentInstancesAttributes);
- this.modules = component.modules;
- this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(component.componentInstancesRelations);
- deferred.resolve();
- };
- this.getComponent().then(onSuccess);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.deleteComponentInstance(this.uniqueId, componentInstanceId).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
-
- 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<RelationshipModel>();
- let onSuccess = (relation:RelationshipModel):void => {
- console.info('Link created successfully', relation);
- if (!this.componentInstancesRelations) {
- this.componentInstancesRelations = [];
- }
- this.componentInstancesRelations.push(new RelationshipModel(relation));
- this.syncComponentByRelation(relation);
- deferred.resolve(relation);
- };
- let onFailed = (error:any):void => {
- console.info('Failed to create relation', error);
- deferred.reject(error);
- };
- this.componentService.createRelation(this.uniqueId, relation).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- public deleteRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => {
- let deferred = this.$q.defer<RelationshipModel>();
- 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].relation, relationship.relation);
- });
- });
- let index = this.componentInstancesRelations.indexOf(relationToDelete);
- if (relationToDelete != undefined && index > -1) {
- if (relationToDelete.relationships.length == 1) {
- this.componentInstancesRelations.splice(index, 1);
- } else {
- this.componentInstancesRelations[index].relationships =
- _.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 => {
- console.error("Failed To Delete Link");
- deferred.reject(error);
- };
- this.componentService.deleteRelation(this.uniqueId, relation).then(onSuccess, onFailed);
- 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 => {
- this.capabilities = new CapabilitiesGroup(response.capabilities);
- this.requirements = new RequirementsGroup(response.requirements);
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getRequirementsCapabilities(this.uniqueId).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
public getModuleForDisplay = (moduleId:string):ng.IPromise<DisplayModule> => {
let deferred = this.$q.defer<DisplayModule>();
@@ -814,82 +393,6 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
-
- // this function get all instances filtered by inputs and properties (optional) - if no search string insert - this function will
- // get all the instances of the component (in service only VF instances)
- public getComponentInstancesFilteredByInputsAndProperties = (searchText?:string):ng.IPromise<Array<ComponentInstance>> => {
-
- let deferred = this.$q.defer<Array<ComponentInstance>>();
- let onSuccess = (response:Array<ComponentInstance>):void => {
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getComponentInstancesFilteredByInputsAndProperties(this.uniqueId, searchText).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
-
- // get inputs for instance - Pagination function
- public getComponentInputs = ():ng.IPromise<Array<InputModel>> => {
-
- let deferred = this.$q.defer<Array<InputModel>>();
- let onSuccess = (inputsRes:Array<InputModel>):void => {
- this.inputs = inputsRes;
- deferred.resolve(inputsRes);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getComponentInputs(this.uniqueId).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
-
- // get inputs instance - Pagination function
- public getComponentInstanceInputs = (componentInstanceId:string, originComponentUid:string):ng.IPromise<Array<InputModel>> => {
-
- let deferred = this.$q.defer<Array<InputModel>>();
- let onSuccess = (response:Array<InputModel>):void => {
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getComponentInstanceInputs(this.uniqueId, componentInstanceId, originComponentUid).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- // get inputs inatnce - Pagination function
- public getComponentInstanceInputProperties = (componentInstanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>> => {
-
- let deferred = this.$q.defer<Array<PropertyModel>>();
- let onSuccess = (response:Array<PropertyModel>):void => {
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getComponentInstanceInputProperties(this.uniqueId, componentInstanceId, inputId).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
- // get inputs inatnce - Pagination function
- public getComponentInstanceProperties = (componentInstanceId:string):ng.IPromise<Array<PropertyModel>> => {
-
- let deferred = this.$q.defer<Array<PropertyModel>>();
- let onSuccess = (response:Array<PropertyModel>):void => {
- deferred.resolve(response);
- };
- let onFailed = (error:any):void => {
- deferred.reject(error);
- };
- this.componentService.getComponentInstanceProperties(this.uniqueId, componentInstanceId).then(onSuccess, onFailed);
- return deferred.promise;
- };
-
-
public updateGroupMetadata = (module:Module):ng.IPromise<Module> => {
let deferred = this.$q.defer<Module>();
@@ -969,15 +472,6 @@ export abstract class Component implements IComponent {
};
- public getAdditionalInformation = ():Array<AdditionalInformationModel> => {
- let additionalInformationObject:any = _.find(this.additionalInformation, (obj:any):boolean => {
- return obj.parentUniqueId == this.uniqueId;
- });
- if (additionalInformationObject) {
- return additionalInformationObject.parameters;
- }
- return [];
- };
public handleTags = ():void => {
let isContainTag = _.find(this.tags, (tag)=> {
@@ -1036,10 +530,10 @@ export abstract class Component implements IComponent {
this.derivedList = componentMetadata.derivedList;
this.normalizedName = componentMetadata.normalizedName;
this.systemName = componentMetadata.systemName;
- this.projectCode = componentMetadata.projectCode;
this.categories = componentMetadata.categories;
this.archived = componentMetadata.archived || false;
this.vspArchived = componentMetadata.vspArchived;
+ this.componentMetadata = componentMetadata;
}
public toJSON = ():any => {
diff --git a/catalog-ui/src/app/models/components/displayComponent.ts b/catalog-ui/src/app/models/components/displayComponent.ts
index f96e0bf14b..4e946954f3 100644
--- a/catalog-ui/src/app/models/components/displayComponent.ts
+++ b/catalog-ui/src/app/models/components/displayComponent.ts
@@ -22,47 +22,42 @@
*/
'use strict';
-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";
+import { ComponentType, SdcElementType } 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 enum LeftPaletteMetadataTypes {
- Component,
- Group,
- Policy
+ Component = 'COMPONENT',
+ Group = 'GROUP',
+ Policy = 'POLICY'
}
export class LeftPaletteComponent {
- uniqueId:string;
- type:string;
- displayName:string;
- version:string;
- mainCategory:string;
- subCategory:string;
- iconClass:string;
- componentSubType:string;
- searchFilterTerms:string;
- certifiedIconClass:string;
- icon:string;
- isDraggable:boolean;
- isRequirmentAndCapabilitiesLoaded:boolean;
- uuid:string;
- name:string;
- lifecycleState:string;
- allVersions:any;
- componentType:string;
- systemName:string;
-
- invariantUUID:string;
-
- capabilities:CapabilitiesGroup;
- requirements:RequirementsGroup;
-
- categoryType:LeftPaletteMetadataTypes;
+ uniqueId: string;
+ type: string;
+ version: string;
+ mainCategory: string;
+ subCategory: string;
+ componentSubType: string;
+ searchFilterTerms: string;
+ certifiedIconClass: string;
+ isDraggable: boolean;
+ uuid: string;
+ name: string;
+ lifecycleState: string;
+ allVersions: any;
+ componentType: string;
+ systemName: string;
+ invariantUUID: string;
+ capabilities: CapabilitiesGroup;
+ requirements: RequirementsGroup;
+ categoryType: LeftPaletteMetadataTypes;
+ resourceType: string;
+ icon: string;
constructor(metadataType: LeftPaletteMetadataTypes, item: ComponentMetadata | PolicyMetadata | GroupMetadata) {
if (metadataType === LeftPaletteMetadataTypes.Policy) {
@@ -81,13 +76,10 @@ export class LeftPaletteComponent {
}
}
- private initComponent(component:ComponentMetadata): void {
- this.categoryType = LeftPaletteMetadataTypes.Component;
+ private initComponent(component: ComponentMetadata): void {
- this.icon = component.icon;
this.version = component.version;
this.uniqueId = component.uniqueId;
- this.isRequirmentAndCapabilitiesLoaded = false;
this.uuid = component.uuid;
this.name = component.name;
this.allVersions = component.allVersions;
@@ -95,7 +87,6 @@ export class LeftPaletteComponent {
this.systemName = component.systemName;
this.invariantUUID = component.invariantUUID;
this.isDraggable = true;
-
if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) {
this.mainCategory = component.categories[0].name;
this.subCategory = component.categories[0].subcategories[0].name;
@@ -103,75 +94,43 @@ export class LeftPaletteComponent {
this.mainCategory = 'Generic';
this.subCategory = 'Generic';
}
+ // this.categoryType = LeftPaletteMetadataTypes.Component;
+ // this.componentSubType = component. ? component.resourceType: ComponentType.SERVICE_PROXY;
+ this.searchFilterTerms = (this.name + ' ' + component.description + ' ' + component.tags.join(' ')).toLowerCase() + ' ' + component.version;
+ this.icon = component.icon;
+ this.certifiedIconClass = component.lifecycleState != 'CERTIFIED' ? 'non-certified' : ''; // need to fix after onap fix
- 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);
- this.certifiedIconClass = component.lifecycleState != 'CERTIFIED' ? 'non-certified' : '';
- if (component.icon === 'vl' || component.icon === 'cp') {
- this.certifiedIconClass = this.certifiedIconClass + " " + 'smaller-icon';
- }
}
- private initGroup(group:GroupMetadata): void {
+ private initGroup(group: GroupMetadata): void {
this.categoryType = LeftPaletteMetadataTypes.Group;
-
this.uniqueId = group.uniqueId;
- this.displayName = group.name;
- this.mainCategory = "Groups";
- this.subCategory = "Groups";
- this.iconClass = "sprite-group-icons group";
+ this.name = group.name;
+ this.mainCategory = 'Groups';
+ this.subCategory = 'Groups';
this.version = group.version;
-
this.type = group.type;
- this.componentSubType = 'GROUP';
-
+ this.componentSubType = SdcElementType.GROUP;
+ this.icon = SdcElementType.GROUP;
this.searchFilterTerms = this.type + ' ' + group.name + ' ' + group.version;
this.isDraggable = false;
}
- private initPolicy(policy:PolicyMetadata): void {
+ private initPolicy(policy: PolicyMetadata): void {
this.categoryType = LeftPaletteMetadataTypes.Policy;
-
this.uniqueId = policy.uniqueId;
- this.displayName = policy.name;
- this.mainCategory = "Policies";
- this.subCategory = "Policies";
- this.iconClass = "sprite-policy-icons policy";
+ this.name = policy.name;
+ this.mainCategory = 'Policies';
+ this.subCategory = 'Policies';
this.version = policy.version;
-
this.type = policy.type;
- this.componentSubType = 'POLICY';
-
+ this.componentSubType = SdcElementType.POLICY;
+ this.icon = SdcElementType.POLICY;
this.searchFilterTerms = this.type + ' ' + policy.name + ' ' + policy.version;
this.isDraggable = false;
}
- public initDisplayName = (name:string):void => {
- let newName =
- _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.'))
- .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.'))
- .split('nodes.module.')).split('cp.')).split('vl.'));
- if (newName) {
- this.displayName = newName;
- } else {
- this.displayName = name;
- }
- };
-
- public initIconSprite = (icon:string):void => {
- switch (this.componentSubType) {
- case ComponentType.SERVICE:
- this.iconClass = "sprite-services-icons " + icon;
- break;
- default:
- this.iconClass = "sprite-resource-icons " + icon;
- }
- }
-
- public getComponentSubType = ():string => {
+ public getComponentSubType = (): string => {
return this.componentSubType;
};
}
diff --git a/catalog-ui/src/app/models/components/service.ts b/catalog-ui/src/app/models/components/service.ts
index a947e81716..911a43204f 100644
--- a/catalog-ui/src/app/models/components/service.ts
+++ b/catalog-ui/src/app/models/components/service.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.
@@ -38,6 +38,7 @@ export class Service extends Component {
public namingPolicy:string;
public serviceType:string;
public serviceRole:string;
+ public serviceFunction:string;
public environmentContext:string;
public instantiationType:string;
public forwardingPaths:{ [key:string]:ForwardingPath } = {};
@@ -52,6 +53,7 @@ export class Service extends Component {
this.namingPolicy = component.namingPolicy;
this.serviceType = component.serviceType;
this.serviceRole = component.serviceRole;
+ this.serviceFunction = component.serviceFunction;
this.instantiationType = component.instantiationType;
this.environmentContext = component.environmentContext;
if (component.categories && component.categories[0]) {
@@ -168,6 +170,7 @@ export class Service extends Component {
this.namingPolicy = componentMetadata.namingPolicy;
this.serviceType = componentMetadata.serviceType;
this.serviceRole = componentMetadata.serviceRole;
+ this.serviceFunction = componentMetadata.serviceFunction;
this.environmentContext = componentMetadata.environmentContext;
this.instantiationType = componentMetadata.instantiationType;
this.setComponentDisplayData();
@@ -195,6 +198,7 @@ export class Service extends Component {
temp.selectedCategory = undefined;
temp.modules = undefined;
temp.groupInstances = undefined;
+ temp.policies = undefined;
return temp;
};
}