re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / HeatParameterValueData.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
31 public class HeatParameterValueData extends GraphNode {
32
33         public HeatParameterValueData() {
34                 super(NodeTypeEnum.HeatParameterValue);
35         }
36
37         public HeatParameterValueData(Map<String, Object> properties) {
38                 this();
39
40                 this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
41                 String value = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
42                 if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
43                         this.setValue(null);
44                 } else {
45                         this.setValue(value);
46                 }
47
48         }
49
50         private String uniqueId;
51
52         private String value;
53
54         @Override
55         public String getUniqueId() {
56                 return uniqueId;
57         }
58
59         public String getValue() {
60                 return value;
61         }
62
63         public void setValue(String value) {
64                 this.value = value;
65         }
66
67         public void setUniqueId(String uniqueId) {
68                 this.uniqueId = uniqueId;
69         }
70
71         @Override
72         public Map<String, Object> toGraphMap() {
73                 Map<String, Object> map = new HashMap<>();
74
75                 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
76
77                 String updatedValue = value;
78                 if (updatedValue == null) {
79                         updatedValue = Constants.GRAPH_EMPTY_VALUE;
80                 }
81                 addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
82
83                 return map;
84         }
85
86         @Override
87         public String toString() {
88                 return "HeatParameterValueData [uniqueId=" + uniqueId + ", value=" + value + "]";
89         }
90
91 }