Select a Model when Importing a VSP
[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 import { Metadata } from "app/models/metadata";
25 /**
26  * Created by obarda on 4/18/2017.
27  */
28 export interface IComponentMetadata {
29
30     abstract: string;
31     uniqueId: string;
32     uuid: string;
33     invariantUUID: string;
34     name: string;
35     version: string;
36     creationDate: number;
37     lastUpdateDate: number;
38     description: string;
39     lifecycleState: string;
40     tags: string[];
41     icon: string;
42     contactId: string;
43     allVersions: any;
44     creatorUserId: string;
45     creatorFullName: string;
46     lastUpdaterUserId: string;
47     lastUpdaterFullName: string;
48     componentType: string;
49     categories: IMainCategory[];
50     highestVersion: boolean;
51     normalizedName: string;
52     systemName: string;
53     archived: boolean;
54     vspArchived: boolean;
55     selectedCategory: string;
56     filterTerm: string;
57     categorySpecificMetadata: Metadata;
58
59     // Resource only
60     resourceType: string;
61     csarUUID: string;
62     csarVersion: string;
63     derivedList: string[];
64     vendorName: string;
65     vendorRelease: string;
66     derivedFrom: string[];
67     resourceVendorModelNumber: string;
68     csarPackageType: string;
69     packageId: string;
70     iconSprite: string;
71
72     // Service only
73     serviceFunction: string;
74     distributionStatus: string;
75     ecompGeneratedNaming: boolean;
76     namingPolicy: string;
77     serviceType: string;
78     serviceRole: string;
79     environmentContext: string;
80     instantiationType: string;
81
82     // backend lifecycleState
83     state: string;
84
85     capabilities: CapabilitiesGroup;
86     requirements: RequirementsGroup;
87
88     // Model
89     model: string;
90
91 }
92
93 export class ComponentMetadata implements IComponentMetadata {
94
95     public abstract: string;
96     public uniqueId: string;
97     public uuid: string;
98     public invariantUUID: string;
99     public name: string;
100     public version: string;
101     public creationDate: number;
102     public lastUpdateDate: number;
103     public description: string;
104     public lifecycleState: string;
105     public tags: string[];
106     public icon: string;
107     public contactId: string;
108     public allVersions: any;
109     public creatorUserId: string;
110     public creatorFullName: string;
111     public lastUpdaterUserId: string;
112     public lastUpdaterFullName: string;
113     public componentType: string;
114     public categories: IMainCategory[];
115     public highestVersion: boolean;
116     public normalizedName: string;
117     public systemName: string;
118     public archived: boolean;
119     public vspArchived: boolean;
120     public toscaResourceName: string;
121     public selectedCategory: string;
122     public filterTerm: string;
123     public categorySpecificMetadata: Metadata = new Metadata();
124
125     // Resource only
126     public resourceType: string;
127     public csarUUID: string;
128     public csarVersion: string;
129     public csarVersionId: string;
130     public derivedList: string[];
131     public vendorName: string;
132     public vendorRelease: string;
133     public derivedFrom: string[];
134     public resourceVendorModelNumber: string;
135     public csarPackageType: string;
136     public packageId: string;
137     public iconSprite: string;
138     public models: string[];
139
140     // Service only
141     public serviceFunction: string;
142     public distributionStatus: string;
143     public ecompGeneratedNaming: boolean;
144     public namingPolicy: string;
145     public serviceType: string;
146     public serviceRole: string;
147     public environmentContext: string;
148     public instantiationType: string;
149     public model: string;
150
151     // backend lifecycleState
152     public state: string;
153
154     // requirements
155     public capabilities;
156     public requirements;
157
158     deserialize(response): ComponentMetadata {
159         this.abstract = response.abstract;
160         this.uniqueId = response.uniqueId;
161         this.uuid = response.uuid;
162         this.invariantUUID = response.invariantUUID;
163         this.contactId = response.contactId;
164         this.categories = response.categories;
165         this.creatorUserId = response.creatorUserId;
166         this.creationDate = response.creationDate;
167         this.creatorFullName = response.creatorFullName;
168         this.description = response.description;
169         this.icon = response.icon;
170         this.lastUpdateDate = response.lastUpdateDate;
171         this.lastUpdaterUserId = response.lastUpdaterUserId;
172         this.lastUpdaterFullName = response.lastUpdaterFullName;
173         this.lifecycleState = response.lifecycleState;
174         this.name = response.name;
175         this.version = response.version;
176         this.tags = angular.copy(response.tags, this.tags);
177         this.allVersions = response.allVersions;
178         this.componentType = response.componentType;
179         this.distributionStatus = response.distributionStatus;
180         this.highestVersion = response.highestVersion;
181         this.vendorName = response.vendorName;
182         this.vendorRelease = response.vendorRelease;
183         this.derivedList = response.derivedList;
184         this.normalizedName = response.normalizedName;
185         this.systemName = response.systemName;
186         this.serviceFunction = response.serviceFunction;
187         this.resourceType = response.resourceType;
188         this.csarUUID = response.csarUUID;
189         this.csarVersion = response.csarVersion;
190         this.state = response.state;
191         this.ecompGeneratedNaming = response.ecompGeneratedNaming;
192         this.namingPolicy = response.namingPolicy;
193         this.derivedFrom = response.derivedFrom;
194         this.resourceVendorModelNumber = response.resourceVendorModelNumber;
195         this.serviceType = response.serviceType;
196         this.serviceRole = response.serviceRole;
197         this.environmentContext = response.environmentContext;
198         this.archived = response.archived;
199         this.instantiationType = response.instantiationType;
200         this.vspArchived = response.vspArchived;
201         this.toscaResourceName = response.toscaResourceName;
202         this.capabilities = response.capabilities;
203         this.requirements = response.requirements;
204         this.categorySpecificMetadata = response.categorySpecificMetadata;
205         this.model = response.model;
206         return this;
207     }
208
209     public isService = (): boolean => {
210         return this.componentType === ComponentType.SERVICE;
211     }
212
213     public getTypeUrl(): string {
214         return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';
215     }
216 }