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 {ComponentState, ComponentType, ResourceType} 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 csarVersionId: string;
64 derivedList: string[];
66 vendorRelease: string;
67 derivedFrom: string[];
68 resourceVendorModelNumber: string;
69 csarPackageType: string;
74 serviceFunction: string;
75 distributionStatus: string;
76 ecompGeneratedNaming: boolean;
80 environmentContext: string;
81 instantiationType: string;
83 // backend lifecycleState
86 capabilities: CapabilitiesGroup;
87 requirements: RequirementsGroup;
94 export class ComponentMetadata implements IComponentMetadata {
96 public abstract: string;
97 public uniqueId: string;
99 public invariantUUID: string;
101 public version: string;
102 public creationDate: number;
103 public lastUpdateDate: number;
104 public description: string;
105 public lifecycleState: string;
106 public tags: string[];
108 public contactId: string;
109 public allVersions: any;
110 public creatorUserId: string;
111 public creatorFullName: string;
112 public lastUpdaterUserId: string;
113 public lastUpdaterFullName: string;
114 public componentType: string;
115 public categories: IMainCategory[];
116 public highestVersion: boolean;
117 public normalizedName: string;
118 public systemName: string;
119 public isArchived: boolean;
120 public vspArchived: boolean;
121 public toscaResourceName: string;
122 public selectedCategory: string;
123 public filterTerm: string;
124 public categorySpecificMetadata: Metadata = new Metadata();
127 public resourceType: string;
128 public csarUUID: string;
129 public csarVersion: string;
130 public csarVersionId: string;
131 public derivedList: string[];
132 public vendorName: string;
133 public vendorRelease: string;
134 public derivedFrom: string[];
135 public resourceVendorModelNumber: string;
136 public csarPackageType: string;
137 public packageId: string;
138 public iconSprite: string;
139 public models: string[];
142 public serviceFunction: string;
143 public distributionStatus: string;
144 public ecompGeneratedNaming: boolean;
145 public namingPolicy: string;
146 public serviceType: string;
147 public serviceRole: string;
148 public environmentContext: string;
149 public instantiationType: string;
150 public model: string;
152 // backend lifecycleState
153 public state: string;
159 deserialize(response): ComponentMetadata {
160 this.abstract = response.abstract;
161 this.uniqueId = response.uniqueId;
162 this.uuid = response.uuid;
163 this.invariantUUID = response.invariantUUID;
164 this.contactId = response.contactId;
165 this.categories = response.categories;
166 this.creatorUserId = response.creatorUserId;
167 this.creationDate = response.creationDate;
168 this.creatorFullName = response.creatorFullName;
169 this.description = response.description;
170 this.icon = response.icon;
171 this.lastUpdateDate = response.lastUpdateDate;
172 this.lastUpdaterUserId = response.lastUpdaterUserId;
173 this.lastUpdaterFullName = response.lastUpdaterFullName;
174 this.lifecycleState = response.lifecycleState;
175 this.name = response.name;
176 this.version = response.version;
177 this.tags = angular.copy(response.tags, this.tags);
178 this.allVersions = response.allVersions;
179 this.componentType = response.componentType;
180 this.distributionStatus = response.distributionStatus;
181 this.highestVersion = response.highestVersion;
182 this.vendorName = response.vendorName;
183 this.vendorRelease = response.vendorRelease;
184 this.derivedList = response.derivedList;
185 this.normalizedName = response.normalizedName;
186 this.systemName = response.systemName;
187 this.serviceFunction = response.serviceFunction;
188 this.resourceType = response.resourceType;
189 this.csarUUID = response.csarUUID;
190 this.csarVersion = response.csarVersion;
191 this.csarVersionId = response.csarVersionId;
192 this.state = response.state;
193 this.ecompGeneratedNaming = response.ecompGeneratedNaming;
194 this.namingPolicy = response.namingPolicy;
195 this.derivedFrom = response.derivedFrom;
196 this.resourceVendorModelNumber = response.resourceVendorModelNumber;
197 this.serviceType = response.serviceType;
198 this.serviceRole = response.serviceRole;
199 this.environmentContext = response.environmentContext;
200 this.isArchived = response.isArchived;
201 this.instantiationType = response.instantiationType;
202 this.vspArchived = response.vspArchived;
203 this.toscaResourceName = response.toscaResourceName;
204 this.capabilities = response.capabilities;
205 this.requirements = response.requirements;
206 this.categorySpecificMetadata = response.categorySpecificMetadata;
207 this.model = response.model;
211 public isService = (): boolean => {
212 return this.componentType === ComponentType.SERVICE;
215 public isVfc(): boolean {
216 return this.resourceType === ResourceType.VFC;
219 public getTypeUrl(): string {
220 return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';
223 public isComponentDataEditable(): boolean {
224 return this.lifecycleState !== ComponentState.NOT_CERTIFIED_CHECKOUT;