Improve test coverage
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / enums / JsonPresentationFields.java
1 /*-
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 package org.openecomp.sdc.be.datatypes.enums;
17
18 import com.fasterxml.jackson.annotation.JsonCreator;
19 import com.fasterxml.jackson.annotation.JsonValue;
20 import lombok.AllArgsConstructor;
21 import lombok.Getter;
22 import lombok.ToString;
23
24 @AllArgsConstructor
25 @Getter
26 @ToString(onlyExplicitlyIncluded = true)
27 public enum JsonPresentationFields {
28
29     UNIQUE_ID("uniqueId", GraphPropertyEnum.UNIQUE_ID),
30     HIGHEST_VERSION("highestVersion", GraphPropertyEnum.IS_HIGHEST_VERSION),
31     LIFECYCLE_STATE("lifecycleState", GraphPropertyEnum.STATE),
32     CREATION_DATE("creationDate", null),
33     LAST_UPDATE_DATE("lastUpdateDate", null),
34     SYSTEM_NAME("systemName", GraphPropertyEnum.SYSTEM_NAME),
35     NAME("name", GraphPropertyEnum.NAME),
36     VERSION("version", GraphPropertyEnum.VERSION),
37     NORMALIZED_NAME("normalizedName", GraphPropertyEnum.NORMALIZED_NAME),
38     UUID("UUID", GraphPropertyEnum.UUID),
39     RESOURCE_TYPE("resourceType", GraphPropertyEnum.RESOURCE_TYPE),
40     COMPONENT_TYPE("componentType", GraphPropertyEnum.COMPONENT_TYPE),
41     IS_DELETED("isDeleted", GraphPropertyEnum.IS_DELETED),
42     ECOMP_GENERATED_NAMING("ecompGeneratedNaming", null),
43     NAMING_POLICY("namingPolicy", null),
44     ENVIRONMENT_CONTEXT("environmentContext", null),
45     TOSCA_RESOURCE_NAME("toscaResourceName", GraphPropertyEnum.TOSCA_RESOURCE_NAME),
46     DESCRIPTION("description", null),
47     TYPE("type", null),
48     DERIVED_FROM("derivedFrom", null),
49     VENDOR_NAME("vendorName", null),
50     VENDOR_RELEASE("vendorRelease", null),
51     CATEGORY("category", null),
52     SUB_CATEGORY("subcategory", null),
53     RESOURCE_VENDOR("resourceVendor", null),
54     RESOURCE_VENDOR_RELEASE("resourceVendorRelease", null),
55     RESOURCE_VENDOR_MODEL_NUMBER("reourceVendorModelNumber", null),
56     SERVICE_TYPE("serviceType", null),
57     SERVICE_ROLE("serviceRole", null),
58     INSTANTIATION_TYPE("instantiationType", null),
59     CONFORMANCE_LEVEL("conformanceLevel", null),
60     ICON("icon", null),
61     TAGS("tags", null),
62     INVARIANT_UUID("invariantUuid", GraphPropertyEnum.INVARIANT_UUID),
63     CSAR_UUID("csarUuid", GraphPropertyEnum.CSAR_UUID),
64     CSAR_VERSION("csarVersion", null),
65     IMPORTED_TOSCA_CHECKSUM("importedToscaChecksum", null),
66     CONTACT_ID("contactId", null),
67     PROJECT_CODE("projectCode", null),
68     DISTRIBUTION_STATUS("distributionStatus", GraphPropertyEnum.DISTRIBUTION_STATUS),
69     DERIVED_FROM_GENERIC_TYPE("derivedFromGenericType", null),
70     DERIVED_FROM_GENERIC_VERSION("derivedFromGenericVersion", null),
71     SERVICE_FUNCTION("serviceFunction", null),
72
73     DATA_TYPES("data_types", GraphPropertyEnum.DATA_TYPES),
74
75     ////Inputs
76     ANNOTATIONS("annotations", null),
77
78     ////Artifact
79     ARTIFACT_TYPE("artifactType", null),
80     ARTIFACT_REF("artifactRef", null),
81     ARTIFACT_REPOSITORY("artifactRepository", null),
82     ARTIFACT_CHECKSUM("artifactChecksum", null),
83     ARTIFACT_CREATOR("artifactCreator", null),
84     USER_ID_CREATOR("userIdCreator", null),
85     USER_ID_LAST_UPDATER("userIdLastUpdater", null),
86     CREATOR_FULL_NAME("creatorFullName", null),
87     UPDATER_FULL_NAME("updaterFullName", null),
88     IS_FROM_CSAR("isFromCsar", null),
89
90     ES_ID("esId", null),
91     ARTIFACT_LABEL("artifactLabel", null),
92     IS_ABSTRACT("mandatory", null),
93     ARTIFACT_DISPLAY_NAME("artifactDisplayName", null),
94     API_URL("apiUrl", null),
95     SERVICE_API("serviceApi", null),
96     ARTIFACT_VERSION("artifactVersion", null),
97     ARTIFACT_UUID("artifactUUID", null),
98     PAYLOAD_UPDATE_DATE("payloadUpdateDate", null),
99     HEAT_PARAMS_UPDATE_DATE("heatParamsUpdateDate", null),
100     GENERATED("generated", null),
101     ARTIFACT_GROUP_TYPE("artifactGroupType", null),
102     ARTIFACT_TIMEOUT("timeout", null),
103     REQUIRED_ARTIFACTS("requiredArtifacts", null),
104     DUPLICATED("duplicated", null),
105     HEAT_PARAMETERS("heatParameters", null),
106     GENERATED_FROM_ID("generatedFromId", null),
107
108     // end artifacts
109
110     //property
111     DEFINITION("definition", null),
112     DEFAULT_VALUE("defaultValue", null),
113     DEFAULT("default", null),
114     REQUIRED("required", null),
115     PASSWORD("password", null),
116     CONSTRAINTS("constraints", null),
117     PROPERTIES("properties", null),
118     PROPERTY("property", null),
119     SCHEMA("schema", null),
120     ENTRY_SCHEMA("entry_schema", null),
121     VALUE("value", null),
122     PARENT_UNIQUE_ID("parentUniqueId", null),
123
124     COMPONENT_INSTANCES("componentInstances", null),
125     RELATIONS("relations", null),
126
127     //attribute
128     STATUS("status", null),
129     //capability
130     VALID_SOURCE_TYPE("validSourceTypes", null),
131     CREATION_TIME("creationTime", null),
132     MODIFICATION_TIME("modificationTime", null),
133     CAPABILITY_SOURCES("capabilitySources", null),
134     MAX_OCCURRENCES("maxOccurrences", null),
135     MIN_OCCURRENCES("minOccurrences", null),
136     OWNER_TYPE("ownerType", null),
137     OWNER_NAME("ownerName", null),
138     OWNER_ID("ownerId", null),
139     LEFT_OCCURRENCES("leftOccurences", null),
140     CAPABILITY_ID("capabiltyId", null),
141     PATH("path", null),
142     SOURCE("source", null),
143
144     //Requirement
145     CAPABILITY("capability", null),
146     NODE("node", null),
147     RELATIONSHIP("relationship", null),
148     VALID_SOURCE_TYPES("validSourceTypes", null),
149     VALID_TARGET_TYPES("validTargetTypes", null),
150     REQUIREMENT_ID("requirementId", null),
151     PARENT_NAME("parentName", null),
152     PREVIOUS_NAME("previousName", null),
153     NODE_FILTER_CAPABILITIES("capabilities", null),
154     PROPERTY_FILTER_NAME("propertyName", null),
155     PROPERTY_FILTER_CONSTRAINT("propertyFilterConstraint", null),
156     EQUAL_CONSTRAINT("equal", null),
157     CONSTRAINT_VALUE("constraintValue", null),
158     CONSTRAINT_FUNCTION("constraintFunction", null),
159     NODE_FILTER("nodeFilter", null),
160     TOSCA_ID("tosca_id", null),
161
162     //Relation
163     CAPABILTY_OWNER_ID("capabilityOwnerId", null),
164     REQUIREMENT_OWNER_ID("requirementOwnerId", null),
165     FROM_ID("fromId", null),
166     TO_ID("toId", null),
167     REQUIREMENT("requirement", null),
168     ORIGIN_UI("originUI", null),
169
170     //Groups
171
172     GROUP_INVARIANT_UUID("invariantUUID", null),
173     GROUP_UUID("groupUUID", null),
174     GROUP_MEMBER("members", null),
175     GROUP_ARTIFACTS("artifacts", null),
176     GROUP_ARTIFACTS_UUID("artifactsUuid", null),
177     GROUP_PROPERTIES("properties", null),
178     GROUP_UNIQUE_ID("groupUid", null),
179     POS_X("posX", null),
180     POS_Y("posY", null),
181     PROPERTY_VALUE_COUNTER("propertyValueCounter", null),
182     CUSTOMIZATION_UUID("customizationUUID", null),
183     GROUP_NAME("groupName", null),
184     GROUP_INSTANCE_ARTIFACTS("groupInstanceArtifacts", null),
185     GROUP_INSTANCE_ARTIFACTS_UUID("groupInstanceArtifactsUuid", null),
186     GROUP_INSTANCE_PROPERTIES("groupInstancesProperties", null),
187
188     //Component instance
189
190     CI_COMPONENT_UID("componentUid", null),
191     CI_POS_X("posX", null),
192     CI_POS_Y("posY", null),
193     CI_PROP_VALUE_COUNTER("propertyValueCounter", null),
194     CI_ATTR_VALUE_COUNTER("attributeValueCounter", null),
195     CI_INPUT_VALUE_COUNTER("inputValueCounter", null),
196     CI_ORIGIN_TYPE("originType", null),
197     CI_COMPONENT_NAME("componentName", null),
198     CI_COMPONENT_VERSION("componentVersion", null),
199     CI_TOSCA_COMPONENT_NAME("toscaComponentName", null),
200     CI_INVARIANT_NAME("invariantName", null),
201     CI_ICON("icon", null),
202     CI_SOURCE_MODEL_UUID("sourceModelUuid", null),
203     CI_SOURCE_MODEL_UID("sourceModelUid", null),
204     CI_SOURCE_MODEL_INVARIANT("sourceModelInvariant", null),
205     CI_SOURCE_MODEL_NAME("sourceModelName", null),
206     CI_IS_PROXY("isProxy", null),
207     CI_DIRECTIVES("directives", null),
208     CI_ARTIFACTS("artifacts", null),
209
210     //path
211     FORWARDING_PATH("forwardingPath", null),
212     FROM_NODE("fromNode", null),
213     TO_NODE("toNode", null),
214     PATH_FROM_CP("fromCP", null),
215     PATH_TO_CP("toCP", null),
216     PATH_TO_CP_ORIGIN("toCPOrigin", null),
217     PATH_FROM_CP_ORIGIN("fromCPOrigin", null),
218     PATH_NAME("pathName", null),
219     PATH_PROTOCOL("pathProtocol", null),
220     PATH_DESTINATION_PORT_NUMBER("destinationPortNumber", null),
221     PATH_ELEMENT_LIST("pathElementList", null),
222
223     TYPE_UNIQUE_ID("typeUniqueId", null),
224     METADATA("metadata", null),
225     TARGETS("targets", null),
226
227     //External Refs
228     EXTERNAL_REF("externalRef", null),
229     CREATED_FROM("createdFrom", null),
230
231     //Archive
232     IS_ARCHIVED("isArchived", GraphPropertyEnum.IS_ARCHIVED),
233     ARCHIVE_TIME("archiveTime", GraphPropertyEnum.ARCHIVE_TIME),
234     IS_VSP_ARCHIVED("isVspArchived", GraphPropertyEnum.IS_VSP_ARCHIVED),
235     CI_IS_ORIGIN_ARCHIVED("isOriginArchived", null),
236
237     //Interface Operation
238     IO_OPERATION_TYPE("operationType", null),
239     IO_INPUT_PARAMETERS("inputParams", null),
240     IO_OUTPUT_PARAMETERS("outputParams", null),
241     IO_PARAM_NAME("paramName", null),
242     IO_PARAM_ID("paramId", null),
243     IO_NAME("name", null),
244     IO_MANDATORY("mandatory", null),
245     IO_TYPE("type", null),
246     IO_PROPERTY("property", null),
247     IO_WORKFLOW_NAME("workflowName", null),
248     IO_WORKFLOW_VERSION("workflowVersion", null),
249     IO_WORKFLOW_ID("workflowId", null),
250     IO_WORKFLOW_VERSION_ID("workflowVersionId", null),
251     IO_WORKFLOW_ASSOCIATION_TYPE("workflowAssociationType", null),
252
253     //Interface
254     INTERFACES("interfaces", null),
255     INTERFACE_INPUT("input", null),
256     OPERATIONS("operations", null),
257     OPERATION_IMPLEMENTATION("implementation", null),
258     OPERATION_INPUTS("inputs", null),
259     OPERATION_OUTPUTS("outputs", null),
260     INPUTS("inputs", null),
261
262     GET_PROPERTY("get_property", null),
263     GET_INPUT("get_input", null),
264     GET_OPERATION_OUTPUT("get_operation_output", null),
265
266     ATTRIBUTES("attributes", null),
267
268     TOSCA_DEFINITIONS_VERSION("tosca_definitions_version", null);
269
270     @ToString.Include
271     private final String presentation;
272     @ToString.Exclude
273     private final GraphPropertyEnum storedAs;
274
275     public static String getPresentationByGraphProperty(GraphPropertyEnum property) {
276         for (JsonPresentationFields currPresentation : JsonPresentationFields.values()) {
277             if (currPresentation.getStoredAs() == property) {
278                 return currPresentation.getPresentation();
279             }
280         }
281         return null;
282     }
283
284     @JsonCreator
285     public static JsonPresentationFields getByPresentation(String presentation) {
286         for (JsonPresentationFields inst : JsonPresentationFields.values()) {
287             if (inst.getPresentation().equals(presentation)) {
288                 return inst;
289             }
290         }
291         return null;
292     }
293
294     @JsonValue
295     public String getPresentation() {
296         return presentation;
297     }
298
299 }