2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
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";
26 * Created by obarda on 4/18/2017.
28 export interface IComponentMetadata {
33 invariantUUID: string;
37 lastUpdateDate: number;
39 lifecycleState: string;
44 creatorUserId: string;
45 creatorFullName: string;
46 lastUpdaterUserId: string;
47 lastUpdaterFullName: string;
48 componentType: string;
49 categories: IMainCategory[];
50 highestVersion: boolean;
51 normalizedName: string;
55 selectedCategory: string;
57 categorySpecificMetadata: Metadata;
63 derivedList: string[];
65 vendorRelease: string;
66 derivedFrom: string[];
67 resourceVendorModelNumber: string;
68 csarPackageType: string;
73 serviceFunction: string;
74 distributionStatus: string;
75 ecompGeneratedNaming: boolean;
79 environmentContext: string;
80 instantiationType: string;
82 // backend lifecycleState
85 capabilities: CapabilitiesGroup;
86 requirements: RequirementsGroup;
93 export class ComponentMetadata implements IComponentMetadata {
95 public abstract: string;
96 public uniqueId: string;
98 public invariantUUID: 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[];
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();
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[];
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;
151 // backend lifecycleState
152 public state: string;
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;
209 public isService = (): boolean => {
210 return this.componentType === ComponentType.SERVICE;
213 public getTypeUrl(): string {
214 return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';