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";
27 import {PropertyBEModel} from "./properties-inputs/property-be-model";
29 //this object contains keys, each key contain ArtifactModel
30 export class ArtifactGroupModel {
32 constructor(artifacts?:ArtifactGroupModel) {
33 _.forEach(artifacts, (artifact:ArtifactModel, key) => {
34 this[key] = new ArtifactModel(artifact);
38 public filteredByType(type:string):ArtifactGroupModel {
39 let tmpArtifactGroupModel = new ArtifactGroupModel();
40 _.each(Object.keys(this), (key)=>{
41 if (this[key].artifactType === type) {
42 tmpArtifactGroupModel[key] = this[key];
45 return tmpArtifactGroupModel;
49 export class ArtifactModel {
51 artifactDisplayName:string;
52 artifactGroupType:string;
58 artifactVersion:string;
59 creatorFullName:string;
61 lastUpdateDate:number;
69 artifactChecksum:string;
71 heatParameters:Array<HeatParameterModel>;
72 generatedFromId:string;
77 originalDescription:string;
78 envArtifact:ArtifactModel;
79 allowDeleteAndUpdate: boolean;
80 properties:Array<PropertyBEModel>;
82 constructor(artifact?:ArtifactModel) {
84 this.artifactDisplayName = artifact.artifactDisplayName;
85 this.artifactGroupType = artifact.artifactGroupType;
86 this.uniqueId = artifact.uniqueId;
87 this.artifactName = artifact.artifactName;
88 this.artifactLabel = artifact.artifactLabel;
89 this.artifactType = artifact.artifactType;
90 this.artifactUUID = artifact.artifactUUID;
91 this.artifactVersion = artifact.artifactVersion;
92 this.creatorFullName = artifact.creatorFullName;
93 this.creationDate = artifact.creationDate;
94 this.lastUpdateDate = artifact.lastUpdateDate;
95 this.description = artifact.description;
96 this.mandatory = artifact.mandatory;
97 this.serviceApi = artifact.serviceApi;
98 this.payloadData = artifact.payloadData;
99 this.timeout = artifact.timeout;
100 this.esId = artifact.esId;
101 this["Content-MD5"] = artifact["Content-MD5"];
102 this.artifactChecksum = artifact.artifactChecksum;
103 this.apiUrl = artifact.apiUrl;
104 this.heatParameters = _.sortBy(_.cloneDeep(artifact.heatParameters), 'name');
105 this.generatedFromId = artifact.generatedFromId;
106 this.selected = artifact.selected ? artifact.selected : false;
107 this.originalDescription = artifact.description;
108 this.isFromCsar = artifact.isFromCsar;
109 this.properties = _.sortBy(_.cloneDeep(artifact.properties), 'name');
113 public isHEAT = ():boolean => {
114 return ArtifactType.HEAT === this.artifactType || ArtifactType.HEAT_VOL === this.artifactType || ArtifactType.HEAT_NET === this.artifactType;
117 public isThirdParty = ():boolean => {
118 return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, this.artifactType);
121 public isGenericBrowseable = ():boolean => {
122 return this.artifactType === ArtifactType.VES_EVENTS || this.artifactType === ArtifactType.PM_DICTIONARY;
125 public toJSON = ():any => {
126 this.selected = undefined;
127 this.originalDescription = undefined;
128 this.envArtifact = undefined;
129 this.allowDeleteAndUpdate = undefined;