1b5f948c1c10883fda6feeac4cbccb20ef275eb4
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / ResourceMetadataData.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 package org.openecomp.sdc.be.resources.data;
21
22 import java.util.Map;
23 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
25 import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
26 import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28
29 public class ResourceMetadataData extends ComponentMetadataData {
30
31     public ResourceMetadataData() {
32         super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition());
33     }
34
35     public ResourceMetadataData(ComponentMetadataDataDefinition metadataDataDefinition) {
36         super(NodeTypeEnum.Resource, metadataDataDefinition);
37     }
38
39     public ResourceMetadataData(final GraphPropertiesDictionaryExtractor extractor) {
40         super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition(), extractor);
41         final var resourceMetadataDataDefinition = (ResourceMetadataDataDefinition) metadataDataDefinition;
42         resourceMetadataDataDefinition.setVendorName(extractor.getVendorName());
43         resourceMetadataDataDefinition.setVendorRelease(extractor.getVendorRelease());
44         resourceMetadataDataDefinition.setResourceType(extractor.getResourceType());
45         resourceMetadataDataDefinition.setAbstract(extractor.isAbstract());
46         resourceMetadataDataDefinition.setCost(extractor.getCost());
47         resourceMetadataDataDefinition.setLicenseType(extractor.getLicenseType());
48         resourceMetadataDataDefinition.setToscaResourceName(extractor.getToscaResourceName());
49         resourceMetadataDataDefinition.setCsarVersionId(extractor.getCsarVersionId());
50     }
51
52     @Override
53     public Map<String, Object> toGraphMap() {
54         final Map<String, Object> graphMap = super.toGraphMap();
55         final ResourceMetadataDataDefinition resourceMetadataDataDefinition = (ResourceMetadataDataDefinition) metadataDataDefinition;
56         addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_NAME, resourceMetadataDataDefinition.getVendorName());
57         addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_RELEASE, resourceMetadataDataDefinition.getVendorRelease());
58         addIfExists(graphMap, GraphPropertiesDictionary.RESOURCE_TYPE, resourceMetadataDataDefinition.getResourceType().name());
59         addIfExists(graphMap, GraphPropertiesDictionary.IS_ABSTRACT, resourceMetadataDataDefinition.isAbstract());
60         addIfExists(graphMap, GraphPropertiesDictionary.COST, resourceMetadataDataDefinition.getCost());
61         addIfExists(graphMap, GraphPropertiesDictionary.LICENSE_TYPE, resourceMetadataDataDefinition.getLicenseType());
62         addIfExists(graphMap, GraphPropertiesDictionary.TOSCA_RESOURCE_NAME, resourceMetadataDataDefinition.getToscaResourceName());
63         addIfExists(graphMap, GraphPropertiesDictionary.CSAR_VERSION_ID, resourceMetadataDataDefinition.getCsarVersionId());
64         return graphMap;
65     }
66 }