Support for Nested/Hierarchical Services
[sdc.git] / catalog-ui / src / app / models / componentsInstances / fullComponentInstance.ts
1 import { ComponentInstance, Component, ArtifactGroupModel, Service, Resource, IMainCategory, ArtifactModel, AttributeModel } from "app/models";
2 import { ComponentType } from '../../utils/constants';
3 import * as _ from 'lodash';
4
5
6 export class FullComponentInstance extends ComponentInstance {
7     public contactId: string;
8     public componentType: string;
9     public interfaces:any;
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;
20     public uuid:string;
21     public lifecycleState: string;
22     public archived: boolean;
23
24     public isServiceInstance: boolean;
25     public isResourceInstance: boolean;
26     public directives: string[];
27
28     //service
29     public serviceApiArtifacts:ArtifactGroupModel;
30     public serviceType:string;
31     public serviceRole:string;
32
33     //resource
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;
41
42     public attributes: Array<AttributeModel>;
43
44     constructor(componentInstance:ComponentInstance, originComponent:Component) {
45         super(componentInstance);
46
47         this.componentType = originComponent.componentType;
48         this.interfaces = originComponent.interfaces;
49         this.tags = [];
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;
67
68
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;
74         }
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;
81         }
82     }
83
84     public isResource = ():boolean => {
85         return this.isResourceInstance;
86     }
87
88     public isService = ():boolean => {
89         return this.isServiceInstance;
90     }
91
92 }