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 com.google.gson.reflect.TypeToken;
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.enums.NodeTypeEnum;
28 import java.lang.reflect.Type;
29 import java.util.HashMap;
30 import java.util.List;
33 public class CapabilityInstData extends GraphNode {
35 public CapabilityInstData() {
36 super(NodeTypeEnum.CapabilityInst);
39 public CapabilityInstData(Map<String, Object> properties) {
42 this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
44 Type listType = new TypeToken<List<String>>() {
46 List<String> propertiesfromJson = getGson()
47 .fromJson((String) properties.get(GraphPropertiesDictionary.PROPERTIES.getProperty()), listType);
49 this.setProperties(propertiesfromJson);
51 // this.setProperties((ArrayList<String>) properties
52 // .get(GraphPropertiesDictionary.PROPERTIES.getProperty()));
54 this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
56 this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
59 private String uniqueId;
61 private List<String> properties;
63 private Long creationTime;
65 private Long modificationTime;
68 public String getUniqueId() {
72 public void setUniqueId(String uniqueId) {
73 this.uniqueId = uniqueId;
76 public Long getCreationTime() {
80 public void setCreationTime(Long creationTime) {
81 this.creationTime = creationTime;
84 public Long getModificationTime() {
85 return modificationTime;
88 public void setModificationTime(Long modificationTime) {
89 this.modificationTime = modificationTime;
92 public List<String> getProperties() {
96 public void setProperties(List<String> properties) {
97 this.properties = properties;
101 public Map<String, Object> toGraphMap() {
103 Map<String, Object> map = new HashMap<>();
105 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
107 // String propertiesToJson = getGson().toJson(properties);
109 // addIfExists(map, GraphPropertiesDictionary.PROPERTIES,
110 // propertiesToJson);
112 addIfExists(map, GraphPropertiesDictionary.PROPERTIES, properties);
114 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
116 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
122 public String toString() {
123 return "CapabilityInstData [uniqueId=" + uniqueId + ", properties=" + properties + ", creationTime="
124 + creationTime + ", modificationTime=" + modificationTime + "]";