1 import { ComponentInstance, Component, ArtifactGroupModel, Service, Resource, IMainCategory, ArtifactModel, AttributeModel } from "app/models";
2 import { ComponentType } from '../../utils/constants';
3 import * as _ from 'lodash';
6 export class FullComponentInstance extends ComponentInstance {
7 public contactId: string;
8 public componentType: string;
10 public tags:Array<string>;
11 public version:string;
12 public allVersions:any;
13 public highestVersion:boolean;
14 public categories:Array<IMainCategory>;
15 public creationDate:number;
16 public creatorFullName:string;
17 public vendorName:string;
18 public vendorRelease:string;
19 public systemName:string;
21 public lifecycleState: string;
22 public archived: boolean;
24 public isServiceInstance: boolean;
25 public isResourceInstance: boolean;
26 public directives: string[];
29 public serviceApiArtifacts:ArtifactGroupModel;
30 public serviceType:string;
31 public serviceRole:string;
34 public csarUUID:string;
35 public isCsarComponent: boolean;
36 public csarVersion:string;
37 public csarPackageType:string;
38 public packageId:string;
39 public resourceType:string;
40 public resourceVendorModelNumber:string;
42 public attributes: Array<AttributeModel>;
44 constructor(componentInstance:ComponentInstance, originComponent:Component) {
45 super(componentInstance);
47 this.componentType = originComponent.componentType;
48 this.interfaces = originComponent.interfaces;
50 this.tags = _.clone(originComponent.tags);
51 this.version = originComponent.version;
52 this.allVersions = originComponent.allVersions;
53 this.highestVersion = originComponent.highestVersion;
54 this.categories = originComponent.categories;
55 this.creationDate = originComponent.creationDate;
56 this.creatorFullName = originComponent.creatorFullName;
57 this.vendorName = originComponent.vendorName;
58 this.vendorRelease = originComponent.vendorRelease;
59 this.contactId = originComponent.contactId;
60 this.description = originComponent.description;
61 this.systemName = originComponent.systemName;
62 this.uuid = originComponent.uuid;
63 this.lifecycleState = originComponent.lifecycleState;
64 this.archived = originComponent.archived;
65 this.attributes = originComponent.attributes;
66 this.directives = componentInstance.directives;
69 if(originComponent.componentType === ComponentType.SERVICE || originComponent.componentType === ComponentType.SERVICE_PROXY || ComponentType.SERVICE_SUBSTITUTION){
70 this.isServiceInstance = true;
71 this.serviceApiArtifacts = (<Service>originComponent).serviceApiArtifacts;
72 this.serviceType = (<Service>originComponent).serviceType;
73 this.serviceRole = (<Service>originComponent).serviceRole;
75 if(originComponent.componentType === ComponentType.RESOURCE) {
76 this.isResourceInstance = true;
77 this.csarUUID = (<Resource>originComponent).csarUUID;
78 this.isCsarComponent = !!this.csarUUID;
79 this.resourceType = (<Resource>originComponent).resourceType;
80 this.resourceVendorModelNumber = (<Resource>originComponent).resourceVendorModelNumber;
84 public isResource = ():boolean => {
85 return this.isResourceInstance;
88 public isService = ():boolean => {
89 return this.isServiceInstance;