re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / AttributeValueData.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.resources.data;
22
23 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.dao.utils.Constants;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
27
28 import java.util.HashMap;
29 import java.util.Map;
30 import java.util.Objects;
31
32 public class AttributeValueData extends GraphNode {
33         private String uniqueId;
34
35         private String value;
36
37         private String type;
38
39         private Boolean hidden;
40
41         private Long creationTime;
42
43         private Long modificationTime;
44
45         public AttributeValueData() {
46                 super(NodeTypeEnum.AttributeValue);
47         }
48
49         public AttributeValueData(Map<String, Object> properties) {
50                 this();
51
52                 this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
53
54                 String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
55                 if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
56                         this.setValue(null);
57                 } else {
58                         this.setValue(updatedValue);
59                 }
60
61                 this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
62
63                 this.setHidden((Boolean) properties.get(GraphPropertiesDictionary.HIDDEN.getProperty()));
64
65                 this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
66
67                 this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
68
69         }
70
71         public String getUniqueId() {
72                 return uniqueId;
73         }
74
75         public void setUniqueId(String uniqueId) {
76                 this.uniqueId = uniqueId;
77         }
78
79         public Long getCreationTime() {
80                 return creationTime;
81         }
82
83         public void setCreationTime(Long creationTime) {
84                 this.creationTime = creationTime;
85         }
86
87         public Long getModificationTime() {
88                 return modificationTime;
89         }
90
91         public void setModificationTime(Long modificationTime) {
92                 this.modificationTime = modificationTime;
93         }
94
95         @Override
96         public Map<String, Object> toGraphMap() {
97
98                 Map<String, Object> map = new HashMap<>();
99
100                 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
101
102                 addIfExists(map, GraphPropertiesDictionary.TYPE, type);
103
104                 addIfExists(map, GraphPropertiesDictionary.HIDDEN, hidden);
105
106                 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
107
108                 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
109
110                 String updatedValue = Objects.isNull(value) ? Constants.GRAPH_EMPTY_VALUE : value;
111                 addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
112                 return map;
113         }
114
115         @Override
116         public String toString() {
117                 return "AttributeValueData [uniqueId=" + uniqueId + ", hidden=" + hidden + ", type=" + type + ", creationTime="
118                                 + creationTime + ", value=" + value + ", modificationTime=" + modificationTime + "]";
119         }
120
121         public Boolean isHidden() {
122                 return hidden;
123         }
124
125         public void setHidden(Boolean hidden) {
126                 this.hidden = hidden;
127         }
128
129         public String getType() {
130                 return type;
131         }
132
133         public void setType(String type) {
134                 this.type = type;
135         }
136
137         public String getValue() {
138                 return value;
139         }
140
141         public void setValue(String value) {
142                 this.value = value;
143         }
144
145 }