Merge "Change healing manager logic"
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / enums / JsonPresentationFields.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
21 package org.openecomp.sdc.be.datatypes.enums;
22
23 import org.codehaus.jackson.annotate.JsonCreator;
24 import org.codehaus.jackson.annotate.JsonValue;
25
26
27 //@JsonDeserialize(using = MyDeserializer.class)
28
29 public enum JsonPresentationFields {
30         UNIQUE_ID                                               ("uniqueId",                            GraphPropertyEnum.UNIQUE_ID), 
31         HIGHEST_VERSION                                 ("highestVersion",                      GraphPropertyEnum.IS_HIGHEST_VERSION),
32         LIFECYCLE_STATE                                 ("lifecycleState",                      GraphPropertyEnum.STATE), 
33         CREATION_DATE                                   ("creationDate",                        null), 
34         LAST_UPDATE_DATE                                ("lastUpdateDate",                      null), 
35         SYSTEM_NAME                                             ("systemName",                          GraphPropertyEnum.SYSTEM_NAME), 
36         NAME                                                    ("name",                                        GraphPropertyEnum.NAME), 
37         VERSION                                                 ("version",                             GraphPropertyEnum.VERSION), 
38         NORMALIZED_NAME                                 ("normalizedName",                      GraphPropertyEnum.NORMALIZED_NAME),
39         UUID                                                    ("UUID",                                        GraphPropertyEnum.UUID), 
40         RESOURCE_TYPE                                   ("resourceType",                        GraphPropertyEnum.RESOURCE_TYPE),
41         COMPONENT_TYPE                                  ("componentType",                       GraphPropertyEnum.COMPONENT_TYPE),
42         IS_DELETED                                              ("isDeleted",                           GraphPropertyEnum.IS_DELETED),
43         ECOMP_GENERATED_NAMING          ("ecompGeneratedNaming",    null),
44         NAMING_POLICY                   ("namingPolicy",            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         RESOURCE_VENDOR_MODEL_NUMBER    ("reourceVendorModelNumber",null),
52         SERVICE_TYPE                    ("serviceType",             null),
53         SERVICE_ROLE                    ("serviceRole",             null),
54         CONFORMANCE_LEVEL                               ("conformanceLevel",            null),
55         ICON                                                    ("icon",                                        null),
56         TAGS                                                    ("tags",                                        null),
57         INVARIANT_UUID                                  ("invariantUuid",                       GraphPropertyEnum.INVARIANT_UUID),
58         CSAR_UUID                                               ("csarUuid",                            GraphPropertyEnum.CSAR_UUID),
59         CSAR_VERSION                                    ("csarVersion",                         null),
60         IMPORTED_TOSCA_CHECKSUM                 ("importedToscaChecksum",       null),
61         CONTACT_ID                                              ("contactId",                           null),
62         PROJECT_CODE                                    ("projectCode",                         null),
63         DISTRIBUTION_STATUS                             ("distributionStatus",          GraphPropertyEnum.DISTRIBUTION_STATUS),
64         DERIVED_FROM_GENERIC_TYPE               ("derivedFromGenericType",      null),
65         DERIVED_FROM_GENERIC_VERSION    ("derivedFromGenericVersion", null),
66
67         ////Artifact
68         ARTIFACT_TYPE                                   ("artifactType",                        null),
69         ARTIFACT_REF                                    ("artifactRef",                         null),
70         ARTIFACT_REPOSITORY                             ("artifactRepository",          null),
71         ARTIFACT_CHECKSUM                               ("artifactChecksum",            null),
72         ARTIFACT_CREATOR                                ("artifactCreator",             null),
73         USER_ID_CREATOR                                 ("userIdCreator",                       null),
74         USER_ID_LAST_UPDATER                    ("userIdLastUpdater",           null),
75         CREATOR_FULL_NAME                               ("creatorFullName",                     null),
76         UPDATER_FULL_NAME                               ("updaterFullName",             null),
77         
78         ES_ID                                                   ("esId",                                        null),
79         ARTIFACT_LABEL                                  ("artifactLabel",                       null),
80         IS_ABSTRACT                                     ("mandatory",                           null),
81         ARTIFACT_DISPLAY_NAME                   ("artifactDisplayName",         null),
82         API_URL                                                 ("apiUrl",                                      null),
83         SERVICE_API                                     ("serviceApi",                          null),
84         ARTIFACT_VERSION                                ("artifactVersion",             null),
85         ARTIFACT_UUID                                   ("artifactUUID",                        null),
86         PAYLOAD_UPDATE_DATE                             ("payloadUpdateDate",           null),
87         HEAT_PARAMS_UPDATE_DATE                 ("heatParamsUpdateDate",        null),
88         GENERATED                                               ("generated",                           null),
89         ARTIFACT_GROUP_TYPE                     ("artifactGroupType",           null),
90         ARTIFACT_TIMEOUT                                ("timeout",                                     null),
91         REQUIRED_ARTIFACTS                              ("requiredArtifacts",           null),
92         DUPLICATED                                              ("duplicated",                          null),
93         HEAT_PARAMETERS                                 ("heatParameters",                      null),
94         GENERATED_FROM_ID                               ("generatedFromId",             null),
95         
96         
97         // end artifacts
98         
99         
100         //property
101         DEFINITION                                              ("definition",                                  null),
102         DEFAULT_VALUE                                   ("defaultValue",                                null),
103         REQUIRED                                                ("required",                                    null),
104         PASSWORD                                                ("password",                                    null),
105         CONSTRAINTS                                             ("constraints",                                 null),
106         PROPERTIES                                              ("properties",                                  null),
107         PROPERTY                                                ("property",                                    null),
108         SCHEMA                                                  ("schema",                                              null),
109         VALUE                                                   ("value",                                               null),
110         PARENT_UNIQUE_ID                                ("parentUniqueId",                              null),
111         
112         COMPONENT_INSTANCES                             ("componentInstances",                  null),
113         RELATIONS                                               ("relations",                                   null),
114         
115         //attribute
116         STATUS                                                  ("status",                                              null),                  
117         //capability
118         VALID_SOURCE_TYPE                               ("validSourceTypes",                    null),
119         CREATION_TIME                                   ("creationTime",                                null),
120         MODIFICATION_TIME                               ("modificationTime",                    null),
121         CAPABILITY_SOURCES                              ("capabilitySources",                   null),
122         MAX_OCCURRENCES                                 ("maxOccurrences",                              null),
123         MIN_OCCURRENCES                                 ("minOccurrences",                              null),
124         OWNER_NAME                                              ("ownerName",                                   null),
125         OWNER_ID                                                ("ownerId",                                     null),
126         LEFT_OCCURRENCES                                ("leftOccurences",                              null),  
127         CAPABILITY_ID                                   ("capabiltyId",                                 null),
128         PATH                                                    ("path",                                                null),
129         SOURCE                                                  ("source",                                              null),
130         
131         //Requirement
132         CAPAPILITY                                              ("capability",                                  null),
133         NODE                                                    ("node",                                                null),          
134         RELATIONSHIP                                    ("relationship",                                null),
135         VALID_SOURCE_TYPES                              ("validSourceTypes",                    null),
136         REQUIREMENT_ID                                  ("requirementId",                               null),
137         PARENT_NAME                                             ("parentName",                                  null),
138         //Relation
139         CAPABILTY_OWNER_ID                              ("capabilityOwnerId",                   null),
140         REQUIREMENT_OWNER_ID                    ("requirementOwnerId",                  null),
141         FROM_ID                                                 ("fromId",                                              null),
142         TO_ID                                                   ("toId",                                                null),
143         REQUIREMENT                                             ("requirement",                                 null),
144                 
145         //Groups
146
147         GROUP_INVARIANT_UUID                    ("invariantUUID",                               null), 
148         GROUP_UUID                                              ("groupUUID",                                   null),  
149         GROUP_MEMBER                                    ("members",                                             null), 
150         GROUP_ARTIFACTS                                 ("artifacts",                                   null),
151         GROUP_ARTIFACTS_UUID                    ("artifactsUuid",                               null),
152         GROUP_PROPERTIES                                ("properties",                                  null),
153         GROUP_UNIQUE_ID                                 ("groupUid",                                    null),
154         POS_X                                                   ("posX",                                                null),
155         POS_Y                                                   ("posY",                                                null),
156         PROPERTY_VALUE_COUNTER                  ("propertyValueCounter",                null),
157         CUSTOMIZATION_UUID                              ("customizationUUID",                   null),
158         GROUP_NAME                                              ("groupName",                                   null),
159         GROUP_INSTANCE_ARTIFACTS                ("groupInstanceArtifacts",              null),
160         GROUP_INSTANCE_ARTIFACTS_UUID   ("groupInstanceArtifactsUuid",  null),
161         GROUP_INSTANCE_PROPERTIES               ("groupInstancesProperties",    null),
162         
163         //Component insatnce
164
165         CI_COMPONENT_UID                                ("componentUid", null),
166         CI_POS_X                                                ("posX", null),
167         CI_POS_Y                                                ("posY", null), 
168         CI_PROP_VALUE_COUNTER                   ("propertyValueCounter", null),
169         CI_ATTR_VALUE_COUNTER                   ("attributeValueCounter", null),
170         CI_INPUT_VALUE_COUNTER                  ("inputValueCounter", null),
171         CI_ORIGIN_TYPE                                  ("originType", null),
172         CI_COMPONENT_NAME                               ("componentName", null),
173         CI_COMPONENT_VERSION                    ("componentVersion", null),
174         CI_TOSCA_COMPONENT_NAME                 ("toscaComponentName", null),
175         CI_INVARIANT_NAME                               ("invariantName", null),
176         CI_ICON                                                 ("icon", null),
177
178         ;
179         
180
181         private String presentation;
182         private GraphPropertyEnum storedAs;
183
184         JsonPresentationFields(String presentation, GraphPropertyEnum storedAs) {
185                 this.presentation = presentation;
186                 this.storedAs = storedAs;
187         }
188
189         @JsonValue
190         public String getPresentation() {
191                 return presentation;
192         }
193
194         public void setPresentation(String presentation) {
195                 this.presentation = presentation;
196         }
197
198         public GraphPropertyEnum getStoredAs() {
199                 return storedAs;
200         }
201         
202         public void setStoredAs(GraphPropertyEnum storedAs) {
203                 this.storedAs = storedAs;
204         }
205
206         public static String getPresentationByGraphProperty(GraphPropertyEnum property) {
207                 for(JsonPresentationFields currPresentation : JsonPresentationFields.values()){
208                         if(currPresentation.getStoredAs() == property){
209                                 return currPresentation.getPresentation();
210                         }
211                 }
212                 return null;
213         }
214         
215         @Override
216         public String toString() {
217                 // TODO Auto-generated method stub
218                 return presentation;
219         }
220
221         @JsonCreator
222         public static JsonPresentationFields getByPresentation(String presentation) {
223                 for (JsonPresentationFields inst : JsonPresentationFields.values()) {
224                         if (inst.getPresentation().equals(presentation)) {
225                                 return inst;
226                         }
227                 }
228                 return null;
229         }
230         
231 }