blob: 8a4b257f551478cd1b5c0b36228ec7b78897eb67 [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';
Michael Landoed64b5e2017-06-09 03:19:04 +030024/**
25 * Created by obarda on 4/18/2017.
26 */
ys969316a9fce2020-01-19 13:50:02 +020027export interface IComponentMetadata {
Michael Landoed64b5e2017-06-09 03:19:04 +030028
ys969316a9fce2020-01-19 13:50:02 +020029 abstract: string;
30 uniqueId: string;
31 uuid: string;
32 invariantUUID: string;
33 name: string;
34 version: string;
35 creationDate: number;
36 lastUpdateDate: number;
37 description: string;
38 lifecycleState: string;
39 tags: string[];
40 icon: string;
41 contactId: string;
42 allVersions: any;
43 creatorUserId: string;
44 creatorFullName: string;
45 lastUpdaterUserId: string;
46 lastUpdaterFullName: string;
47 componentType: string;
48 categories: IMainCategory[];
49 highestVersion: boolean;
50 normalizedName: string;
51 systemName: string;
52 archived: boolean;
53 vspArchived: boolean;
54 selectedCategory: string;
55 filterTerm: string;
56
57 // Resource only
58 resourceType: string;
59 csarUUID: string;
60 csarVersion: string;
61 derivedList: string[];
62 vendorName: string;
63 vendorRelease: string;
64 derivedFrom: string[];
65 resourceVendorModelNumber: string;
66 csarPackageType: string;
67 packageId: string;
68 iconSprite: string;
69
70 // Service only
71 serviceFunction: string;
72 distributionStatus: string;
73 ecompGeneratedNaming: boolean;
74 namingPolicy: string;
75 serviceType: string;
76 serviceRole: string;
77 environmentContext: string;
78 instantiationType: string;
79
80 // backend lifecycleState
81 state: string;
82
83 capabilities: CapabilitiesGroup;
84 requirements: RequirementsGroup;
85
86}
87
88export class ComponentMetadata implements IComponentMetadata {
89
90 public abstract: string;
91 public uniqueId: string;
92 public uuid: string;
93 public invariantUUID: string;
94 public name: string;
95 public version: string;
96 public creationDate: number;
97 public lastUpdateDate: number;
98 public description: string;
99 public lifecycleState: string;
100 public tags: string[];
101 public icon: string;
102 public contactId: string;
103 public allVersions: any;
104 public creatorUserId: string;
105 public creatorFullName: string;
106 public lastUpdaterUserId: string;
107 public lastUpdaterFullName: string;
108 public componentType: string;
109 public categories: IMainCategory[];
110 public highestVersion: boolean;
111 public normalizedName: string;
112 public systemName: string;
113 public archived: boolean;
Michael Lando5b593492018-07-29 16:13:45 +0300114 public vspArchived: boolean;
miriame41ee9cb2019-03-04 13:49:15 +0200115 public toscaResourceName: string;
ys969316a9fce2020-01-19 13:50:02 +0200116 public selectedCategory: string;
117 public filterTerm: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300118
ys969316a9fce2020-01-19 13:50:02 +0200119 // Resource only
Michael Landoed64b5e2017-06-09 03:19:04 +0300120 public resourceType: string;
ys969316a9fce2020-01-19 13:50:02 +0200121 public csarUUID: string;
122 public csarVersion: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300123 public derivedList: string[];
ys969316a9fce2020-01-19 13:50:02 +0200124 public vendorName: string;
125 public vendorRelease: string;
126 public derivedFrom: string[];
127 public resourceVendorModelNumber: string;
128 public csarPackageType: string;
129 public packageId: string;
130 public iconSprite: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300131
ys969316a9fce2020-01-19 13:50:02 +0200132 // Service only
133 public serviceFunction: string;
134 public distributionStatus: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300135 public ecompGeneratedNaming: boolean;
136 public namingPolicy: string;
ys969316a9fce2020-01-19 13:50:02 +0200137 public serviceType: string;
138 public serviceRole: string;
139 public environmentContext: string;
140 public instantiationType: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300141
ys969316a9fce2020-01-19 13:50:02 +0200142 // backend lifecycleState
143 public state: string;
Michael Landoed64b5e2017-06-09 03:19:04 +0300144
ys969316a9fce2020-01-19 13:50:02 +0200145 // requirements
146 public capabilities;
147 public requirements;
Michael Lando5b593492018-07-29 16:13:45 +0300148
ys969316a9fce2020-01-19 13:50:02 +0200149 deserialize(response): ComponentMetadata {
Michael Landoed64b5e2017-06-09 03:19:04 +0300150 this.abstract = response.abstract;
151 this.uniqueId = response.uniqueId;
152 this.uuid = response.uuid;
153 this.invariantUUID = response.invariantUUID;
154 this.contactId = response.contactId;
155 this.categories = response.categories;
156 this.creatorUserId = response.creatorUserId;
157 this.creationDate = response.creationDate;
158 this.creatorFullName = response.creatorFullName;
159 this.description = response.description;
160 this.icon = response.icon;
161 this.lastUpdateDate = response.lastUpdateDate;
162 this.lastUpdaterUserId = response.lastUpdaterUserId;
163 this.lastUpdaterFullName = response.lastUpdaterFullName;
164 this.lifecycleState = response.lifecycleState;
165 this.name = response.name;
166 this.version = response.version;
167 this.tags = angular.copy(response.tags, this.tags);
168 this.allVersions = response.allVersions;
169 this.componentType = response.componentType;
170 this.distributionStatus = response.distributionStatus;
171 this.highestVersion = response.highestVersion;
172 this.vendorName = response.vendorName;
173 this.vendorRelease = response.vendorRelease;
174 this.derivedList = response.derivedList;
175 this.normalizedName = response.normalizedName;
176 this.systemName = response.systemName;
ys969316a9fce2020-01-19 13:50:02 +0200177 this.serviceFunction = response.serviceFunction;
Michael Landoed64b5e2017-06-09 03:19:04 +0300178 this.resourceType = response.resourceType;
179 this.csarUUID = response.csarUUID;
Idan Amit6cc9a112017-09-13 17:21:33 +0300180 this.csarVersion = response.csarVersion;
Michael Landoed64b5e2017-06-09 03:19:04 +0300181 this.state = response.state;
182 this.ecompGeneratedNaming = response.ecompGeneratedNaming;
183 this.namingPolicy = response.namingPolicy;
184 this.derivedFrom = response.derivedFrom;
Michael Lando75aacbb2017-07-17 21:12:03 +0300185 this.resourceVendorModelNumber = response.resourceVendorModelNumber;
186 this.serviceType = response.serviceType;
187 this.serviceRole = response.serviceRole;
Idan Amit6cc9a112017-09-13 17:21:33 +0300188 this.environmentContext = response.environmentContext;
Michael Lando5b593492018-07-29 16:13:45 +0300189 this.archived = response.archived;
190 this.instantiationType = response.instantiationType;
191 this.vspArchived = response.vspArchived;
miriame41ee9cb2019-03-04 13:49:15 +0200192 this.toscaResourceName = response.toscaResourceName;
ys969316a9fce2020-01-19 13:50:02 +0200193 this.capabilities = response.capabilities;
194 this.requirements = response.requirements;
Michael Landoed64b5e2017-06-09 03:19:04 +0300195 return this;
196 }
197
ys969316a9fce2020-01-19 13:50:02 +0200198 public isService = (): boolean => {
199 return this.componentType === ComponentType.SERVICE;
200 }
201
202 public getTypeUrl(): string {
203 return this.componentType === ComponentType.RESOURCE ? 'resources/' : 'services/';
204 }
Michael Landoed64b5e2017-06-09 03:19:04 +0300205}