blob: 53a28f076ef857bc24b81c64c69546072f732115 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*-
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
/**
* Created by obarda on 6/30/2016.
*/
/**
* Created by obarda on 2/4/2016.
*/
'use strict';
import {PropertyModel} from "../properties";
import {ArtifactModel} from "../artifacts";
import {CommonUtils} from "../../utils/common-utils";
export class Module {
public name:string;
public groupUUID:string;
public invariantUUID:string;
public propertyValueCounter:number;
public type:string;
public typeUid:string;
public uniqueId:string;
public version:string;
public artifacts:Array<string> | Array<ArtifactModel>;
public artifactsUuid:Array<string>;
public properties:Array<PropertyModel>;
public members:Array<string>;
public customizationUUID:string;
public groupInstanceUniqueId:string; // This will only have a value if this is a group instance
constructor(module?:Module) {
if (module) {
this.name = module.name;
this.groupUUID = module.groupUUID;
this.invariantUUID = module.invariantUUID;
this.propertyValueCounter = module.propertyValueCounter;
this.type = module.type;
this.typeUid = module.typeUid;
this.uniqueId = module.uniqueId;
this.version = module.version;
this.artifacts = module.artifacts;
this.artifactsUuid = module.artifactsUuid;
this.properties = CommonUtils.initProperties(module.properties);
this.members = module.members;
this.customizationUUID = module.customizationUUID;
this.groupInstanceUniqueId = module.groupInstanceUniqueId;
this.name = this.name.replace(/:/g, '..');
}
}
}
export class DisplayModule extends Module {
isBase:string;
artifacts:Array<ArtifactModel>;
//custom properties
public vfInstanceName:string;
public heatName:string;
public moduleName:string;
public customizationUUID:string;
constructor(displayModule?:DisplayModule) {
super(displayModule);
this.isBase = displayModule.isBase;
this.customizationUUID = displayModule.customizationUUID;
this.initArtifactsForDisplay(displayModule.artifacts);
//splitting module name for display and edit
let splitName:Array<string> = this.name.split('..');
this.vfInstanceName = splitName[0];
this.heatName = splitName[1];
this.moduleName = splitName[2];
}
private initArtifactsForDisplay = (artifacts:Array<ArtifactModel>):void => {
this.artifacts = new Array<ArtifactModel>();
_.forEach(artifacts, (artifact:ArtifactModel) => {
this.artifacts.push(new ArtifactModel(artifact));
});
};
public updateName = ():void => {
this.name = this.vfInstanceName + '..' + this.heatName + '..' + this.moduleName;
};
public toJSON = ():any => {
this.vfInstanceName = undefined;
this.heatName = undefined;
this.moduleName = undefined;
this.isBase = undefined;
this.artifacts = undefined;
return this;
};
}
|