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=========================================================
22 * Created by obarda on 6/30/2016.
25 * Created by obarda on 2/4/2016.
28 import * as _ from "lodash";
29 import {PropertyModel} from "../properties";
30 import {ArtifactModel} from "../artifacts";
31 import {CommonUtils} from "../../utils/common-utils";
36 public groupUUID:string;
37 public invariantUUID:string;
38 public propertyValueCounter:number;
40 public typeUid:string;
41 public uniqueId:string;
42 public version:string;
43 public artifacts:Array<string> | Array<ArtifactModel>;
44 public artifactsUuid:Array<string>;
45 public properties:Array<PropertyModel>;
46 public members:Map<string, string>;
47 public customizationUUID:string;
48 public groupInstanceUniqueId:string; // This will only have a value if this is a group instance
50 constructor(module?:Module) {
52 this.name = module.name;
53 this.groupUUID = module.groupUUID;
54 this.invariantUUID = module.invariantUUID;
55 this.propertyValueCounter = module.propertyValueCounter;
56 this.type = module.type;
57 this.typeUid = module.typeUid;
58 this.uniqueId = module.uniqueId;
59 this.version = module.version;
60 this.artifacts = module.artifacts;
61 this.artifactsUuid = module.artifactsUuid;
62 this.properties = CommonUtils.initProperties(module.properties);
63 this.members = module.members;
64 this.customizationUUID = module.customizationUUID;
65 this.groupInstanceUniqueId = module.groupInstanceUniqueId;
66 this.name = this.name.replace(/:/g, '..');
72 export class DisplayModule extends Module {
75 artifacts:Array<ArtifactModel>;
78 public vfInstanceName:string;
79 public heatName:string;
80 public moduleName:string;
81 public customizationUUID:string;
84 constructor(displayModule?:DisplayModule) {
87 this.isBase = displayModule.isBase;
88 this.customizationUUID = displayModule.customizationUUID;
89 this.initArtifactsForDisplay(displayModule.artifacts);
91 //splitting module name for display and edit
92 let splitName:Array<string> = this.name.split('..');
93 this.vfInstanceName = splitName[0];
94 this.heatName = splitName[1];
95 this.moduleName = splitName[2];
98 private initArtifactsForDisplay = (artifacts:Array<ArtifactModel>):void => {
99 this.artifacts = new Array<ArtifactModel>();
100 _.forEach(artifacts, (artifact:ArtifactModel) => {
101 this.artifacts.push(new ArtifactModel(artifact));
105 public updateName = ():void => {
106 this.name = this.vfInstanceName + '..' + this.heatName + '..' + this.moduleName;
109 public toJSON = ():any => {
110 this.vfInstanceName = undefined;
111 this.heatName = undefined;
112 this.moduleName = undefined;
113 this.isBase = undefined;
114 this.artifacts = undefined;