Backend support for operation milestone filters
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / utils / TypeUtils.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 package org.openecomp.sdc.be.utils;
21
22 import java.util.Map;
23 import java.util.function.Consumer;
24 import lombok.AllArgsConstructor;
25 import lombok.Getter;
26
27 public class TypeUtils {
28
29     private static final String FIRST_CERTIFIED_VERSION_VERSION = "1.0";
30
31     public static <FieldType> void setField(Map<String, Object> toscaJson, ToscaTagNamesEnum tagName, Consumer<FieldType> setter) {
32         String fieldName = tagName.getElementName();
33         if (toscaJson.containsKey(fieldName)) {
34             FieldType fieldValue = (FieldType) toscaJson.get(fieldName);
35             setter.accept(fieldValue);
36         }
37     }
38
39     public static String getFirstCertifiedVersionVersion() {
40         return FIRST_CERTIFIED_VERSION_VERSION;
41     }
42
43     @Getter
44     @AllArgsConstructor
45     public enum ToscaTagNamesEnum {
46         // @formatter:off
47         DERIVED_FROM("derived_from"), IS_PASSWORD("is_password"),
48         // Properties
49         PROPERTIES("properties"), TYPE("type"), STATUS("status"),
50         KEY_SCHEMA("key_schema"), ENTRY_SCHEMA("entry_schema"), REQUIRED("required"), DESCRIPTION("description"),
51         DEFAULT_VALUE("default"), VALUE("value"), CONSTRAINTS("constraints"),
52         DEFAULT("default"),
53         // Group Types
54         MEMBERS("members"), METADATA("metadata"),
55         // Policy Types
56         POLICIES("policies"), TARGETS("targets"),
57         // Capabilities
58         CAPABILITIES("capabilities"), CAPABILITY_TYPES("capability_types"), VALID_SOURCE_TYPES("valid_source_types"),
59         // Requirements
60         REQUIREMENTS("requirements"), NODE("node"), RELATIONSHIP("relationship"), CAPABILITY("capability"), INTERFACES("interfaces"),
61         NODE_FILTER("node_filter"), TOSCA_ID("tosca_id"),
62         // Artifacts
63         ARTIFACTS("artifacts"), ARTIFACT_TYPES("artifact_types"), FILE("file"),
64         // Heat env Validation
65         PARAMETERS("parameters"),
66         // Import Validations
67         TOSCA_VERSION("tosca_definitions_version"), TOPOLOGY_TEMPLATE("topology_template"), OCCURRENCES("occurrences"),
68         NODE_TEMPLATES("node_templates"), GROUPS("groups"), GROUP_TYPES("group_types"), INPUTS("inputs"),
69         OUTPUTS("outputs"), RELATIONSHIP_TEMPLATES("relationship_templates"),
70         SUBSTITUTION_MAPPINGS("substitution_mappings"), NODE_TYPE("node_type"), DIRECTIVES("directives"),
71         // Attributes
72         ATTRIBUTES("attributes"), LABEL("label"), HIDDEN("hidden"), IMMUTABLE("immutable"), ANNOTATIONS("annotations"),
73         VERSION("version"), OPERATIONS("operations"), NOTIFICATIONS("notifications"),
74         //functions
75         GET_INPUT("get_input"), CONCAT("concat"),
76         // Definitions
77         DATA_TYPES("data_types"), NODE_TYPES("node_types"), POLICY_TYPES("policy_types"),  IMPORTS("imports"),
78         //Operations
79         IMPLEMENTATION("implementation"),
80         MILESTONES("milestones"),
81         ACTIVITIES("activities"),
82         FILTERS("filters"),
83         WORKFLOW("workflow"),
84         SUBSTITUTION_FILTERS("substitution_filter"),
85         DERIVED_FROM_NAME("derivedFromName"),
86         INTERFACE_TYPES("interface_types"),
87         INSTANCE_COUNT("instance_count");
88         // @formatter:om
89
90         private final String elementName;
91
92     }
93 }