blob: 186cd8aa39bae12d5bb2b615f3355d18a6cb730f [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
88}
89
90export class ComponentMetadata implements IComponentMetadata {
91
92 public abstract: string;
93 public uniqueId: string;
94 public uuid: string;
95 public invariantUUID: string;
96 public name: string;
97 public version: string;
98 public creationDate: number;
99 public lastUpdateDate: number;
100 public description: string;
101 public lifecycleState: string;
102 public tags: string[];
103 public icon: string;
104 public contactId: string;
105 public allVersions: any;
106 public creatorUserId: string;
107 public creatorFullName: string;
108 public lastUpdaterUserId: string;
109 public lastUpdaterFullName: string;
110 public componentType: string;
111 public categories: IMainCategory[];
112 public highestVersion: boolean;
113 public normalizedName: string;
114 public systemName: string;
115 public archived: boolean;
Michael Lando5b593492018-07-29 16:13:45 +0300116 public vspArchived: boolean;
miriame41ee9cb2019-03-04 13:49:15 +0200117 public toscaResourceName: string;
ys969316a9fce2020-01-19 13:50:02 +0200118 public selectedCategory: string;
119 public filterTerm: string;
MichaelMorris69779182020-12-15 16:12:59 +0000120 public categorySpecificMetadata: Metadata = new Metadata();
Michael Landoed64b5e2017-06-09 03:19:04 +0300121
ys969316a9fce2020-01-19 13:50:02 +0200122 // Resource only
Michael Landoed64b5e2017-06-09 03:19:04 +0300123 public resourceType: string;
ys969316a9fce2020-01-19 13:50:02 +0200124 public csarUUID: string;
125 public csarVersion: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300126 public derivedList: string[];
ys969316a9fce2020-01-19 13:50:02 +0200127 public vendorName: string;
128 public vendorRelease: string;
129 public derivedFrom: string[];
130 public resourceVendorModelNumber: string;
131 public csarPackageType: string;
132 public packageId: string;
133 public iconSprite: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300134
ys969316a9fce2020-01-19 13:50:02 +0200135 // Service only
136 public serviceFunction: string;
137 public distributionStatus: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300138 public ecompGeneratedNaming: boolean;
139 public namingPolicy: string;
ys969316a9fce2020-01-19 13:50:02 +0200140 public serviceType: string;
141 public serviceRole: string;
142 public environmentContext: string;
143 public instantiationType: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300144
ys969316a9fce2020-01-19 13:50:02 +0200145 // backend lifecycleState
146 public state: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300147
ys969316a9fce2020-01-19 13:50:02 +0200148 // requirements
149 public capabilities;
150 public requirements;
Michael Lando5b593492018-07-29 16:13:45 +0300151
ys969316a9fce2020-01-19 13:50:02 +0200152 deserialize(response): ComponentMetadata {
Michael Landoed64b5e2017-06-09 03:19:04 +0300153 this.abstract = response.abstract;
154 this.uniqueId = response.uniqueId;
155 this.uuid = response.uuid;
156 this.invariantUUID = response.invariantUUID;
157 this.contactId = response.contactId;
158 this.categories = response.categories;
159 this.creatorUserId = response.creatorUserId;
160 this.creationDate = response.creationDate;
161 this.creatorFullName = response.creatorFullName;
162 this.description = response.description;
163 this.icon = response.icon;
164 this.lastUpdateDate = response.lastUpdateDate;
165 this.lastUpdaterUserId = response.lastUpdaterUserId;
166 this.lastUpdaterFullName = response.lastUpdaterFullName;
167 this.lifecycleState = response.lifecycleState;
168 this.name = response.name;
169 this.version = response.version;
170 this.tags = angular.copy(response.tags, this.tags);
171 this.allVersions = response.allVersions;
172 this.componentType = response.componentType;
173 this.distributionStatus = response.distributionStatus;
174 this.highestVersion = response.highestVersion;
175 this.vendorName = response.vendorName;
176 this.vendorRelease = response.vendorRelease;
177 this.derivedList = response.derivedList;
178 this.normalizedName = response.normalizedName;
179 this.systemName = response.systemName;
ys969316a9fce2020-01-19 13:50:02 +0200180 this.serviceFunction = response.serviceFunction;
Michael Landoed64b5e2017-06-09 03:19:04 +0300181 this.resourceType = response.resourceType;
182 this.csarUUID = response.csarUUID;
Idan Amit6cc9a112017-09-13 17:21:33 +0300183 this.csarVersion = response.csarVersion;
Michael Landoed64b5e2017-06-09 03:19:04 +0300184 this.state = response.state;
185 this.ecompGeneratedNaming = response.ecompGeneratedNaming;
186 this.namingPolicy = response.namingPolicy;
187 this.derivedFrom = response.derivedFrom;
Michael Lando75aacbb2017-07-17 21:12:03 +0300188 this.resourceVendorModelNumber = response.resourceVendorModelNumber;
189 this.serviceType = response.serviceType;
190 this.serviceRole = response.serviceRole;
Idan Amit6cc9a112017-09-13 17:21:33 +0300191 this.environmentContext = response.environmentContext;
Michael Lando5b593492018-07-29 16:13:45 +0300192 this.archived = response.archived;
193 this.instantiationType = response.instantiationType;
194 this.vspArchived = response.vspArchived;
miriame41ee9cb2019-03-04 13:49:15 +0200195 this.toscaResourceName = response.toscaResourceName;
ys969316a9fce2020-01-19 13:50:02 +0200196 this.capabilities = response.capabilities;
197 this.requirements = response.requirements;
MichaelMorris69779182020-12-15 16:12:59 +0000198 this.categorySpecificMetadata = response.categorySpecificMetadata;
Michael Landoed64b5e2017-06-09 03:19:04 +0300199 return this;
200 }
201
ys969316a9fce2020-01-19 13:50:02 +0200202 public isService = (): boolean => {
203 return this.componentType === ComponentType.SERVICE;
204 }
205
206 public getTypeUrl(): string {
207 return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';
208 }
Michael Landoed64b5e2017-06-09 03:19:04 +0300209}