2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 import * as _ from "lodash";
24 import {ArtifactType} from './../utils';
25 import {HeatParameterModel} from "./heat-parameters";
27 //this object contains keys, each key contain ArtifactModel
28 export class ArtifactGroupModel {
30 constructor(artifacts?:ArtifactGroupModel) {
31 _.forEach(artifacts, (artifact:ArtifactModel, key) => {
32 this[key] = new ArtifactModel(artifact);
36 public filteredByType(type:string):ArtifactGroupModel {
37 let tmpArtifactGroupModel = new ArtifactGroupModel();
38 _.each(Object.keys(this), (key)=>{
39 if (this[key].artifactType === type) {
40 tmpArtifactGroupModel[key] = this[key];
43 return tmpArtifactGroupModel;
47 export class ArtifactModel {
49 artifactDisplayName:string;
50 artifactGroupType:string;
56 artifactVersion:string;
57 creatorFullName:string;
59 lastUpdateDate:number;
67 artifactChecksum:string;
69 heatParameters:Array<HeatParameterModel>;
70 generatedFromId:string;
74 originalDescription:string;
75 envArtifact:ArtifactModel;
77 constructor(artifact?:ArtifactModel) {
79 this.artifactDisplayName = artifact.artifactDisplayName;
80 this.artifactGroupType = artifact.artifactGroupType;
81 this.uniqueId = artifact.uniqueId;
82 this.artifactName = artifact.artifactName;
83 this.artifactLabel = artifact.artifactLabel;
84 this.artifactType = artifact.artifactType;
85 this.artifactUUID = artifact.artifactUUID;
86 this.artifactVersion = artifact.artifactVersion;
87 this.creatorFullName = artifact.creatorFullName;
88 this.creationDate = artifact.creationDate;
89 this.lastUpdateDate = artifact.lastUpdateDate;
90 this.description = artifact.description;
91 this.mandatory = artifact.mandatory;
92 this.serviceApi = artifact.serviceApi;
93 this.payloadData = artifact.payloadData;
94 this.timeout = artifact.timeout;
95 this.esId = artifact.esId;
96 this["Content-MD5"] = artifact["Content-MD5"];
97 this.artifactChecksum = artifact.artifactChecksum;
98 this.apiUrl = artifact.apiUrl;
99 this.heatParameters = _.sortBy(artifact.heatParameters, 'name');
100 this.generatedFromId = artifact.generatedFromId;
101 this.selected = artifact.selected ? artifact.selected : false;
102 this.originalDescription = artifact.description;
106 public isHEAT = ():boolean => {
107 return ArtifactType.HEAT === this.artifactType || ArtifactType.HEAT_VOL === this.artifactType || ArtifactType.HEAT_NET === this.artifactType;
110 public isThirdParty = ():boolean => {
111 return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, this.artifactType);
114 public toJSON = ():any => {
115 this.selected = undefined;
116 this.originalDescription = undefined;
117 this.envArtifact = undefined;