2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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.dao.neo4j;
23 import com.google.gson.Gson;
24 import com.google.gson.reflect.TypeToken;
25 import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
27 import org.springframework.beans.factory.annotation.Autowired;
29 import java.lang.reflect.Type;
30 import java.util.List;
33 public class GraphPropertiesDictionaryExtractor {
35 private Map<String, Object> properties;
37 private Gson gson = new Gson();
39 public GraphPropertiesDictionaryExtractor(Map<String, Object> properties) {
40 this.properties = properties;
43 public String getUniqueId() {
44 return (String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
47 public String getName() {
48 return (String) properties.get(GraphPropertiesDictionary.NAME.getProperty());
51 public String getVersion() {
52 return (String) properties.get(GraphPropertiesDictionary.VERSION.getProperty());
55 public Boolean isHighestVersion() {
56 return (Boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty());
59 public Long getCreationDate() {
60 return (Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty());
63 public Long getLastUpdateDate() {
64 return (Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty());
67 public String getDescription() {
68 return (String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty());
71 public String getConformanceLevel() {
72 return (String) properties.get(GraphPropertiesDictionary.CONFORMANCE_LEVEL.getProperty());
75 @SuppressWarnings("unchecked")
76 public List<String> getTags() {
77 List<String> tagsFromJson;
78 if(properties.get(GraphPropertiesDictionary.TAGS.getProperty()) instanceof List<?>){
79 tagsFromJson = (List<String>) properties.get(GraphPropertiesDictionary.TAGS.getProperty());
81 Type listType = new TypeToken<List<String>>() {}.getType();
82 tagsFromJson = gson.fromJson((String) properties.get(GraphPropertiesDictionary.TAGS.getProperty()), listType);
87 public String getIcon() {
88 return (String) properties.get(GraphPropertiesDictionary.ICON.getProperty());
91 public String getState() {
92 return (String) properties.get(GraphPropertiesDictionary.STATE.getProperty());
95 public String getContactId() {
96 return (String) properties.get(GraphPropertiesDictionary.CONTACT_ID.getProperty());
99 public String getUUID() {
100 return (String) properties.get(GraphPropertiesDictionary.UUID.getProperty());
103 public String getNormalizedName() {
104 return (String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty());
107 public String getSystemName() {
108 return (String) properties.get(GraphPropertiesDictionary.SYSTEM_NAME.getProperty());
111 public Boolean isDeleted() {
112 return (Boolean) properties.get(GraphPropertiesDictionary.IS_DELETED.getProperty());
115 public String getProjectCode() {
116 return (String) properties.get(GraphPropertiesDictionary.PROJECT_CODE.getProperty());
119 public String getCsarUuid() {
120 return (String) properties.get(GraphPropertiesDictionary.CSAR_UUID.getProperty());
123 public String getCsarVersion() {
124 return (String) properties.get(GraphPropertiesDictionary.CSAR_VERSION.getProperty());
127 public String getImportedToscaChecksum() {
128 return (String) properties.get(GraphPropertiesDictionary.IMPORTED_TOSCA_CHECKSUM.getProperty());
131 public String getInvariantUuid() {
132 return (String) properties.get(GraphPropertiesDictionary.INVARIANT_UUID.getProperty());
135 public String getVendorName() {
136 return (String) properties.get(GraphPropertiesDictionary.VENDOR_NAME.getProperty());
139 public String getVendorRelease() {
140 return (String) properties.get(GraphPropertiesDictionary.VENDOR_RELEASE.getProperty());
143 public Boolean isAbstract() {
144 return (Boolean) properties.get(GraphPropertiesDictionary.IS_ABSTRACT.getProperty());
147 public ResourceTypeEnum getResourceType() {
148 if (properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()) != null) {
149 return ResourceTypeEnum.valueOf((String) properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()));
155 public String getToscaResourceName() {
156 return (String) properties.get(GraphPropertiesDictionary.TOSCA_RESOURCE_NAME.getProperty());
159 public Integer getInstanceCounter() {
160 return (Integer) properties.get(GraphPropertiesDictionary.INSTANCE_COUNTER.getProperty());
163 public String getCost() {
164 return (String) properties.get(GraphPropertiesDictionary.COST.getProperty());
167 public String getLicenseType() {
168 return (String) properties.get(GraphPropertiesDictionary.LICENSE_TYPE.getProperty());
171 public String getDistributionStatus() {
172 return (String) properties.get(GraphPropertiesDictionary.DISTRIBUTION_STATUS.getProperty());
175 public String getFullName() {
176 return (String) properties.get(GraphPropertiesDictionary.FULL_NAME.getProperty());
179 public List<String> getContacts() {
180 Type listType = new TypeToken<List<String>>() {}.getType();
181 return gson.fromJson((String) properties.get(GraphPropertiesDictionary.CONTACTS.getProperty()), listType);
184 public Boolean isActive() {
185 return (Boolean) properties.get(GraphPropertiesDictionary.IS_ACTIVE.getProperty());