Catalog alignment
[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
16 package org.openecomp.sdc.be.datatypes.enums;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21
22 public enum GraphPropertyEnum {
23
24     // field name ,class type ,unique ,indexed
25     UNIQUE_ID("uid", String.class, true, true),
26     LABEL("nodeLabel", String.class, false, true),
27     JSON("json", String.class, false, false),
28     METADATA("metadata", String.class, false, false),
29     VERSION("version", String.class, false, true),
30     STATE("state", String.class, false, true),
31     IS_HIGHEST_VERSION("highestVersion", Boolean.class, false, true),
32     IS_DELETED("deleted", Boolean.class, false, true),
33     NORMALIZED_NAME("normalizedName", String.class, false, true),
34     NAME("name", String.class, false, true),
35     TOSCA_RESOURCE_NAME("toscaResourceName", String.class, false, true),
36     DISTRIBUTION_STATUS("distributionStatus", String.class, false, false),
37     RESOURCE_TYPE("resourceType", String.class, false, true),
38     COMPONENT_TYPE("componentType", String.class, false, true),
39     UUID("uuid", String.class, false, true),
40     SYSTEM_NAME("systemName", String.class, false, true),
41     IS_ABSTRACT("abstract", Boolean.class, false, true),
42     INVARIANT_UUID("invariantUuid", String.class, false, true),
43     CSAR_UUID("csarUuid", String.class, false, true),
44     //used for user (old format, no json for users)
45     USERID("userId", String.class, true, true),
46     ROLE("role", String.class, false, false),
47     FIRST_NAME("firstName", String.class, false, false),
48     LAST_NAME("lastName", String.class, false, false),
49     EMAIL("email", String.class, false, false),
50     LAST_LOGIN_TIME("lastLoginTime", Long.class, false, false),
51     //used for category (old format, no json for categories)
52     ICONS("icons", String.class, false, false),
53
54     //Archive/Restore
55     IS_ARCHIVED("isArchived", Boolean.class, false, true),
56     IS_VSP_ARCHIVED("isVspArchived", Boolean.class, false, true),
57     ARCHIVE_TIME("archiveTime", Long.class, false, true),
58     PREV_CATALOG_UPDATE_TIME    ("previousUpdateTime",         Long.class,                 false,      true),
59     CURRENT_CATALOG_UPDATE_TIME ("currentUpdateTime",         Long.class,                 false,      true),
60
61     //Healing
62     HEALING_VERSION("healVersion", Integer.class, false, true);
63
64
65
66     private String property;
67     private Class clazz;
68     private boolean unique;
69     private boolean indexed;
70
71     GraphPropertyEnum(String property, Class clazz, boolean unique, boolean indexed) {
72         this.property = property;
73         this.clazz = clazz;
74         this.unique = unique;
75         this.indexed = indexed;
76     }
77
78     public static GraphPropertyEnum getByProperty(String property) {
79         for (GraphPropertyEnum currProperty : GraphPropertyEnum.values()) {
80             if (currProperty.getProperty().equals(property)) {
81                 return currProperty;
82             }
83         }
84         return null;
85     }
86
87     public String getProperty() {
88         return property;
89     }
90
91     public void setProperty(String property) {
92         this.property = property;
93     }
94
95     public Class getClazz() {
96         return clazz;
97     }
98
99     public void setClazz(Class clazz) {
100         this.clazz = clazz;
101     }
102
103     public boolean isUnique() {
104         return unique;
105     }
106
107     public void setUnique(boolean unique) {
108         this.unique = unique;
109     }
110
111     public boolean isIndexed() {
112         return indexed;
113     }
114
115     public void setIndexed(boolean indexed) {
116         this.indexed = indexed;
117     }
118
119     public static List<String> getAllProperties() {
120
121         List<String> arrayList = new ArrayList<>();
122
123         for (GraphPropertyEnum graphProperty : GraphPropertyEnum.values()) {
124             arrayList.add(graphProperty.getProperty());
125         }
126
127         return arrayList;
128     }
129 }