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.GroupInstanceDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.util.HashMap;
32 public class GroupInstanceData extends GraphNode {
34 GroupInstanceDataDefinition groupDataDefinition;
36 public GroupInstanceData() {
37 super(NodeTypeEnum.GroupInstance);
38 this.groupDataDefinition = new GroupInstanceDataDefinition();
41 public GroupInstanceData(GroupInstanceDataDefinition groupDataDefinition) {
42 super(NodeTypeEnum.GroupInstance);
43 this.groupDataDefinition = groupDataDefinition;
46 public GroupInstanceData(Map<String, Object> properties) {
51 .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
53 .setGroupUid((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
55 .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
57 .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
60 .setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
62 .setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
63 groupDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
64 groupDataDefinition.setPropertyValueCounter(
65 (Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
68 .setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
71 .setCustomizationUUID((String) properties.get(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty()));
75 public Map<String, Object> toGraphMap() {
77 Map<String, Object> map = new HashMap<>();
79 addIfExists(map, GraphPropertiesDictionary.TYPE, groupDataDefinition.getGroupUid());
80 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, groupDataDefinition.getCreationTime());
81 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, groupDataDefinition.getModificationTime());
83 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupDataDefinition.getUniqueId());
84 addIfExists(map, GraphPropertiesDictionary.POSITION_X, groupDataDefinition.getPosX());
85 addIfExists(map, GraphPropertiesDictionary.POSITION_Y, groupDataDefinition.getPosY());
86 addIfExists(map, GraphPropertiesDictionary.NAME, groupDataDefinition.getName());
87 addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER,
88 groupDataDefinition.getPropertyValueCounter());
90 addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, groupDataDefinition.getNormalizedName());
92 addIfExists(map, GraphPropertiesDictionary.CUSTOMIZATION_UUID, groupDataDefinition.getCustomizationUUID());
98 public String getUniqueId() {
99 return groupDataDefinition.getUniqueId();
102 public String getName() {
103 return groupDataDefinition.getName();
107 public String getUniqueIdKey() {
108 return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
111 public GroupInstanceDataDefinition getGroupDataDefinition() {
112 return groupDataDefinition;
115 public void setComponentInstDataDefinition(GroupInstanceDataDefinition groupDataDefinition) {
116 this.groupDataDefinition = groupDataDefinition;
120 public String toString() {
121 return "GroupInstanceData [groupInstDataDefinition=" + groupDataDefinition + "]";