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.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.datatypes.elements.ProductMetadataDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.lang.reflect.Type;
29 import java.util.List;
32 public class ProductMetadataData extends ComponentMetadataData {
34 public ProductMetadataData() {
35 super(NodeTypeEnum.Product, new ProductMetadataDataDefinition());
38 public ProductMetadataData(ProductMetadataDataDefinition metadataDataDefinition) {
39 super(NodeTypeEnum.Product, metadataDataDefinition);
42 public ProductMetadataData(Map<String, Object> properties) {
43 super(NodeTypeEnum.Product, new ProductMetadataDataDefinition(), properties);
44 ((ProductMetadataDataDefinition) metadataDataDefinition)
45 .setFullName((String) properties.get(GraphPropertiesDictionary.FULL_NAME.getProperty()));
46 Type listType = new TypeToken<List<String>>() {
48 List<String> contactsfromJson = getGson()
49 .fromJson((String) properties.get(GraphPropertiesDictionary.CONTACTS.getProperty()), listType);
50 ((ProductMetadataDataDefinition) metadataDataDefinition).setContacts(contactsfromJson);
51 ((ProductMetadataDataDefinition) metadataDataDefinition)
52 .setIsActive((Boolean) properties.get(GraphPropertiesDictionary.IS_ACTIVE.getProperty()));
56 public String getUniqueIdKey() {
57 return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
61 public Map<String, Object> toGraphMap() {
62 Map<String, Object> graphMap = super.toGraphMap();
63 addIfExists(graphMap, GraphPropertiesDictionary.FULL_NAME,
64 ((ProductMetadataDataDefinition) metadataDataDefinition).getFullName());
65 addIfExists(graphMap, GraphPropertiesDictionary.CONTACTS,
66 ((ProductMetadataDataDefinition) metadataDataDefinition).getContacts());
67 addIfExists(graphMap, GraphPropertiesDictionary.IS_ACTIVE,
68 ((ProductMetadataDataDefinition) metadataDataDefinition).getIsActive());
73 public String toString() {
74 return "ProductMetadataData [metadataDataDefinition=" + metadataDataDefinition + "]";