Merge "Check if configuration resource already exists."
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / OrchestrationStatus.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.so.db.catalog.beans;
22
23 public enum OrchestrationStatus {
24     ACTIVE("Active", "active"),
25     ASSIGNED("Assigned", "assigned"),
26     CREATED("Created", "created"),
27     INVENTORIED("Inventoried", "inventoried"),
28     PENDING("Pending", "pending"),
29     PENDING_ACTIVATION("PendingActivation", "pending.?activation"),
30     PENDING_CREATE("PendingCreate", "pending.?create"),
31     PENDING_DELETE("PendingDelete", "pending.?delete"),
32     PRECREATED("PreCreated", "pre.?created"),
33     CONFIGASSIGNED("ConfigAssigned", "config.?assigned"),
34     CONFIGURE("Configure", "configure"),
35     CONFIGURED("Configured", "configured");
36
37     private final String name;
38     private final String fuzzyMatcher;
39
40     private OrchestrationStatus(String name, String fuzzyMatcher) {
41         this.name = name;
42         this.fuzzyMatcher = fuzzyMatcher;
43     }
44
45     @Override
46     public String toString() {
47         return name;
48     }
49
50     /**
51      * case insensitive regular expression match to enum value
52      *
53      * @param status
54      * @return
55      */
56     public boolean fuzzyMap(String status) {
57         if (status != null) {
58             return status.matches("(?i)" + this.fuzzyMatcher);
59         } else {
60             return false;
61         }
62     }
63 }