2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.resources.data;
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.datatypes.enums.NodeTypeEnum;
27 import java.util.HashMap;
30 public abstract class CategoryData extends GraphNode {
33 private String normalizedName;
34 private String uniqueId;
36 protected abstract void createUniqueId();
38 protected CategoryData(NodeTypeEnum label) {
42 protected CategoryData(String name, String normalizedName, NodeTypeEnum label) {
45 this.normalizedName = normalizedName;
48 protected CategoryData(Map<String, Object> properties, NodeTypeEnum label) {
50 setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
51 setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
52 setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
56 public Map<String, Object> toGraphMap() {
57 Map<String, Object> map = new HashMap<String, Object>();
58 addIfExists(map, GraphPropertiesDictionary.NAME, name);
59 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
60 addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, normalizedName);
64 public String getName() {
68 public void setName(String name) {
72 public String getNormalizedName() {
73 return normalizedName;
76 public void setNormalizedName(String normalizedName) {
77 this.normalizedName = normalizedName;
80 public void setUniqueId(String uniqueId) {
81 this.uniqueId = uniqueId;
85 public String toString() {
86 return "CategoryData [name=" + name + ", normalizedName=" + normalizedName + "uniqueId=" + uniqueId + "]";
90 * @Override public int hashCode() { final int prime = 31; int result = 1;
91 * result = prime * result + ((name == null) ? 0 : name.hashCode()); result
92 * = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode()); return
95 * @Override public boolean equals(Object obj) { if (this == obj) return
96 * true; if (obj == null) return false; if (getClass() != obj.getClass())
97 * return false; CategoryData other = (CategoryData) obj; if (name == null)
98 * { if (other.name != null) return false; } else if
99 * (!name.equals(other.name)) return false; if (uniqueId == null) { if
100 * (other.uniqueId != null) return false; } else if
101 * (!uniqueId.equals(other.uniqueId)) return false; return true; }
105 public String getUniqueIdKey() {
106 return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
110 public String getUniqueId() {