Renaming Files having BluePrint to have Blueprint
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / blueprints / blueprint-core / src / main / kotlin / org / onap / ccsdk / cds / controllerblueprints / core / BlueprintTypes.kt
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2018 IBM.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package org.onap.ccsdk.cds.controllerblueprints.core
19
20 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
21
22 /**
23  *
24  *
25  * @author Brinda Santh
26  */
27 object BlueprintTypes {
28
29     @JvmStatic
30     val validNodeTypeDerivedFroms: MutableList<String> = arrayListOf(
31         BlueprintConstants.MODEL_TYPE_NODES_ROOT,
32         BlueprintConstants.MODEL_TYPE_NODE_WORKFLOW,
33         BlueprintConstants.MODEL_TYPE_NODE_COMPONENT,
34         BlueprintConstants.MODEL_TYPE_NODE_VNF,
35         BlueprintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
36         BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA,
37         BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,
38         BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT,
39         BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON,
40         BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON,
41         BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT
42     )
43
44     @JvmStatic
45     val validArtifactTypeDerivedFroms: MutableList<String> = arrayListOf(
46         BlueprintConstants.MODEL_TYPE_ARTIFACTS_ROOT,
47         BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION
48     )
49
50     @JvmStatic
51     val validDataTypeDerivedFroms: MutableList<String> = arrayListOf(
52         BlueprintConstants.MODEL_TYPE_DATATYPES_ROOT,
53         BlueprintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
54     )
55
56     @JvmStatic
57     val validRelationShipDerivedFroms: MutableList<String> = arrayListOf(
58         BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
59         BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
60         BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON,
61         BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
62         BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO,
63         BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO
64     )
65
66     @JvmStatic
67     val validCapabilityTypes: MutableList<String> = arrayListOf(
68         BlueprintConstants.MODEL_TYPE_CAPABILITIES_ROOT,
69         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE,
70         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE,
71         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK,
72         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE,
73         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT,
74         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC,
75         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN,
76         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE,
77         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT,
78         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM,
79         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE,
80         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT,
81         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING,
82         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF,
83         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_RESTCONF,
84         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH,
85         BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP
86     )
87
88     @JvmStatic
89     fun validModelTypes(): List<String> {
90         val validTypes: MutableList<String> = arrayListOf()
91         validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
92         validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
93         validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
94         validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
95         validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
96         return validTypes
97     }
98
99     @JvmStatic
100     fun validPropertyTypes(): List<String> {
101         val validTypes: MutableList<String> = arrayListOf()
102         validTypes.addAll(validPrimitiveTypes())
103         validTypes.addAll(validComplexTypes())
104         validTypes.addAll(validCollectionTypes())
105         return validTypes
106     }
107
108     @JvmStatic
109     fun validPrimitiveTypes(): List<String> {
110         val validTypes: MutableList<String> = arrayListOf()
111         validTypes.add(BlueprintConstants.DATA_TYPE_STRING)
112         validTypes.add(BlueprintConstants.DATA_TYPE_INTEGER)
113         validTypes.add(BlueprintConstants.DATA_TYPE_FLOAT)
114         validTypes.add(BlueprintConstants.DATA_TYPE_DOUBLE)
115         validTypes.add(BlueprintConstants.DATA_TYPE_BOOLEAN)
116         validTypes.add(BlueprintConstants.DATA_TYPE_TIMESTAMP)
117         validTypes.add(BlueprintConstants.DATA_TYPE_NULL)
118         return validTypes
119     }
120
121     @JvmStatic
122     fun validComplexTypes(): List<String> {
123         val validTypes: MutableList<String> = arrayListOf()
124         validTypes.add(BlueprintConstants.DATA_TYPE_JSON)
125         validTypes.add(BlueprintConstants.DATA_TYPE_MAP)
126         return validTypes
127     }
128
129     @JvmStatic
130     fun validCollectionTypes(): List<String> {
131         val validTypes: MutableList<String> = arrayListOf()
132         validTypes.add(BlueprintConstants.DATA_TYPE_LIST)
133         return validTypes
134     }
135
136     @JvmStatic
137     fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean {
138         val entrySchema = propertyDefinition.entrySchema?.type ?: BlueprintConstants.DATA_TYPE_NULL
139         return BlueprintTypes.validPropertyTypes().contains(propertyDefinition.type) &&
140             BlueprintTypes.validPrimitiveTypes().contains(entrySchema)
141     }
142
143     @JvmStatic
144     fun validCommands(): List<String> {
145         return listOf(
146             BlueprintConstants.EXPRESSION_DSL_REFERENCE,
147             BlueprintConstants.EXPRESSION_GET_INPUT,
148             BlueprintConstants.EXPRESSION_GET_ATTRIBUTE,
149             BlueprintConstants.EXPRESSION_GET_PROPERTY,
150             BlueprintConstants.EXPRESSION_GET_ARTIFACT,
151             BlueprintConstants.EXPRESSION_GET_OPERATION_OUTPUT,
152             BlueprintConstants.EXPRESSION_GET_NODE_OF_TYPE
153         )
154     }
155
156     @JvmStatic
157     fun rootNodeTypes(): List<String> {
158         return listOf(BlueprintConstants.MODEL_TYPE_NODES_ROOT)
159     }
160
161     @JvmStatic
162     fun rootRelationshipTypes(): List<String> {
163         return listOf(BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT)
164     }
165
166     @JvmStatic
167     fun rootDataTypes(): List<String> {
168         return listOf(BlueprintConstants.MODEL_TYPE_DATATYPES_ROOT)
169     }
170 }