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.elements.DataTypeDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.util.HashMap;
31 public class DataTypeData extends GraphNode {
33 DataTypeDataDefinition dataTypeDataDefinition;
35 public DataTypeData() {
36 super(NodeTypeEnum.DataType);
37 dataTypeDataDefinition = new DataTypeDataDefinition();
40 public DataTypeData(DataTypeDataDefinition dataTypeDataDefinition) {
41 super(NodeTypeEnum.DataType);
42 this.dataTypeDataDefinition = dataTypeDataDefinition;
43 // this.constraints = constraints;
46 public DataTypeData(Map<String, Object> properties) {
50 dataTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
52 dataTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
54 dataTypeDataDefinition
55 .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
57 dataTypeDataDefinition
58 .setDerivedFromName((String) properties.get(GraphPropertiesDictionary.DERIVED_FROM.getProperty()));
60 dataTypeDataDefinition
61 .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
63 dataTypeDataDefinition
64 .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
69 public Map<String, Object> toGraphMap() {
71 Map<String, Object> map = new HashMap<>();
73 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, dataTypeDataDefinition.getUniqueId());
75 addIfExists(map, GraphPropertiesDictionary.NAME, dataTypeDataDefinition.getName());
77 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, dataTypeDataDefinition.getDescription());
79 addIfExists(map, GraphPropertiesDictionary.DERIVED_FROM, dataTypeDataDefinition.getDerivedFromName());
81 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, dataTypeDataDefinition.getCreationTime());
83 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, dataTypeDataDefinition.getModificationTime());
88 public DataTypeDataDefinition getDataTypeDataDefinition() {
89 return dataTypeDataDefinition;
92 public void setDataTypeDataDefinition(DataTypeDataDefinition dataTypeDataDefinition) {
93 this.dataTypeDataDefinition = dataTypeDataDefinition;
97 public String toString() {
98 return "DataTypeData [dataTypeDataDefinition=" + dataTypeDataDefinition + "]";
102 public String getUniqueId() {
103 return this.dataTypeDataDefinition.getUniqueId();