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