2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.AnnotationTypeDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.util.HashMap;
31 public class AnnotationTypeData extends GraphNode {
33 private AnnotationTypeDataDefinition annotationTypeDataDefinition;
35 public AnnotationTypeData() {
36 super(NodeTypeEnum.AnnotationType);
37 annotationTypeDataDefinition = new AnnotationTypeDataDefinition();
40 public AnnotationTypeData(AnnotationTypeDataDefinition annotationTypeDataDefinition) {
41 super(NodeTypeEnum.AnnotationType);
42 this.annotationTypeDataDefinition = annotationTypeDataDefinition;
45 public AnnotationTypeData(Map<String, Object> properties) {
47 annotationTypeDataDefinition
48 .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
49 annotationTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
50 annotationTypeDataDefinition
51 .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
52 annotationTypeDataDefinition.setHighestVersion(
53 (boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
54 annotationTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
55 annotationTypeDataDefinition
56 .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
57 annotationTypeDataDefinition
58 .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
62 public String getUniqueId() {
63 return annotationTypeDataDefinition.getUniqueId();
67 public Map<String, Object> toGraphMap() {
68 Map<String, Object> map = new HashMap<>();
69 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, annotationTypeDataDefinition.getUniqueId());
70 addIfExists(map, GraphPropertiesDictionary.TYPE, annotationTypeDataDefinition.getType());
71 addIfExists(map, GraphPropertiesDictionary.VERSION, annotationTypeDataDefinition.getVersion());
72 addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, annotationTypeDataDefinition.isHighestVersion());
73 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, annotationTypeDataDefinition.getDescription());
74 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, annotationTypeDataDefinition.getCreationTime());
75 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, annotationTypeDataDefinition.getModificationTime());
79 public void setInitialCreationProperties(String uniqueId) {
80 annotationTypeDataDefinition.setUniqueId(uniqueId);
81 Long creationDate = annotationTypeDataDefinition.getCreationTime();
82 if (creationDate == null) {
83 creationDate = System.currentTimeMillis();
85 annotationTypeDataDefinition.setCreationTime(creationDate);
86 annotationTypeDataDefinition.setModificationTime(creationDate);
89 public void setUpdateProperties(AnnotationTypeDataDefinition originalDefinition) {
90 annotationTypeDataDefinition.setUniqueId(originalDefinition.getUniqueId());
91 annotationTypeDataDefinition.setCreationTime(originalDefinition.getCreationTime());
92 annotationTypeDataDefinition.setModificationTime(System.currentTimeMillis());
95 public AnnotationTypeDataDefinition getAnnotationTypeDataDefinition() {
96 return annotationTypeDataDefinition;
100 public String toString() {
101 return "AnnotationTypeData [annotationTypeDataDefinition=" + annotationTypeDataDefinition + "]";