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