Michael Lando | dd60339 | 2017-07-12 00:54:52 +0300 | [diff] [blame] | 1 | /*- |
| 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 |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 10 | * |
Michael Lando | dd60339 | 2017-07-12 00:54:52 +0300 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 12 | * |
Michael Lando | dd60339 | 2017-07-12 00:54:52 +0300 | [diff] [blame] | 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========================================================= |
| 19 | */ |
| 20 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 21 | import { CapabilitiesGroup, RequirementsGroup } from 'app/models'; |
| 22 | import { ComponentType } from 'app/utils'; |
| 23 | import { IMainCategory } from './category'; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 24 | /** |
| 25 | * Created by obarda on 4/18/2017. |
| 26 | */ |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 27 | export interface IComponentMetadata { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 28 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 29 | 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 | |
| 88 | export 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 Lando | 5b59349 | 2018-07-29 16:13:45 +0300 | [diff] [blame] | 114 | public vspArchived: boolean; |
miriame | 41ee9cb | 2019-03-04 13:49:15 +0200 | [diff] [blame] | 115 | public toscaResourceName: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 116 | public selectedCategory: string; |
| 117 | public filterTerm: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 118 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 119 | // Resource only |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 120 | public resourceType: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 121 | public csarUUID: string; |
| 122 | public csarVersion: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 123 | public derivedList: string[]; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 124 | 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 Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 131 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 132 | // Service only |
| 133 | public serviceFunction: string; |
| 134 | public distributionStatus: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 135 | public ecompGeneratedNaming: boolean; |
| 136 | public namingPolicy: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 137 | public serviceType: string; |
| 138 | public serviceRole: string; |
| 139 | public environmentContext: string; |
| 140 | public instantiationType: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 141 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 142 | // backend lifecycleState |
| 143 | public state: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 144 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 145 | // requirements |
| 146 | public capabilities; |
| 147 | public requirements; |
Michael Lando | 5b59349 | 2018-07-29 16:13:45 +0300 | [diff] [blame] | 148 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 149 | deserialize(response): ComponentMetadata { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 150 | 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; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 177 | this.serviceFunction = response.serviceFunction; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 178 | this.resourceType = response.resourceType; |
| 179 | this.csarUUID = response.csarUUID; |
Idan Amit | 6cc9a11 | 2017-09-13 17:21:33 +0300 | [diff] [blame] | 180 | this.csarVersion = response.csarVersion; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 181 | this.state = response.state; |
| 182 | this.ecompGeneratedNaming = response.ecompGeneratedNaming; |
| 183 | this.namingPolicy = response.namingPolicy; |
| 184 | this.derivedFrom = response.derivedFrom; |
Michael Lando | 75aacbb | 2017-07-17 21:12:03 +0300 | [diff] [blame] | 185 | this.resourceVendorModelNumber = response.resourceVendorModelNumber; |
| 186 | this.serviceType = response.serviceType; |
| 187 | this.serviceRole = response.serviceRole; |
Idan Amit | 6cc9a11 | 2017-09-13 17:21:33 +0300 | [diff] [blame] | 188 | this.environmentContext = response.environmentContext; |
Michael Lando | 5b59349 | 2018-07-29 16:13:45 +0300 | [diff] [blame] | 189 | this.archived = response.archived; |
| 190 | this.instantiationType = response.instantiationType; |
| 191 | this.vspArchived = response.vspArchived; |
miriame | 41ee9cb | 2019-03-04 13:49:15 +0200 | [diff] [blame] | 192 | this.toscaResourceName = response.toscaResourceName; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 193 | this.capabilities = response.capabilities; |
| 194 | this.requirements = response.requirements; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 195 | return this; |
| 196 | } |
| 197 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 198 | 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 Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 205 | } |