Sync Integ to Master
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / GroupDataDefinition.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.tosca.ToscaDataDefinition;
25
26 import java.io.Serializable;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32
33 public class GroupDataDefinition extends ToscaDataDefinition implements Serializable {
34
35         /**
36          * 
37          */
38         private static final long serialVersionUID = 1565606165279109427L;
39
40         private String typeUid;
41
42         private Integer propertyValueCounter = 0;
43
44         public GroupDataDefinition() {
45                 super();
46
47         }
48         
49         public GroupDataDefinition(Map<String, Object> gr) {
50                 super(gr);
51                 propertyValueCounter = 0;
52         }
53         
54         public GroupDataDefinition(GroupDataDefinition other) {
55                 this.setName(other.getName());
56                 this.setUniqueId(other.getUniqueId());
57                 this.setType(other.getType());
58                 this.setVersion(other.getVersion());
59                 this.setInvariantUUID(other.getInvariantUUID());
60                 this.setDescription(other.getDescription());
61                 this.propertyValueCounter = other.propertyValueCounter;
62                 this.setGroupUUID(other.getGroupUUID());
63                 
64                 if (other.getMembers() != null) {
65                         this.setMembers(new HashMap<String, String>(other.getMembers()));
66                 }
67                 if (other.getArtifacts() != null) {
68                         this.setArtifacts(new ArrayList<String>(other.getArtifacts()));
69                 }
70
71                 if (other.getArtifactsUuid() != null) {
72                         this.setArtifactsUuid( new ArrayList<String>(other.getArtifactsUuid()));
73                 }
74                 this.setTypeUid(other.typeUid);
75                 this.setProperties(other.getProperties());
76         }
77
78
79         public String getName() {
80                 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
81         }
82
83         public void setName(String name) {
84                 setToscaPresentationValue(JsonPresentationFields.NAME, name);
85         }
86
87         public String getUniqueId() {
88                 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
89         }
90
91         public void setUniqueId(String uniqueId) {
92                 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
93         }
94
95         public String getType() {
96                 return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
97         }
98
99         public void setType(String type) {
100                 setToscaPresentationValue(JsonPresentationFields.TYPE, type);
101         }
102
103         public String getVersion() {
104                 return (String) getToscaPresentationValue(JsonPresentationFields.VERSION);
105         }
106
107         public void setVersion(String version) {
108                 setToscaPresentationValue(JsonPresentationFields.VERSION, version);
109         }
110
111         public String getInvariantUUID() {
112                 return (String) getToscaPresentationValue(JsonPresentationFields.INVARIANT_UUID);
113         }
114
115         public void setInvariantUUID(String invariantUUID) {
116                 setToscaPresentationValue(JsonPresentationFields.INVARIANT_UUID, invariantUUID);
117         }
118
119         public String getDescription() {
120                 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
121         }
122
123         public void setDescription(String description) {
124                 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
125         }
126
127         public Integer getPropertyValueCounter() {
128                 return propertyValueCounter;
129         }
130
131         public void setPropertyValueCounter(Integer propertyValueCounter) {
132                 this.propertyValueCounter = propertyValueCounter;
133         }
134
135         public String getGroupUUID() {
136                 return (String) getToscaPresentationValue(JsonPresentationFields.GROUP_UUID);
137         }
138
139         public void setGroupUUID(String groupUUID) {
140                 setToscaPresentationValue(JsonPresentationFields.GROUP_UUID, groupUUID);
141         }
142
143         public Map<String, String> getMembers() {
144                 return (Map<String, String>) getToscaPresentationValue(JsonPresentationFields.GROUP_MEMBER);
145         }
146
147         public void setMembers(Map<String, String> members) {
148                 setToscaPresentationValue(JsonPresentationFields.GROUP_MEMBER, members);
149         }
150
151         public List<String> getArtifacts() {
152                 return (List<String> ) getToscaPresentationValue(JsonPresentationFields.GROUP_ARTIFACTS);
153         }
154
155         public void setArtifacts(List<String> artifacts) {
156                 setToscaPresentationValue(JsonPresentationFields.GROUP_ARTIFACTS, artifacts);
157         }
158
159         public List<String> getArtifactsUuid() {
160                 return (List<String> ) getToscaPresentationValue(JsonPresentationFields.GROUP_ARTIFACTS_UUID);
161         }
162
163         public void setArtifactsUuid(List<String> artifactsUuid) {
164                 setToscaPresentationValue(JsonPresentationFields.GROUP_ARTIFACTS_UUID, artifactsUuid);
165         }
166         
167         public List<PropertyDataDefinition> getProperties() {
168                 return (List<PropertyDataDefinition> ) getToscaPresentationValue(JsonPresentationFields.GROUP_PROPERTIES);
169         }
170
171         public void setProperties(List<PropertyDataDefinition> properties) {
172                 setToscaPresentationValue(JsonPresentationFields.GROUP_PROPERTIES, properties);
173         }
174         
175         public String getTypeUid() {
176                 return typeUid;
177         }
178
179         public void setTypeUid(String typeUid) {
180                 this.typeUid = typeUid;
181         }
182
183         @Override
184         public String toString() {
185                 return "GroupDataDefinition [propertyValueCounter=" + propertyValueCounter + ", toscaPresentation=" + toscaPresentation + ", getName()=" + getName() + ", getUniqueId()=" + getUniqueId() + ", getType()=" + getType() + ", getVersion()="
186                                 + getVersion() + ", getInvariantUUID()=" + getInvariantUUID() + ", getDescription()=" + getDescription() + ", getPropertyValueCounter()=" + getPropertyValueCounter() + ", getGroupUUID()=" + getGroupUUID() + ", getMembers()="
187                                 + getMembers() + ", getArtifacts()=" + getArtifacts() + ", getArtifactsUuid()=" + getArtifactsUuid() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()="
188                                 + super.toString() + "]";
189         }
190
191
192         public boolean containsInstanceAsMember(String instanceId) {
193                 return getMembers() != null && getMembers().values().contains(instanceId);
194         }
195 }