re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / InputValueData.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 InputValueData 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 InputValueData() {
46                 super(NodeTypeEnum.InputValue);
47         }
48
49         public InputValueData(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         @Override
72         public String getUniqueId() {
73                 return uniqueId;
74         }
75
76         public void setUniqueId(String uniqueId) {
77                 this.uniqueId = uniqueId;
78         }
79
80         public Long getCreationTime() {
81                 return creationTime;
82         }
83
84         public void setCreationTime(Long creationTime) {
85                 this.creationTime = creationTime;
86         }
87
88         public Long getModificationTime() {
89                 return modificationTime;
90         }
91
92         public void setModificationTime(Long modificationTime) {
93                 this.modificationTime = modificationTime;
94         }
95
96         @Override
97         public Map<String, Object> toGraphMap() {
98
99                 Map<String, Object> map = new HashMap<>();
100
101                 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
102
103                 addIfExists(map, GraphPropertiesDictionary.TYPE, type);
104
105                 addIfExists(map, GraphPropertiesDictionary.HIDDEN, hidden);
106
107                 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
108
109                 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
110
111                 String updatedValue = Objects.isNull(value) ? Constants.GRAPH_EMPTY_VALUE : value;
112                 addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
113                 return map;
114         }
115
116         @Override
117         public String toString() {
118                 return "InputValueData [uniqueId=" + uniqueId + ", hidden=" + hidden + ", type=" + type + ", creationTime="
119                                 + creationTime + ", value=" + value + ", modificationTime=" + modificationTime + "]";
120         }
121
122         public Boolean isHidden() {
123                 return hidden;
124         }
125
126         public void setHidden(Boolean hidden) {
127                 this.hidden = hidden;
128         }
129
130         public String getType() {
131                 return type;
132         }
133
134         public void setType(String type) {
135                 this.type = type;
136         }
137
138         public String getValue() {
139                 return value;
140         }
141
142         public void setValue(String value) {
143                 this.value = value;
144         }
145
146 }