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;
25 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
26 import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
27 import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
28 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
29 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
31 public class ResourceMetadataData extends ComponentMetadataData {
33 public ResourceMetadataData() {
34 super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition());
37 public ResourceMetadataData(ComponentMetadataDataDefinition metadataDataDefinition) {
38 super(NodeTypeEnum.Resource, metadataDataDefinition);
41 public ResourceMetadataData(Map<String, Object> properties) {
42 super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition(), properties);
43 ((ResourceMetadataDataDefinition) metadataDataDefinition)
44 .setVendorName((String) properties.get(GraphPropertiesDictionary.VENDOR_NAME.getProperty()));
45 ((ResourceMetadataDataDefinition) metadataDataDefinition)
46 .setVendorRelease((String) properties.get(GraphPropertiesDictionary.VENDOR_RELEASE.getProperty()));
47 ((ResourceMetadataDataDefinition) metadataDataDefinition).setResourceType(ResourceTypeEnum
48 .valueOf((String) properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty())));
49 ((ResourceMetadataDataDefinition) metadataDataDefinition)
50 .setAbstract((Boolean) properties.get(GraphPropertiesDictionary.IS_ABSTRACT.getProperty()));
51 ((ResourceMetadataDataDefinition) metadataDataDefinition)
52 .setCost((String) properties.get(GraphPropertiesDictionary.COST.getProperty()));
53 ((ResourceMetadataDataDefinition) metadataDataDefinition)
54 .setLicenseType((String) properties.get(GraphPropertiesDictionary.LICENSE_TYPE.getProperty()));
55 ((ResourceMetadataDataDefinition) metadataDataDefinition).setToscaResourceName(
56 (String) properties.get(GraphPropertiesDictionary.TOSCA_RESOURCE_NAME.getProperty()));
61 public Map<String, Object> toGraphMap() {
62 Map<String, Object> graphMap = super.toGraphMap();
63 addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_NAME,
64 ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorName());
65 addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_RELEASE,
66 ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorRelease());
67 addIfExists(graphMap, GraphPropertiesDictionary.RESOURCE_TYPE,
68 ((ResourceMetadataDataDefinition) metadataDataDefinition).getResourceType().name());
69 addIfExists(graphMap, GraphPropertiesDictionary.IS_ABSTRACT,
70 ((ResourceMetadataDataDefinition) metadataDataDefinition).isAbstract());
71 addIfExists(graphMap, GraphPropertiesDictionary.COST,
72 ((ResourceMetadataDataDefinition) metadataDataDefinition).getCost());
73 addIfExists(graphMap, GraphPropertiesDictionary.LICENSE_TYPE,
74 ((ResourceMetadataDataDefinition) metadataDataDefinition).getLicenseType());
75 addIfExists(graphMap, GraphPropertiesDictionary.TOSCA_RESOURCE_NAME,
76 ((ResourceMetadataDataDefinition) metadataDataDefinition).getToscaResourceName());