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()));
53 final Object normativeProperty = properties.get(GraphPropertiesDictionary.NORMATIVE.getProperty());
54 final boolean normative = normativeProperty != null && (boolean) normativeProperty;
55 dataTypeDataDefinition.setNormative(normative);
59 public Map<String, Object> toGraphMap() {
60 Map<String, Object> map = new HashMap<>();
61 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, dataTypeDataDefinition.getUniqueId());
62 addIfExists(map, GraphPropertiesDictionary.NAME, dataTypeDataDefinition.getName());
63 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, dataTypeDataDefinition.getDescription());
64 addIfExists(map, GraphPropertiesDictionary.DERIVED_FROM, dataTypeDataDefinition.getDerivedFromName());
65 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, dataTypeDataDefinition.getCreationTime());
66 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, dataTypeDataDefinition.getModificationTime());
67 addIfExists(map, GraphPropertiesDictionary.MODEL, dataTypeDataDefinition.getModel());
68 addIfExists(map, GraphPropertiesDictionary.NORMATIVE, dataTypeDataDefinition.isNormative());
72 public DataTypeDataDefinition getDataTypeDataDefinition() {
73 return dataTypeDataDefinition;
76 public void setDataTypeDataDefinition(DataTypeDataDefinition dataTypeDataDefinition) {
77 this.dataTypeDataDefinition = dataTypeDataDefinition;
81 public String toString() {
82 return "DataTypeData [dataTypeDataDefinition=" + dataTypeDataDefinition + "]";
86 public String getUniqueId() {
87 return this.dataTypeDataDefinition.getUniqueId();