re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / GroupInstanceData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.resources.data;
22
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;
27
28 import java.util.HashMap;
29 import java.util.Map;
30
31
32 public class GroupInstanceData extends GraphNode {
33         
34         GroupInstanceDataDefinition groupDataDefinition;
35
36         public GroupInstanceData() {
37                 super(NodeTypeEnum.GroupInstance);
38                 this.groupDataDefinition = new GroupInstanceDataDefinition();
39         }
40
41         public GroupInstanceData(GroupInstanceDataDefinition groupDataDefinition) {
42                 super(NodeTypeEnum.GroupInstance);
43                 this.groupDataDefinition = groupDataDefinition;
44         }
45
46         public GroupInstanceData(Map<String, Object> properties) {
47
48                 this();
49
50                 groupDataDefinition
51                                 .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
52                 groupDataDefinition
53                                 .setGroupUid((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
54                 groupDataDefinition
55                                 .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
56                 groupDataDefinition
57                                 .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
58                 
59                 groupDataDefinition
60                                 .setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
61                 groupDataDefinition
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()));
66                 
67                 groupDataDefinition
68                                 .setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
69                 
70                 groupDataDefinition
71                 .setCustomizationUUID((String) properties.get(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty()));
72         }
73
74         @Override
75         public Map<String, Object> toGraphMap() {
76
77                 Map<String, Object> map = new HashMap<>();
78
79                 addIfExists(map, GraphPropertiesDictionary.TYPE, groupDataDefinition.getGroupUid());
80                 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, groupDataDefinition.getCreationTime());
81                 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, groupDataDefinition.getModificationTime());
82                 
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());
89                 
90                 addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, groupDataDefinition.getNormalizedName());
91                 
92                 addIfExists(map, GraphPropertiesDictionary.CUSTOMIZATION_UUID, groupDataDefinition.getCustomizationUUID());
93
94                 return map;
95         }
96
97         @Override
98         public String getUniqueId() {
99                 return groupDataDefinition.getUniqueId();
100         }
101
102         public String getName() {
103                 return groupDataDefinition.getName();
104         }
105
106         @Override
107         public String getUniqueIdKey() {
108                 return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
109         }
110
111         public GroupInstanceDataDefinition getGroupDataDefinition() {
112                 return groupDataDefinition;
113         }
114
115         public void setComponentInstDataDefinition(GroupInstanceDataDefinition groupDataDefinition) {
116                 this.groupDataDefinition = groupDataDefinition;
117         }
118
119         @Override
120         public String toString() {
121                 return "GroupInstanceData [groupInstDataDefinition=" + groupDataDefinition + "]";
122         }
123
124
125 }