7e9941822196d52ce725bfdbf297f26b1bd385ca
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / AttributeDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2020, Nordix Foundation. 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 package org.openecomp.sdc.be.datatypes.elements;
21
22 import java.util.ArrayList;
23 import java.util.List;
24 import lombok.Getter;
25 import lombok.NoArgsConstructor;
26 import lombok.Setter;
27 import org.apache.commons.collections.CollectionUtils;
28 import org.onap.sdc.tosca.datatypes.model.EntrySchema;
29 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
30 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
31
32 @Getter
33 @Setter
34 @NoArgsConstructor
35 public class AttributeDataDefinition extends ToscaDataDefinition {
36
37     private transient List<GetOutputValueDataDefinition> getOutputValues;
38     private String outputId;
39     private String value;
40     private String outputPath;
41     private String instanceUniqueId;
42     private String attributeId;
43     private String model;
44     private String parentUniqueId;
45
46     public AttributeDataDefinition(final AttributeDataDefinition attributeDataDefinition) {
47         super();
48         this.setUniqueId(attributeDataDefinition.getUniqueId());
49         this.setOwnerId(attributeDataDefinition.getOwnerId());
50         this.setName(attributeDataDefinition.getName());
51         this.setType(attributeDataDefinition.getType());
52         this.setDescription(attributeDataDefinition.getDescription());
53         this.set_default(attributeDataDefinition.get_default());
54         this.setValue(attributeDataDefinition.getValue());
55         this.setStatus(attributeDataDefinition.getStatus());
56         this.setEntry_schema(attributeDataDefinition.getEntry_schema());
57         this.setSchema(attributeDataDefinition.getSchema());
58         this.setOutputPath(attributeDataDefinition.getOutputPath());
59         this.setInstanceUniqueId(attributeDataDefinition.getInstanceUniqueId());
60         this.setAttributeId(attributeDataDefinition.getAttributeId());
61         this.setModel(attributeDataDefinition.getModel());
62         this.setParentUniqueId(attributeDataDefinition.getParentUniqueId());
63         this.setOutputId(attributeDataDefinition.getOutputId());
64         if (CollectionUtils.isNotEmpty(attributeDataDefinition.getGetOutputValues())) {
65             this.getOutputValues = new ArrayList<>(attributeDataDefinition.getGetOutputValues());
66         }
67     }
68
69     public String getUniqueId() {
70         return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
71     }
72
73     public void setUniqueId(final String uniqueId) {
74         setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
75     }
76
77     @Override
78     public String getOwnerId() {
79         return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
80     }
81
82     @Override
83     public void setOwnerId(final String ownerId) {
84         setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
85     }
86
87     public String getName() {
88         return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
89     }
90
91     public void setName(final String name) {
92         setToscaPresentationValue(JsonPresentationFields.NAME, name);
93     }
94
95     @Override
96     public String getType() {
97         return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
98     }
99
100     public String getDescription() {
101         return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
102     }
103
104     public void setDescription(final String description) {
105         setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
106     }
107
108     public Object get_default() {
109         return getToscaPresentationValue(JsonPresentationFields.DEFAULT);
110     }
111
112     public void set_default(final Object _default) {
113         setToscaPresentationValue(JsonPresentationFields.DEFAULT, _default);
114     }
115
116     public String getStatus() {
117         return (String) getToscaPresentationValue(JsonPresentationFields.STATUS);
118     }
119
120     public void setStatus(final String status) {
121         setToscaPresentationValue(JsonPresentationFields.STATUS, status);
122     }
123
124     public EntrySchema getEntry_schema() {
125         return (EntrySchema) getToscaPresentationValue(JsonPresentationFields.ENTRY_SCHEMA);
126     }
127
128     public void setEntry_schema(final EntrySchema entrySchema) {
129         setToscaPresentationValue(JsonPresentationFields.ENTRY_SCHEMA, entrySchema);
130     }
131
132     public SchemaDefinition getSchema() {
133         return (SchemaDefinition) getToscaPresentationValue(JsonPresentationFields.SCHEMA);
134     }
135
136     public void setSchema(final SchemaDefinition schema) {
137         setToscaPresentationValue(JsonPresentationFields.SCHEMA, schema);
138     }
139
140     public String getParentUniqueId() {
141         return getOwnerId();
142     }
143
144     public boolean isGetOutputAttribute() {
145         return this.getGetOutputValues() != null && !this.getGetOutputValues().isEmpty();
146     }
147
148     public boolean typeEquals(Object obj) {
149         if (this == obj) {
150             return true;
151         }
152         if (obj == null) {
153             return false;
154         }
155         if (getClass() != obj.getClass()) {
156             return false;
157         }
158         AttributeDataDefinition other = (AttributeDataDefinition) obj;
159         if (this.getType() == null) {
160             return other.getType() == null;
161         }
162         return false;
163     }
164
165 }