2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nokia. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
24 import * as _ from "lodash";
25 import {ArtifactType} from './../utils';
26 import {HeatParameterModel} from "./heat-parameters";
28 //this object contains keys, each key contain ArtifactModel
29 export class ArtifactGroupModel {
31 constructor(artifacts?:ArtifactGroupModel) {
32 _.forEach(artifacts, (artifact:ArtifactModel, key) => {
33 this[key] = new ArtifactModel(artifact);
37 public filteredByType(type:string):ArtifactGroupModel {
38 let tmpArtifactGroupModel = new ArtifactGroupModel();
39 _.each(Object.keys(this), (key)=>{
40 if (this[key].artifactType === type) {
41 tmpArtifactGroupModel[key] = this[key];
44 return tmpArtifactGroupModel;
48 export class ArtifactModel {
50 artifactDisplayName:string;
51 artifactGroupType:string;
57 artifactVersion:string;
58 creatorFullName:string;
60 lastUpdateDate:number;
68 artifactChecksum:string;
70 heatParameters:Array<HeatParameterModel>;
71 generatedFromId:string;
76 originalDescription:string;
77 envArtifact:ArtifactModel;
78 allowDeleteAndUpdate: boolean;
80 constructor(artifact?:ArtifactModel) {
82 this.artifactDisplayName = artifact.artifactDisplayName;
83 this.artifactGroupType = artifact.artifactGroupType;
84 this.uniqueId = artifact.uniqueId;
85 this.artifactName = artifact.artifactName;
86 this.artifactLabel = artifact.artifactLabel;
87 this.artifactType = artifact.artifactType;
88 this.artifactUUID = artifact.artifactUUID;
89 this.artifactVersion = artifact.artifactVersion;
90 this.creatorFullName = artifact.creatorFullName;
91 this.creationDate = artifact.creationDate;
92 this.lastUpdateDate = artifact.lastUpdateDate;
93 this.description = artifact.description;
94 this.mandatory = artifact.mandatory;
95 this.serviceApi = artifact.serviceApi;
96 this.payloadData = artifact.payloadData;
97 this.timeout = artifact.timeout;
98 this.esId = artifact.esId;
99 this["Content-MD5"] = artifact["Content-MD5"];
100 this.artifactChecksum = artifact.artifactChecksum;
101 this.apiUrl = artifact.apiUrl;
102 this.heatParameters = _.sortBy(_.cloneDeep(artifact.heatParameters), 'name');
103 this.generatedFromId = artifact.generatedFromId;
104 this.selected = artifact.selected ? artifact.selected : false;
105 this.originalDescription = artifact.description;
106 this.isFromCsar = artifact.isFromCsar;
110 public isHEAT = ():boolean => {
111 return ArtifactType.HEAT === this.artifactType || ArtifactType.HEAT_VOL === this.artifactType || ArtifactType.HEAT_NET === this.artifactType;
114 public isThirdParty = ():boolean => {
115 return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, this.artifactType);
118 public isGenericBrowseable = ():boolean => {
119 return this.artifactType === ArtifactType.VES_EVENTS || this.artifactType === ArtifactType.PM_DICTIONARY;
122 public toJSON = ():any => {
123 this.selected = undefined;
124 this.originalDescription = undefined;
125 this.envArtifact = undefined;
126 this.allowDeleteAndUpdate = undefined;