blob: 1cbecda2b37b0787ac81b09bb60281d25e6c0006 [file] [log] [blame]
Michael Landodd603392017-07-12 00:54:52 +03001/*-
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
ys969316a9fce2020-01-19 13:50:02 +020010 *
Michael Landodd603392017-07-12 00:54:52 +030011 * http://www.apache.org/licenses/LICENSE-2.0
ys969316a9fce2020-01-19 13:50:02 +020012 *
Michael Landodd603392017-07-12 00:54:52 +030013 * 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
ys969316a9fce2020-01-19 13:50:02 +020021import { CapabilitiesGroup, RequirementsGroup } from 'app/models';
22import { ComponentType } from 'app/utils';
23import { IMainCategory } from './category';
MichaelMorris69779182020-12-15 16:12:59 +000024import { Metadata } from "app/models/metadata";
Michael Landoed64b5e2017-06-09 03:19:04 +030025/**
26 * Created by obarda on 4/18/2017.
27 */
ys969316a9fce2020-01-19 13:50:02 +020028export interface IComponentMetadata {
Michael Landoed64b5e2017-06-09 03:19:04 +030029
ys969316a9fce2020-01-19 13:50:02 +020030 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;
MichaelMorris69779182020-12-15 16:12:59 +000057 categorySpecificMetadata: Metadata;
ys969316a9fce2020-01-19 13:50:02 +020058
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
aribeiro4f4f7fb2021-06-24 11:19:45 +010088 // Model
89 model: string;
90
ys969316a9fce2020-01-19 13:50:02 +020091}
92
93export 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;
Michael Lando5b593492018-07-29 16:13:45 +0300119 public vspArchived: boolean;
miriame41ee9cb2019-03-04 13:49:15 +0200120 public toscaResourceName: string;
ys969316a9fce2020-01-19 13:50:02 +0200121 public selectedCategory: string;
122 public filterTerm: string;
MichaelMorris69779182020-12-15 16:12:59 +0000123 public categorySpecificMetadata: Metadata = new Metadata();
Michael Landoed64b5e2017-06-09 03:19:04 +0300124
ys969316a9fce2020-01-19 13:50:02 +0200125 // Resource only
Michael Landoed64b5e2017-06-09 03:19:04 +0300126 public resourceType: string;
ys969316a9fce2020-01-19 13:50:02 +0200127 public csarUUID: string;
128 public csarVersion: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300129 public derivedList: string[];
ys969316a9fce2020-01-19 13:50:02 +0200130 public vendorName: string;
131 public vendorRelease: string;
132 public derivedFrom: string[];
133 public resourceVendorModelNumber: string;
134 public csarPackageType: string;
135 public packageId: string;
136 public iconSprite: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300137
ys969316a9fce2020-01-19 13:50:02 +0200138 // Service only
139 public serviceFunction: string;
140 public distributionStatus: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300141 public ecompGeneratedNaming: boolean;
142 public namingPolicy: string;
ys969316a9fce2020-01-19 13:50:02 +0200143 public serviceType: string;
144 public serviceRole: string;
145 public environmentContext: string;
146 public instantiationType: string;
aribeiro4f4f7fb2021-06-24 11:19:45 +0100147 public model: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300148
ys969316a9fce2020-01-19 13:50:02 +0200149 // backend lifecycleState
150 public state: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300151
ys969316a9fce2020-01-19 13:50:02 +0200152 // requirements
153 public capabilities;
154 public requirements;
Michael Lando5b593492018-07-29 16:13:45 +0300155
ys969316a9fce2020-01-19 13:50:02 +0200156 deserialize(response): ComponentMetadata {
Michael Landoed64b5e2017-06-09 03:19:04 +0300157 this.abstract = response.abstract;
158 this.uniqueId = response.uniqueId;
159 this.uuid = response.uuid;
160 this.invariantUUID = response.invariantUUID;
161 this.contactId = response.contactId;
162 this.categories = response.categories;
163 this.creatorUserId = response.creatorUserId;
164 this.creationDate = response.creationDate;
165 this.creatorFullName = response.creatorFullName;
166 this.description = response.description;
167 this.icon = response.icon;
168 this.lastUpdateDate = response.lastUpdateDate;
169 this.lastUpdaterUserId = response.lastUpdaterUserId;
170 this.lastUpdaterFullName = response.lastUpdaterFullName;
171 this.lifecycleState = response.lifecycleState;
172 this.name = response.name;
173 this.version = response.version;
174 this.tags = angular.copy(response.tags, this.tags);
175 this.allVersions = response.allVersions;
176 this.componentType = response.componentType;
177 this.distributionStatus = response.distributionStatus;
178 this.highestVersion = response.highestVersion;
179 this.vendorName = response.vendorName;
180 this.vendorRelease = response.vendorRelease;
181 this.derivedList = response.derivedList;
182 this.normalizedName = response.normalizedName;
183 this.systemName = response.systemName;
ys969316a9fce2020-01-19 13:50:02 +0200184 this.serviceFunction = response.serviceFunction;
Michael Landoed64b5e2017-06-09 03:19:04 +0300185 this.resourceType = response.resourceType;
186 this.csarUUID = response.csarUUID;
Idan Amit6cc9a112017-09-13 17:21:33 +0300187 this.csarVersion = response.csarVersion;
Michael Landoed64b5e2017-06-09 03:19:04 +0300188 this.state = response.state;
189 this.ecompGeneratedNaming = response.ecompGeneratedNaming;
190 this.namingPolicy = response.namingPolicy;
191 this.derivedFrom = response.derivedFrom;
Michael Lando75aacbb2017-07-17 21:12:03 +0300192 this.resourceVendorModelNumber = response.resourceVendorModelNumber;
193 this.serviceType = response.serviceType;
194 this.serviceRole = response.serviceRole;
Idan Amit6cc9a112017-09-13 17:21:33 +0300195 this.environmentContext = response.environmentContext;
Michael Lando5b593492018-07-29 16:13:45 +0300196 this.archived = response.archived;
197 this.instantiationType = response.instantiationType;
198 this.vspArchived = response.vspArchived;
miriame41ee9cb2019-03-04 13:49:15 +0200199 this.toscaResourceName = response.toscaResourceName;
ys969316a9fce2020-01-19 13:50:02 +0200200 this.capabilities = response.capabilities;
201 this.requirements = response.requirements;
MichaelMorris69779182020-12-15 16:12:59 +0000202 this.categorySpecificMetadata = response.categorySpecificMetadata;
aribeiro4f4f7fb2021-06-24 11:19:45 +0100203 this.model = response.model;
Michael Landoed64b5e2017-06-09 03:19:04 +0300204 return this;
205 }
206
ys969316a9fce2020-01-19 13:50:02 +0200207 public isService = (): boolean => {
208 return this.componentType === ComponentType.SERVICE;
209 }
210
211 public getTypeUrl(): string {
212 return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';
213 }
Michael Landoed64b5e2017-06-09 03:19:04 +0300214}