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.elements.AdditionalInfoParameterDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
29 import java.lang.reflect.Type;
30 import java.util.HashMap;
33 public class AdditionalInfoParameterData extends GraphNode {
35 AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition;
37 private Map<String, String> parameters;
39 private Map<String, String> idToKey;
41 public AdditionalInfoParameterData() {
42 super(NodeTypeEnum.AdditionalInfoParameters);
43 additionalInfoParameterDataDefinition = new AdditionalInfoParameterDataDefinition();
46 public AdditionalInfoParameterData(AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition,
47 Map<String, String> parameters, Map<String, String> idToKey) {
48 super(NodeTypeEnum.AdditionalInfoParameters);
49 this.additionalInfoParameterDataDefinition = additionalInfoParameterDataDefinition;
50 this.parameters = parameters;
51 this.idToKey = idToKey;
54 public AdditionalInfoParameterData(Map<String, Object> properties) {
58 additionalInfoParameterDataDefinition
59 .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
61 additionalInfoParameterDataDefinition
62 .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
64 additionalInfoParameterDataDefinition
65 .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
67 additionalInfoParameterDataDefinition.setLastCreatedCounter(
68 (Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
69 Type mapType = new TypeToken<HashMap<String, String>>() {
71 HashMap<String, String> prametersfromJson = getGson().fromJson(
72 (String) properties.get(GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS.getProperty()), mapType);
74 this.setParameters(prametersfromJson);
76 // this.setParameters((HashMap<String, String>) properties
77 // .get(GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS
80 HashMap<String, String> idToKeyfromJson = getGson().fromJson(
81 (String) properties.get(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty()), mapType);
83 this.setIdToKey(idToKeyfromJson);
84 // this.setIdToKey((HashMap<String, String>) properties
85 // .get(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY
90 public Map<String, Object> toGraphMap() {
92 Map<String, Object> map = new HashMap<String, Object>();
94 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, additionalInfoParameterDataDefinition.getUniqueId());
96 // String parametersToJson = getGson().toJson(getParameters());
98 // addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS,
100 addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS, getParameters());
102 // String idToKeyToJson = getGson().toJson(getIdToKey());
103 // addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY,
105 addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY, getIdToKey());
107 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE,
108 additionalInfoParameterDataDefinition.getCreationTime());
110 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE,
111 additionalInfoParameterDataDefinition.getModificationTime());
113 addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER,
114 additionalInfoParameterDataDefinition.getLastCreatedCounter());
120 public String getUniqueId() {
121 return additionalInfoParameterDataDefinition.getUniqueId();
124 public AdditionalInfoParameterDataDefinition getAdditionalInfoParameterDataDefinition() {
125 return additionalInfoParameterDataDefinition;
128 public void setAdditionalInfoParameterDataDefinition(
129 AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition) {
130 this.additionalInfoParameterDataDefinition = additionalInfoParameterDataDefinition;
133 public Map<String, String> getParameters() {
137 public void setParameters(Map<String, String> parameters) {
138 this.parameters = parameters;
141 public Map<String, String> getIdToKey() {
145 public void setIdToKey(Map<String, String> idToKey) {
146 this.idToKey = idToKey;
150 public String toString() {
151 return "PropertyData [parameters= " + parameters + " idToKey= " + idToKey
152 + ", additionalInfoParameterDataDefinition=" + additionalInfoParameterDataDefinition + "]";