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=========================================================
20 package org.openecomp.sdc.be.resources.data;
22 import java.util.HashMap;
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.elements.DataTypeDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
29 public class DataTypeData extends GraphNode {
31 DataTypeDataDefinition dataTypeDataDefinition;
33 public DataTypeData() {
34 super(NodeTypeEnum.DataType);
35 dataTypeDataDefinition = new DataTypeDataDefinition();
38 public DataTypeData(DataTypeDataDefinition dataTypeDataDefinition) {
39 super(NodeTypeEnum.DataType);
40 this.dataTypeDataDefinition = dataTypeDataDefinition;
41 // this.constraints = constraints;
44 public DataTypeData(Map<String, Object> properties) {
46 dataTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
47 dataTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
48 dataTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
49 dataTypeDataDefinition.setDerivedFromName((String) properties.get(GraphPropertiesDictionary.DERIVED_FROM.getProperty()));
50 dataTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
51 dataTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
52 dataTypeDataDefinition.setModel((String) properties.get(GraphPropertiesDictionary.MODEL.getProperty()));
56 public Map<String, Object> toGraphMap() {
57 Map<String, Object> map = new HashMap<>();
58 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, dataTypeDataDefinition.getUniqueId());
59 addIfExists(map, GraphPropertiesDictionary.NAME, dataTypeDataDefinition.getName());
60 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, dataTypeDataDefinition.getDescription());
61 addIfExists(map, GraphPropertiesDictionary.DERIVED_FROM, dataTypeDataDefinition.getDerivedFromName());
62 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, dataTypeDataDefinition.getCreationTime());
63 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, dataTypeDataDefinition.getModificationTime());
64 addIfExists(map, GraphPropertiesDictionary.MODEL, dataTypeDataDefinition.getModel());
68 public DataTypeDataDefinition getDataTypeDataDefinition() {
69 return dataTypeDataDefinition;
72 public void setDataTypeDataDefinition(DataTypeDataDefinition dataTypeDataDefinition) {
73 this.dataTypeDataDefinition = dataTypeDataDefinition;
77 public String toString() {
78 return "DataTypeData [dataTypeDataDefinition=" + dataTypeDataDefinition + "]";
82 public String getUniqueId() {
83 return this.dataTypeDataDefinition.getUniqueId();