blob: 27c0dd6c49095b9ec0addb2f2e3a1e170c511274 [file] [log] [blame]
Michael Landodd603392017-07-12 00:54:52 +03001/*-
2 * ============LICENSE_START=======================================================
3 * SDC
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
Piotr Darosz2c25cba2019-03-27 15:25:50 +01006 * Modifications Copyright (C) 2019 Nokia. All rights reserved.
Michael Landodd603392017-07-12 00:54:52 +03007 * ================================================================================
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
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
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=========================================================
20 */
21
Michael Landoed64b5e2017-06-09 03:19:04 +030022'use strict';
23
Michael Landoa5445102018-03-04 14:53:33 +020024import * as _ from "lodash";
Michael Landoed64b5e2017-06-09 03:19:04 +030025import {ArtifactType} from './../utils';
26import {HeatParameterModel} from "./heat-parameters";
27
28//this object contains keys, each key contain ArtifactModel
29export class ArtifactGroupModel {
30
31 constructor(artifacts?:ArtifactGroupModel) {
32 _.forEach(artifacts, (artifact:ArtifactModel, key) => {
33 this[key] = new ArtifactModel(artifact);
34 });
35 }
36
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];
42 }
43 });
44 return tmpArtifactGroupModel;
45 };
46}
47
48export class ArtifactModel {
49
50 artifactDisplayName:string;
51 artifactGroupType:string;
52 uniqueId:string;
53 artifactName:string;
54 artifactLabel:string;
55 artifactType:string;
56 artifactUUID:string;
57 artifactVersion:string;
58 creatorFullName:string;
59 creationDate:number;
60 lastUpdateDate:number;
61 description:string;
62 mandatory:boolean;
63 serviceApi:boolean;
64 payloadData:string;
65 timeout:number;
66 esId:string;
67 "Content-MD5":string;
68 artifactChecksum:string;
69 apiUrl:string;
70 heatParameters:Array<HeatParameterModel>;
71 generatedFromId:string;
72
73 //custom properties
74 selected:boolean;
75 originalDescription:string;
76 envArtifact:ArtifactModel;
77
78 constructor(artifact?:ArtifactModel) {
79 if (artifact) {
80 this.artifactDisplayName = artifact.artifactDisplayName;
81 this.artifactGroupType = artifact.artifactGroupType;
82 this.uniqueId = artifact.uniqueId;
83 this.artifactName = artifact.artifactName;
84 this.artifactLabel = artifact.artifactLabel;
85 this.artifactType = artifact.artifactType;
86 this.artifactUUID = artifact.artifactUUID;
87 this.artifactVersion = artifact.artifactVersion;
88 this.creatorFullName = artifact.creatorFullName;
89 this.creationDate = artifact.creationDate;
90 this.lastUpdateDate = artifact.lastUpdateDate;
91 this.description = artifact.description;
92 this.mandatory = artifact.mandatory;
93 this.serviceApi = artifact.serviceApi;
94 this.payloadData = artifact.payloadData;
95 this.timeout = artifact.timeout;
96 this.esId = artifact.esId;
97 this["Content-MD5"] = artifact["Content-MD5"];
98 this.artifactChecksum = artifact.artifactChecksum;
99 this.apiUrl = artifact.apiUrl;
100 this.heatParameters = _.sortBy(artifact.heatParameters, 'name');
101 this.generatedFromId = artifact.generatedFromId;
102 this.selected = artifact.selected ? artifact.selected : false;
103 this.originalDescription = artifact.description;
104 }
105 }
106
107 public isHEAT = ():boolean => {
108 return ArtifactType.HEAT === this.artifactType || ArtifactType.HEAT_VOL === this.artifactType || ArtifactType.HEAT_NET === this.artifactType;
109 };
110
111 public isThirdParty = ():boolean => {
112 return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, this.artifactType);
113 };
114
Piotr Darosz2c25cba2019-03-27 15:25:50 +0100115 public isGenericBrowseable = ():boolean => {
116 return this.artifactType == ArtifactType.VES_EVENTS;
117 };
118
Michael Landoed64b5e2017-06-09 03:19:04 +0300119 public toJSON = ():any => {
120 this.selected = undefined;
121 this.originalDescription = undefined;
122 this.envArtifact = undefined;
123 return this;
124 };
125}
126
127