Catalog alignment
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / dao / neo4j / GraphPropertiesDictionaryExtractor.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
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.dao.neo4j;
22
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;
28
29 import java.lang.reflect.Type;
30 import java.util.List;
31 import java.util.Map;
32
33 public class GraphPropertiesDictionaryExtractor {
34
35     private Map<String, Object> properties;
36
37     private Gson gson = new Gson();
38
39     public GraphPropertiesDictionaryExtractor(Map<String, Object> properties) {
40         this.properties = properties;
41     }
42
43     public String getUniqueId() {
44         return (String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
45     }
46
47     public String getName() {
48         return (String) properties.get(GraphPropertiesDictionary.NAME.getProperty());
49     }
50
51     public String getVersion() {
52         return (String) properties.get(GraphPropertiesDictionary.VERSION.getProperty());
53     }
54
55     public Boolean isHighestVersion() {
56         return (Boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty());
57     }
58
59     public Long getCreationDate() {
60         return (Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty());
61     }
62
63     public Long getLastUpdateDate() {
64         return (Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty());
65     }
66
67     public String getDescription() {
68         return (String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty());
69     }
70
71     public String getConformanceLevel() {
72         return (String) properties.get(GraphPropertiesDictionary.CONFORMANCE_LEVEL.getProperty());
73     }
74
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());
80         } else {
81             Type listType = new TypeToken<List<String>>() {}.getType();
82             tagsFromJson = gson.fromJson((String) properties.get(GraphPropertiesDictionary.TAGS.getProperty()), listType);
83         }
84         return tagsFromJson;
85     }
86
87     public String getIcon() {
88         return (String) properties.get(GraphPropertiesDictionary.ICON.getProperty());
89     }
90
91     public String getState() {
92         return (String) properties.get(GraphPropertiesDictionary.STATE.getProperty());
93     }
94
95     public String getContactId() {
96         return (String) properties.get(GraphPropertiesDictionary.CONTACT_ID.getProperty());
97     }
98
99     public String getUUID() {
100         return (String) properties.get(GraphPropertiesDictionary.UUID.getProperty());
101     }
102
103     public String getNormalizedName() {
104         return (String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty());
105     }
106
107     public String getSystemName() {
108         return (String) properties.get(GraphPropertiesDictionary.SYSTEM_NAME.getProperty());
109     }
110
111     public Boolean isDeleted() {
112         return (Boolean) properties.get(GraphPropertiesDictionary.IS_DELETED.getProperty());
113     }
114
115     public String getProjectCode() {
116         return (String) properties.get(GraphPropertiesDictionary.PROJECT_CODE.getProperty());
117     }
118
119     public String getCsarUuid() {
120         return (String) properties.get(GraphPropertiesDictionary.CSAR_UUID.getProperty());
121     }
122
123     public String getCsarVersion() {
124         return (String) properties.get(GraphPropertiesDictionary.CSAR_VERSION.getProperty());
125     }
126
127     public String getImportedToscaChecksum() {
128         return (String) properties.get(GraphPropertiesDictionary.IMPORTED_TOSCA_CHECKSUM.getProperty());
129     }
130
131     public String getInvariantUuid() {
132         return (String) properties.get(GraphPropertiesDictionary.INVARIANT_UUID.getProperty());
133     }
134
135     public String getVendorName() {
136         return (String) properties.get(GraphPropertiesDictionary.VENDOR_NAME.getProperty());
137     }
138
139     public String getVendorRelease() {
140         return (String) properties.get(GraphPropertiesDictionary.VENDOR_RELEASE.getProperty());
141     }
142
143     public Boolean isAbstract() {
144         return (Boolean) properties.get(GraphPropertiesDictionary.IS_ABSTRACT.getProperty());
145     }
146
147     public ResourceTypeEnum getResourceType() {
148         if (properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()) != null) {
149            return ResourceTypeEnum.valueOf((String) properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()));
150         } else {
151             return null;
152         }
153     }
154
155     public String getToscaResourceName() {
156         return (String) properties.get(GraphPropertiesDictionary.TOSCA_RESOURCE_NAME.getProperty());
157     }
158
159     public Integer getInstanceCounter() {
160         return (Integer) properties.get(GraphPropertiesDictionary.INSTANCE_COUNTER.getProperty());
161     }
162
163     public String getCost() {
164         return (String) properties.get(GraphPropertiesDictionary.COST.getProperty());
165     }
166
167     public String getLicenseType() {
168         return (String) properties.get(GraphPropertiesDictionary.LICENSE_TYPE.getProperty());
169     }
170
171     public String getDistributionStatus() {
172         return (String) properties.get(GraphPropertiesDictionary.DISTRIBUTION_STATUS.getProperty());
173     }
174
175     public String getFullName() {
176         return (String) properties.get(GraphPropertiesDictionary.FULL_NAME.getProperty());
177     }
178
179     public List<String> getContacts() {
180         Type listType = new TypeToken<List<String>>() {}.getType();
181         return gson.fromJson((String) properties.get(GraphPropertiesDictionary.CONTACTS.getProperty()), listType);
182     }
183
184     public Boolean isActive() {
185         return (Boolean) properties.get(GraphPropertiesDictionary.IS_ACTIVE.getProperty());
186     }
187
188 }