Reformat catalog-dao
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / CategoryData.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 package org.openecomp.sdc.be.resources.data;
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
25 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
27
28 public abstract class CategoryData extends GraphNode {
29
30     private String name;
31     private String normalizedName;
32     private String uniqueId;
33
34     protected CategoryData(NodeTypeEnum label) {
35         super(label);
36     }
37
38     protected CategoryData(String name, String normalizedName, NodeTypeEnum label) {
39         super(label);
40         this.name = name;
41         this.normalizedName = normalizedName;
42     }
43
44     protected CategoryData(Map<String, Object> properties, NodeTypeEnum label) {
45         super(label);
46         setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
47         setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
48         setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
49     }
50
51     protected abstract void createUniqueId();
52
53     @Override
54     public Map<String, Object> toGraphMap() {
55         Map<String, Object> map = new HashMap<>();
56         addIfExists(map, GraphPropertiesDictionary.NAME, name);
57         addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
58         addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, normalizedName);
59         return map;
60     }
61
62     public String getName() {
63         return name;
64     }
65
66     public void setName(String name) {
67         this.name = name;
68     }
69
70     public String getNormalizedName() {
71         return normalizedName;
72     }
73
74     public void setNormalizedName(String normalizedName) {
75         this.normalizedName = normalizedName;
76     }
77
78     @Override
79     public String toString() {
80         return "CategoryData [name=" + name + ", normalizedName=" + normalizedName + "uniqueId=" + uniqueId + "]";
81     }
82
83     @Override
84     public String getUniqueIdKey() {
85         return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
86     }
87
88     @Override
89     public String getUniqueId() {
90         return uniqueId;
91     }
92
93     public void setUniqueId(String uniqueId) {
94         this.uniqueId = uniqueId;
95     }
96 }