Catalog alignment
[sdc.git] / catalog-ui / src / app / models / component-metadata.ts
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import { CapabilitiesGroup, RequirementsGroup } from 'app/models';
22 import { ComponentType } from 'app/utils';
23 import { IMainCategory } from './category';
24 /**
25  * Created by obarda on 4/18/2017.
26  */
27 export interface IComponentMetadata {
28
29     abstract: string;
30     uniqueId: string;
31     uuid: string;
32     invariantUUID: string;
33     name: string;
34     version: string;
35     creationDate: number;
36     lastUpdateDate: number;
37     description: string;
38     lifecycleState: string;
39     tags: string[];
40     icon: string;
41     contactId: string;
42     allVersions: any;
43     creatorUserId: string;
44     creatorFullName: string;
45     lastUpdaterUserId: string;
46     lastUpdaterFullName: string;
47     componentType: string;
48     categories: IMainCategory[];
49     highestVersion: boolean;
50     normalizedName: string;
51     systemName: string;
52     archived: boolean;
53     vspArchived: boolean;
54     selectedCategory: string;
55     filterTerm: string;
56
57     // Resource only
58     resourceType: string;
59     csarUUID: string;
60     csarVersion: string;
61     derivedList: string[];
62     vendorName: string;
63     vendorRelease: string;
64     derivedFrom: string[];
65     resourceVendorModelNumber: string;
66     csarPackageType: string;
67     packageId: string;
68     iconSprite: string;
69
70     // Service only
71     serviceFunction: string;
72     distributionStatus: string;
73     ecompGeneratedNaming: boolean;
74     namingPolicy: string;
75     serviceType: string;
76     serviceRole: string;
77     environmentContext: string;
78     instantiationType: string;
79
80     // backend lifecycleState
81     state: string;
82
83     capabilities: CapabilitiesGroup;
84     requirements: RequirementsGroup;
85
86 }
87
88 export class ComponentMetadata implements IComponentMetadata {
89
90     public abstract: string;
91     public uniqueId: string;
92     public uuid: string;
93     public invariantUUID: string;
94     public name: string;
95     public version: string;
96     public creationDate: number;
97     public lastUpdateDate: number;
98     public description: string;
99     public lifecycleState: string;
100     public tags: string[];
101     public icon: string;
102     public contactId: string;
103     public allVersions: any;
104     public creatorUserId: string;
105     public creatorFullName: string;
106     public lastUpdaterUserId: string;
107     public lastUpdaterFullName: string;
108     public componentType: string;
109     public categories: IMainCategory[];
110     public highestVersion: boolean;
111     public normalizedName: string;
112     public systemName: string;
113     public archived: boolean;
114     public vspArchived: boolean;
115     public toscaResourceName: string;
116     public selectedCategory: string;
117     public filterTerm: string;
118
119     // Resource only
120     public resourceType: string;
121     public csarUUID: string;
122     public csarVersion: string;
123     public derivedList: string[];
124     public vendorName: string;
125     public vendorRelease: string;
126     public derivedFrom: string[];
127     public resourceVendorModelNumber: string;
128     public csarPackageType: string;
129     public packageId: string;
130     public iconSprite: string;
131
132     // Service only
133     public serviceFunction: string;
134     public distributionStatus: string;
135     public ecompGeneratedNaming: boolean;
136     public namingPolicy: string;
137     public serviceType: string;
138     public serviceRole: string;
139     public environmentContext: string;
140     public instantiationType: string;
141
142     // backend lifecycleState
143     public state: string;
144
145     // requirements
146     public capabilities;
147     public requirements;
148
149     deserialize(response): ComponentMetadata {
150         this.abstract = response.abstract;
151         this.uniqueId = response.uniqueId;
152         this.uuid = response.uuid;
153         this.invariantUUID = response.invariantUUID;
154         this.contactId = response.contactId;
155         this.categories = response.categories;
156         this.creatorUserId = response.creatorUserId;
157         this.creationDate = response.creationDate;
158         this.creatorFullName = response.creatorFullName;
159         this.description = response.description;
160         this.icon = response.icon;
161         this.lastUpdateDate = response.lastUpdateDate;
162         this.lastUpdaterUserId = response.lastUpdaterUserId;
163         this.lastUpdaterFullName = response.lastUpdaterFullName;
164         this.lifecycleState = response.lifecycleState;
165         this.name = response.name;
166         this.version = response.version;
167         this.tags = angular.copy(response.tags, this.tags);
168         this.allVersions = response.allVersions;
169         this.componentType = response.componentType;
170         this.distributionStatus = response.distributionStatus;
171         this.highestVersion = response.highestVersion;
172         this.vendorName = response.vendorName;
173         this.vendorRelease = response.vendorRelease;
174         this.derivedList = response.derivedList;
175         this.normalizedName = response.normalizedName;
176         this.systemName = response.systemName;
177         this.serviceFunction = response.serviceFunction;
178         this.resourceType = response.resourceType;
179         this.csarUUID = response.csarUUID;
180         this.csarVersion = response.csarVersion;
181         this.state = response.state;
182         this.ecompGeneratedNaming = response.ecompGeneratedNaming;
183         this.namingPolicy = response.namingPolicy;
184         this.derivedFrom = response.derivedFrom;
185         this.resourceVendorModelNumber = response.resourceVendorModelNumber;
186         this.serviceType = response.serviceType;
187         this.serviceRole = response.serviceRole;
188         this.environmentContext = response.environmentContext;
189         this.archived = response.archived;
190         this.instantiationType = response.instantiationType;
191         this.vspArchived = response.vspArchived;
192         this.toscaResourceName = response.toscaResourceName;
193         this.capabilities = response.capabilities;
194         this.requirements = response.requirements;
195         return this;
196     }
197
198     public isService = (): boolean => {
199         return this.componentType === ComponentType.SERVICE;
200     }
201
202     public getTypeUrl(): string {
203         return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';
204     }
205 }