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'; |
MichaelMorris | 6977918 | 2020-12-15 16:12:59 +0000 | [diff] [blame] | 24 | import { Metadata } from "app/models/metadata"; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 25 | /** |
| 26 | * Created by obarda on 4/18/2017. |
| 27 | */ |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 28 | export interface IComponentMetadata { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 29 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 30 | 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; |
MichaelMorris | 6977918 | 2020-12-15 16:12:59 +0000 | [diff] [blame] | 57 | categorySpecificMetadata: Metadata; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 58 | |
| 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 | |
| 90 | export 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 Lando | 5b59349 | 2018-07-29 16:13:45 +0300 | [diff] [blame] | 116 | public vspArchived: boolean; |
miriame | 41ee9cb | 2019-03-04 13:49:15 +0200 | [diff] [blame] | 117 | public toscaResourceName: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 118 | public selectedCategory: string; |
| 119 | public filterTerm: string; |
MichaelMorris | 6977918 | 2020-12-15 16:12:59 +0000 | [diff] [blame] | 120 | public categorySpecificMetadata: Metadata = new Metadata(); |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 121 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 122 | // Resource only |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 123 | public resourceType: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 124 | public csarUUID: string; |
| 125 | public csarVersion: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 126 | public derivedList: string[]; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 127 | 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 Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 134 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 135 | // Service only |
| 136 | public serviceFunction: string; |
| 137 | public distributionStatus: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 138 | public ecompGeneratedNaming: boolean; |
| 139 | public namingPolicy: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 140 | public serviceType: string; |
| 141 | public serviceRole: string; |
| 142 | public environmentContext: string; |
| 143 | public instantiationType: 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 | // backend lifecycleState |
| 146 | public state: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 147 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 148 | // requirements |
| 149 | public capabilities; |
| 150 | public requirements; |
Michael Lando | 5b59349 | 2018-07-29 16:13:45 +0300 | [diff] [blame] | 151 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 152 | deserialize(response): ComponentMetadata { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 153 | 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; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 180 | this.serviceFunction = response.serviceFunction; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 181 | this.resourceType = response.resourceType; |
| 182 | this.csarUUID = response.csarUUID; |
Idan Amit | 6cc9a11 | 2017-09-13 17:21:33 +0300 | [diff] [blame] | 183 | this.csarVersion = response.csarVersion; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 184 | this.state = response.state; |
| 185 | this.ecompGeneratedNaming = response.ecompGeneratedNaming; |
| 186 | this.namingPolicy = response.namingPolicy; |
| 187 | this.derivedFrom = response.derivedFrom; |
Michael Lando | 75aacbb | 2017-07-17 21:12:03 +0300 | [diff] [blame] | 188 | this.resourceVendorModelNumber = response.resourceVendorModelNumber; |
| 189 | this.serviceType = response.serviceType; |
| 190 | this.serviceRole = response.serviceRole; |
Idan Amit | 6cc9a11 | 2017-09-13 17:21:33 +0300 | [diff] [blame] | 191 | this.environmentContext = response.environmentContext; |
Michael Lando | 5b59349 | 2018-07-29 16:13:45 +0300 | [diff] [blame] | 192 | this.archived = response.archived; |
| 193 | this.instantiationType = response.instantiationType; |
| 194 | this.vspArchived = response.vspArchived; |
miriame | 41ee9cb | 2019-03-04 13:49:15 +0200 | [diff] [blame] | 195 | this.toscaResourceName = response.toscaResourceName; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 196 | this.capabilities = response.capabilities; |
| 197 | this.requirements = response.requirements; |
MichaelMorris | 6977918 | 2020-12-15 16:12:59 +0000 | [diff] [blame] | 198 | this.categorySpecificMetadata = response.categorySpecificMetadata; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 199 | return this; |
| 200 | } |
| 201 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 202 | 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 Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 209 | } |