Support querying of model by type
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / enums / GraphPropertyEnum.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 package org.openecomp.sdc.be.datatypes.enums;
16
17 import java.util.ArrayList;
18 import java.util.List;
19 import java.util.Map;
20 import lombok.AllArgsConstructor;
21 import lombok.Getter;
22
23 @AllArgsConstructor
24 @Getter
25 public enum GraphPropertyEnum {
26     // @formatter:off
27     // field name ,class type ,unique ,indexed
28     UNIQUE_ID("uid", String.class, true, true),
29     LABEL("nodeLabel", String.class, false, true),
30     JSON("json", String.class, false, false),
31     METADATA("metadata", String.class, false, false),
32     VERSION("version", String.class, false, true),
33     STATE("state", String.class, false, true),
34     IS_HIGHEST_VERSION("highestVersion", Boolean.class, false, true),
35     IS_DELETED("deleted", Boolean.class, false, true),
36     NORMALIZED_NAME("normalizedName", String.class, false, true),
37     NAME("name", String.class, false, true),
38     TOSCA_RESOURCE_NAME("toscaResourceName", String.class, false, true),
39     DISTRIBUTION_STATUS("distributionStatus", String.class, false, false),
40     RESOURCE_TYPE("resourceType", String.class, false, true),
41     COMPONENT_TYPE("componentType", String.class, false, true),
42     UUID("uuid", String.class, false, true),
43     SYSTEM_NAME("systemName", String.class, false, true),
44     IS_ABSTRACT("abstract", Boolean.class, false, true),
45     INVARIANT_UUID("invariantUuid", String.class, false, true),
46     CSAR_UUID("csarUuid", String.class, false, true),
47     //used for user (old format, no json for users)
48     USERID("userId", String.class, true, true),
49     ROLE("role", String.class, false, false),
50     FIRST_NAME("firstName", String.class, false, false),
51     LAST_NAME("lastName", String.class, false, false),
52     EMAIL("email", String.class, false, false),
53     LAST_LOGIN_TIME("lastLoginTime", Long.class, false, false),
54     //used for category (old format, no json for categories)
55     ICONS("icons", String.class, false, false),
56     METADATA_KEYS("metadataKeys", String.class, false, false),
57     USE_SUBSTITUTION_FOR_NESTED_SERVICES("useServiceSubstitutionForNestedServices", Boolean.class, false, false),
58     DATA_TYPES("data_types", Map.class, false, false),
59     //Archive/Restore
60     IS_ARCHIVED("isArchived", Boolean.class, false, true),
61     IS_VSP_ARCHIVED("isVspArchived", Boolean.class, false, true),
62     ARCHIVE_TIME("archiveTime", Long.class, false, true),
63     PREV_CATALOG_UPDATE_TIME("previousUpdateTime", Long.class, false, true),
64     CURRENT_CATALOG_UPDATE_TIME("currentUpdateTime", Long.class, false, true),
65     //Healing
66     HEALING_VERSION("healVersion", Integer.class, false, true),
67     MODEL("model", String.class, false, false),
68     MODEL_TYPE("modelType", String.class, false, false);
69     // @formatter:on
70
71     private final String property;
72     private final Class<?> clazz;
73     private final boolean unique;
74     private final boolean indexed;
75
76     public static GraphPropertyEnum getByProperty(String property) {
77         for (GraphPropertyEnum currProperty : GraphPropertyEnum.values()) {
78             if (currProperty.getProperty().equals(property)) {
79                 return currProperty;
80             }
81         }
82         return null;
83     }
84
85     public static List<String> getAllProperties() {
86         List<String> arrayList = new ArrayList<>();
87         for (GraphPropertyEnum graphProperty : GraphPropertyEnum.values()) {
88             arrayList.add(graphProperty.getProperty());
89         }
90         return arrayList;
91     }
92 }