re base code
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / ComponentInstanceDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.datatypes.elements;
22
23 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
24 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
25 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
26 import org.openecomp.sdc.common.util.ValidationUtils;
27
28 public class ComponentInstanceDataDefinition extends ToscaDataDefinition {
29
30         public ComponentInstanceDataDefinition() {
31                 setPropertyValueCounter(1);
32                 setAttributeValueCounter(1);
33                 setInputValueCounter(1);
34                 setIsProxy(false);
35         }
36
37         public ComponentInstanceDataDefinition(ComponentInstanceDataDefinition dataDefinition) {
38                 setIcon(dataDefinition.getIcon());
39                 setUniqueId(dataDefinition.getUniqueId());
40                 setName(dataDefinition.getName());
41                 setComponentUid(dataDefinition.getComponentUid());
42                 setCreationTime(dataDefinition.getCreationTime());
43                 setModificationTime(dataDefinition.getModificationTime());
44                 setDescription(dataDefinition.getDescription());
45                 setPosX(dataDefinition.getPosX());
46                 setPosY(dataDefinition.getPosY());
47                 setPropertyValueCounter(dataDefinition.getPropertyValueCounter());
48                 setNormalizedName(dataDefinition.getNormalizedName());
49                 setOriginType(dataDefinition.getOriginType());
50                 setCustomizationUUID(dataDefinition.getCustomizationUUID());
51                 setComponentName(dataDefinition.getComponentName());
52                 setComponentVersion(dataDefinition.getComponentVersion());
53                 setToscaComponentName(dataDefinition.getToscaComponentName());
54                 setInvariantName(dataDefinition.getInvariantName());
55                 setSourceModelInvariant(dataDefinition.getSourceModelInvariant());
56                 setSourceModelName(dataDefinition.getSourceModelName());
57                 setSourceModelUuid(dataDefinition.getSourceModelUuid());
58                 setSourceModelUid(dataDefinition.getSourceModelUid());
59                 setIsProxy(dataDefinition.getIsProxy());
60                 setOriginArchived(dataDefinition.isOriginArchived());
61         }
62
63         public String getIcon() {
64                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_ICON);
65         }
66
67         public void setIcon(String icon) {
68                 setToscaPresentationValue(JsonPresentationFields.CI_ICON, icon);
69         }
70
71         public String getUniqueId() {
72                 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
73         }
74
75         public void setUniqueId(String uniqueId) {
76                 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
77         }
78
79         public Long getCreationTime() {
80                 return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_TIME);
81         }
82
83         public void setCreationTime(Long creationTime) {
84                 setToscaPresentationValue(JsonPresentationFields.CREATION_TIME, creationTime);
85         }
86
87         public Long getModificationTime() {
88                 return (Long) getToscaPresentationValue(JsonPresentationFields.MODIFICATION_TIME);
89         }
90
91         public void setModificationTime(Long modificationTime) {
92                 setToscaPresentationValue(JsonPresentationFields.MODIFICATION_TIME, modificationTime);
93         }
94
95         public String getDescription() {
96                 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
97         }
98
99         public void setDescription(String description) {
100                 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
101         }
102
103         public String getPosX() {
104                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_POS_X);
105         }
106
107         public void setPosX(String posX) {
108                 setToscaPresentationValue(JsonPresentationFields.CI_POS_X, posX);
109         }
110
111         public String getPosY() {
112                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_POS_Y);
113         }
114
115         public void setPosY(String posY) {
116                 setToscaPresentationValue(JsonPresentationFields.CI_POS_Y, posY);
117         }
118
119         public String getComponentUid() {
120                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID);
121         }
122
123         public void setComponentUid(String resourceUid) {
124                 setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, resourceUid);
125         }
126
127         public String getName() {
128                 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
129         }
130
131         public void setName(String name) {
132                 if (this.getInvariantName() == null && name != null) {
133                         this.setInvariantName(ValidationUtils.normalizeComponentInstanceName(name));
134                 }
135                 setToscaPresentationValue(JsonPresentationFields.NAME, name);
136         }
137
138         public String getInvariantName() {
139                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME);
140         }
141
142         public void setInvariantName(String invariantName) {
143                 setToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME, invariantName);
144         }
145
146         public Integer getPropertyValueCounter() {
147                 return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_PROP_VALUE_COUNTER);
148         }
149
150         public void setPropertyValueCounter(Integer propertyValueCounter) {
151                 setToscaPresentationValue(JsonPresentationFields.CI_PROP_VALUE_COUNTER, propertyValueCounter);
152         }
153
154         public String getNormalizedName() {
155                 return (String) getToscaPresentationValue(JsonPresentationFields.NORMALIZED_NAME);
156         }
157
158         public void setNormalizedName(String normalizedName) {
159                 setToscaPresentationValue(JsonPresentationFields.NORMALIZED_NAME, normalizedName);
160         }
161
162         public OriginTypeEnum getOriginType() {
163                 OriginTypeEnum originType = null;
164                 String origType = (String) getToscaPresentationValue(JsonPresentationFields.CI_ORIGIN_TYPE);
165                 if (origType != null && !origType.isEmpty()) {
166
167                         originType = OriginTypeEnum.findByValue(origType);
168                 }
169                 return originType;
170         }
171
172         public void setOriginType(OriginTypeEnum originType) {
173                 if (originType != null)
174                         setToscaPresentationValue(JsonPresentationFields.CI_ORIGIN_TYPE, originType.getValue());
175         }
176
177         public Integer getAttributeValueCounter() {
178                 return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_ATTR_VALUE_COUNTER);
179         }
180
181         public void setAttributeValueCounter(Integer attributeValueCounter) {
182                 setToscaPresentationValue(JsonPresentationFields.CI_ATTR_VALUE_COUNTER, attributeValueCounter);
183         }
184
185         public Integer getInputValueCounter() {
186                 return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_INPUT_VALUE_COUNTER);
187         }
188
189         public void setInputValueCounter(Integer inputValueCounter) {
190                 setToscaPresentationValue(JsonPresentationFields.CI_INPUT_VALUE_COUNTER, inputValueCounter);
191         }
192
193         public String getCustomizationUUID() {
194                 return (String) getToscaPresentationValue(JsonPresentationFields.CUSTOMIZATION_UUID);
195         }
196
197         public void setCustomizationUUID(String customizationUUID) {
198                 setToscaPresentationValue(JsonPresentationFields.CUSTOMIZATION_UUID, customizationUUID);
199         }
200
201         public String getComponentName() {
202                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME);
203         }
204
205         public void setComponentName(String resourceName) {
206                 setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME, resourceName);
207         }
208
209         public String getComponentVersion() {
210                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_VERSION);
211         }
212
213         public String getToscaComponentName() {
214                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_TOSCA_COMPONENT_NAME);
215         }
216
217         public void setToscaComponentName(String toscaComponentName) {
218                 setToscaPresentationValue(JsonPresentationFields.CI_TOSCA_COMPONENT_NAME, toscaComponentName);
219         }
220
221         public void setComponentVersion(String resourceVersion) {
222                 setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_VERSION, resourceVersion);
223         }
224
225         public void setSourceModelUuid(String targetModelUuid) {
226                 setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UUID, targetModelUuid);
227         }
228         public void setSourceModelUid(String targetModelUid) {
229                 setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UID, targetModelUid);
230         }
231
232         public void setSourceModelName(String targetModelName) {
233                 setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_NAME, targetModelName);
234         }
235
236         public void setSourceModelInvariant(String targetModelInvariant) {
237                 setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_INVARIANT, targetModelInvariant);
238         }
239
240         public String getSourceModelUuid() {
241                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UUID);
242         }
243         public String getSourceModelUid() {
244                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UID);
245         }
246
247         public String getSourceModelName() {
248                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_NAME);
249         }
250
251         public String getSourceModelInvariant() {
252                 return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_INVARIANT);
253         }
254
255         public void setIsProxy(Boolean isProxy) {
256                 if (isProxy == null) {
257                         setToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY, false);
258                 } else {
259                         setToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY, isProxy);
260                 }
261         }
262
263         public Boolean getIsProxy() {
264                 Boolean isProxy = (Boolean) getToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY);
265                 return ( isProxy != null ) ? isProxy : false;
266         }
267
268         public void setOriginArchived(Boolean originArchived) {
269                 if (originArchived == null) {
270                         setToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED, false);
271                 } else {
272                         setToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED, originArchived);
273                 }
274         }
275
276         public Boolean isOriginArchived() {
277                 Boolean originArchived = (Boolean) getToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED);
278                 return ( originArchived != null ) ? originArchived : false;
279         }
280
281         @Override
282         public String toString() {
283                 return "ComponentInstanceDataDefinition [icon=" + getIcon() + ", uniqueId=" + getUniqueId() + ", name="
284                                 + getName() + ", normalizedName=" + getNormalizedName() + ", componentUid=" + getComponentUid()
285                                 + ", creationTime=" + getCreationTime() + ", modificationTime=" + getModificationTime()
286                                 + ", description=" + getDescription() + ", posX=" + getPosX() + ", posY=" + getPosY()
287                                 + ", propertyValueCounter=" + getPropertyValueCounter() + ", attributeValueCounter="
288                                 + getAttributeValueCounter() + ", inputValueCounter=" + getInputValueCounter() + ", originType="
289                                 + getOriginType() + ", customizationUUID=" + getCustomizationUUID() + ", componentName="
290                                 + getComponentName() + ", componentVersion=" + getComponentVersion() + ", toscaComponentName="
291                                 + getToscaComponentName() + "]";
292         }
293
294 }