Catalog alignment
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / ProductMetadataData.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 com.google.gson.reflect.TypeToken;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
26 import org.openecomp.sdc.be.datatypes.elements.ProductMetadataDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28
29 import java.lang.reflect.Type;
30 import java.util.List;
31 import java.util.Map;
32
33 public class ProductMetadataData extends ComponentMetadataData {
34
35         public ProductMetadataData() {
36                 super(NodeTypeEnum.Product, new ProductMetadataDataDefinition());
37         }
38
39         public ProductMetadataData(ProductMetadataDataDefinition metadataDataDefinition) {
40                 super(NodeTypeEnum.Product, metadataDataDefinition);
41         }
42
43         public ProductMetadataData(GraphPropertiesDictionaryExtractor extractor) {
44                 super(NodeTypeEnum.Product, new ProductMetadataDataDefinition(), extractor);
45                 ((ProductMetadataDataDefinition) metadataDataDefinition).setFullName(extractor.getFullName());
46                 ((ProductMetadataDataDefinition) metadataDataDefinition).setContacts(extractor.getContacts());
47                 ((ProductMetadataDataDefinition) metadataDataDefinition).setIsActive(extractor.isActive());
48         }
49
50         @Override
51         public String getUniqueIdKey() {
52                 return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
53         }
54
55         @Override
56         public Map<String, Object> toGraphMap() {
57                 Map<String, Object> graphMap = super.toGraphMap();
58                 addIfExists(graphMap, GraphPropertiesDictionary.FULL_NAME,
59                                 ((ProductMetadataDataDefinition) metadataDataDefinition).getFullName());
60                 addIfExists(graphMap, GraphPropertiesDictionary.CONTACTS,
61                                 ((ProductMetadataDataDefinition) metadataDataDefinition).getContacts());
62                 addIfExists(graphMap, GraphPropertiesDictionary.IS_ACTIVE,
63                                 ((ProductMetadataDataDefinition) metadataDataDefinition).getIsActive());
64                 return graphMap;
65         }
66
67         @Override
68         public String toString() {
69                 return "ProductMetadataData [metadataDataDefinition=" + metadataDataDefinition + "]";
70         }
71 }