2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.aai.dbmodel.v8.gen;
23 import java.util.HashMap;
26 import com.google.common.collect.ImmutableSetMultimap;
27 import com.google.common.collect.Multimap;
29 public class DbEdgeRules {
32 * The EdgeRules data is set up as a key (fromNodeTypeA|toNodeTypeB) mapped
33 * to a string which holds the info we need to build an edge from nodeTypeA
34 * to nodeTypeB. Note -- the MultiMap will let us define more than one type
35 * of edge between a given pair of nodeTypes, but for now we never define
38 * The edgeInfo part is comma separated and looks like this:
39 * "edgeLabel,direction,multiplicityRule,isParent,usesResource,hasDelTarget,SVC-INFRA" This
40 * format is encoded into the EdgeInfoMap below.
41 * MultiplicityRule can be either "Many2Many", "Many2One", "One2Many" or "One2One"
42 * The values for the things after multiplicityRule can be either "true", "false" or "reverse". "reverse" is
43 * really saying that this tag does apply, but the edge will be traversed
44 * the opposite way from the same tag that just has "true".
46 public static final Map<Integer, String> EdgeInfoMap;
48 EdgeInfoMap = new HashMap<Integer, String>();
49 EdgeInfoMap.put(0, "edgeLabel");
50 EdgeInfoMap.put(1, "direction");
51 EdgeInfoMap.put(2, "multiplicityRule");
52 EdgeInfoMap.put(3, "isParent");
53 EdgeInfoMap.put(4, "usesResource");
54 EdgeInfoMap.put(5, "hasDelTarget");
55 EdgeInfoMap.put(6, "SVC-INFRA");
58 public static Integer firstTagIndex = 3;
60 public static final Multimap<String, String> EdgeRules = new ImmutableSetMultimap.Builder<String, String>()
61 .putAll("cloud-region|l3-network",
62 "uses,OUT,Many2Many,false,false,false,false")
63 .putAll("cloud-region|tenant",
64 "has,OUT,One2Many,true,false,false,reverse")
65 .putAll("cloud-region|image",
66 "has,OUT,One2Many,true,false,false,false")
67 .putAll("cloud-region|flavor",
68 "has,OUT,One2Many,true,false,false,false")
69 .putAll("cloud-region|availability-zone",
70 "has,OUT,One2Many,true,false,false,false")
71 .putAll("cloud-region|volume-group",
72 "has,OUT,One2Many,true,true,false,false")
73 .putAll("cloud-region|group-assignment",
74 "has,OUT,One2Many,true,false,false,false")
75 .putAll("cloud-region|snapshot",
76 "has,OUT,One2Many,true,false,false,false")
77 .putAll("customer|service-subscription",
78 "subscribesTo,OUT,Many2Many,true,false,false,reverse")
79 .putAll("generic-vnf|l-interface",
80 "hasLInterface,OUT,Many2Many,true,false,false,true")
81 .putAll("generic-vnf|availability-zone",
82 "hasAvailabilityZone,OUT,Many2Many,false,false,false,true")
83 .putAll("generic-vnf|lag-interface",
84 "hasLAGInterface,OUT,Many2Many,true,false,false,true")
85 .putAll("generic-vnf|l3-network",
86 "usesL3Network,OUT,Many2Many,false,true,false,true")
87 .putAll("generic-vnf|pserver",
88 "runsOnPserver,OUT,Many2Many,false,true,false,true")
89 .putAll("generic-vnf|vserver",
90 "runsOnVserver,OUT,One2Many,false,true,false,true")
91 .putAll("generic-vnf|service-instance",
92 "hasInstance,OUT,Many2Many,false,true,false,true")
93 .putAll("group-assignment|tenant",
94 "has,OUT,Many2Many,false,false,false,false")
95 .putAll("group-assignment|pserver",
96 "has,OUT,One2Many,false,false,false,false")
97 .putAll("image|metadata", "hasMetaData,OUT,Many2Many,true,false,false,false")
98 .putAll("image|metadatum",
99 "hasMetaDatum,OUT,Many2Many,true,false,false,false")
100 .putAll("l-interface|l3-interface-ipv4-address-list",
101 "hasIpAddress,OUT,Many2Many,true,false,false,true")
102 .putAll("l-interface|l3-interface-ipv6-address-list",
103 "hasIpAddress,OUT,Many2Many,true,false,false,true")
104 .putAll("l-interface|logical-link",
105 "usesLogicalLink,OUT,Many2Many,false,false,true,true")
106 .putAll("l-interface|vlan","hasVlan,OUT,Many2Many,true,false,false,false")
107 .putAll("l3-interface-ipv4-address-list|l3-network",
108 "isMemberOf,OUT,Many2Many,false,false,false,true")
109 .putAll("l3-interface-ipv6-address-list|l3-network",
110 "isMemberOf,OUT,Many2Many,false,false,false,true")
111 .putAll("l3-interface-ipv4-address-list|subnet",
112 "isMemberOf,OUT,Many2Many,false,false,false,true")
113 .putAll("l3-interface-ipv6-address-list|subnet",
114 "isMemberOf,OUT,Many2Many,false,false,false,true")
115 .putAll("l3-network|subnet",
116 "hasSubnet,OUT,Many2Many,true,false,false,reverse")
117 .putAll("l3-network|service-instance",
118 "hasInstance,OUT,Many2Many,false,false,false,reverse")
119 .putAll("l3-network|ctag-assignment",
120 "hasCtagAssignment,OUT,Many2Many,true,false,false,true")
121 .putAll("l3-network|segmentation-assignment",
122 "has,OUT,One2Many,true,false,false,false")
123 .putAll("lag-interface|p-interface",
124 "usesPInterface,OUT,Many2Many,false,true,false,true")
125 .putAll("lag-interface|l-interface",
126 "hasLInterface,OUT,Many2Many,true,false,false,true")
127 .putAll("logical-link|pnf",
128 "bridgedTo,OUT,Many2Many,false,false,false,false")
129 .putAll("logical-link|logical-link",
130 "uses,OUT,One2Many,false,false,false,true")
131 .putAll("model|model-element",
132 "startsWith,OUT,One2Many,true,false,false,false")
133 .putAll("model-element|model",
134 "isA,OUT,Many2One,false,false,false,false")
135 .putAll("model|metadatum",
136 "hasMetaData,OUT,One2Many,true,false,false,false")
137 .putAll("model-element|model-element",
138 "connectsTo,OUT,One2Many,true,false,false,false")
139 .putAll("model-element|model-constraint",
140 "uses,OUT,One2Many,true,false,false,false")
141 .putAll("model-element|constrained-element-set",
142 "connectsTo,OUT,One2Many,true,false,false,false")
143 .putAll("model-constraint|constrained-element-set",
144 "uses,OUT,One2Many,true,false,false,false")
145 .putAll("constrained-element-set|element-choice-set",
146 "uses,OUT,One2Many,true,false,false,false")
147 .putAll("element-choice-set|model-element",
148 "has,OUT,One2Many,true,false,false,false")
149 .putAll("named-query|model",
150 "relatedTo,OUT,One2Many,false,false,false,false")
151 .putAll("named-query|named-query-element",
152 "startsWith,OUT,One2One,true,false,false,false")
153 .putAll("named-query-element|named-query-element",
154 "connectsTo,OUT,Many2Many,true,false,false,false")
155 .putAll("named-query-element|model",
156 "isA,OUT,Many2One,false,false,false,false")
157 .putAll("named-query-element|property-constraint",
158 "uses,OUT,One2Many,true,false,false,false")
159 .putAll("named-query-element|related-lookup",
160 "uses,OUT,One2Many,true,false,false,false")
161 .putAll("p-interface|l-interface",
162 "hasLInterface,OUT,Many2Many,true,false,false,true")
163 .putAll("p-interface|physical-link",
164 "usesPhysicalLink,OUT,Many2Many,false,false,true,false")
165 .putAll("p-interface|logical-link",
166 "usesLogicalLink,OUT,Many2One,false,false,false,true")
167 .putAll("pserver|cloud-region","locatedIn,OUT,Many2One,false,false,false,true")
168 .putAll("pserver|availability-zone","existsIn,OUT,Many2One,false,false,false,true")
169 .putAll("pserver|lag-interface",
170 "hasLAGInterface,OUT,Many2Many,true,false,false,true")
171 .putAll("pserver|p-interface",
172 "hasPinterface,OUT,Many2Many,true,true,false,true")
173 .putAll("pnf|p-interface",
174 "hasPinterface,OUT,Many2Many,true,true,false,true")
175 .putAll("pnf|lag-interface",
176 "has,OUT,One2Many,true,false,false,true")
177 .putAll("service-instance|pnf",
178 "uses,OUT,One2Many,false,true,false,false")
179 .putAll("service-subscription|service-instance",
180 "hasInstance,OUT,Many2Many,true,false,false,reverse")
181 .putAll("tenant|l3-network",
182 "usesL3Network,OUT,Many2Many,false,false,false,false")
183 .putAll("tenant|service-subscription",
184 "relatedTo,OUT,Many2Many,false,false,false,false")
185 .putAll("tenant|vserver", "owns,OUT,One2Many,true,false,false,reverse")
186 .putAll("vlan|l3-interface-ipv4-address-list",
187 "hasIpAddress,OUT,Many2Many,true,false,false,true")
188 .putAll("vlan|l3-interface-ipv6-address-list",
189 "hasIpAddress,OUT,Many2Many,true,false,false,true")
190 .putAll("vserver|flavor", "hasFlavor,OUT,Many2One,false,false,false,true")
191 .putAll("vserver|image", "hasImage,OUT,Many2One,false,false,false,true")
192 .putAll("vserver|ipaddress",
193 "hasIpAddress,OUT,Many2Many,true,true,false,false")
194 .putAll("vserver|l-interface",
195 "hasLInterface,OUT,Many2Many,true,false,false,true")
196 .putAll("vserver|pserver",
197 "runsOnPserver,OUT,Many2One,false,true,false,true")
198 .putAll("vserver|volume", "hasVolume,OUT,Many2Many,true,true,false,true")
199 .putAll("vserver|vnfc", "hosts,OUT,Many2Many,false,true,false,true")
200 .putAll("vserver|snapshot", "uses,OUT,One2One,false,false,false,true")
201 .putAll("service-instance|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false")
202 .putAll("service-instance|logical-link", "uses,OUT,Many2Many,false,false,true,false")
203 .putAll("service-instance|vlan", "dependsOn,OUT,One2Many,false,true,false,false")
204 .putAll("service-instance|service-instance", "dependsOn,OUT,One2Many,false,true,false,false")
205 .putAll("logical-link|generic-vnf", "bridgedTo,OUT,Many2Many,false,false,false,false")
206 .putAll("logical-link|pserver", "bridgedTo,OUT,Many2Many,false,false,false,false")
207 .putAll("volume-group|tenant", "belongsTo,OUT,Many2Many,false,false,false,true")
208 .putAll("vf-module|volume-group", "uses,OUT,One2One,false,false,false,true")
209 .putAll("vserver|vf-module", "isPartOf,OUT,Many2One,false,false,false,true")
210 .putAll("vf-module|l3-network", "uses,OUT,Many2Many,false,false,false,true")
211 .putAll("vf-module|vnfc", "uses,OUT,One2Many,false,false,true,true")
212 .putAll("generic-vnf|vf-module", "has,OUT,One2Many,true,false,false,true")
213 .putAll("generic-vnf|volume-group", "uses,OUT,One2Many,false,false,false,true")
214 .putAll("generic-vnf|vnfc", "uses,OUT,One2Many,false,false,true,true")
215 .putAll("vlan|logical-link", "usesLogicalLink,OUT,One2One,false,false,true,true")
218 public static final Multimap<String, String> DefaultDeleteScope = new ImmutableSetMultimap.Builder<String, String>()
219 .putAll("customer", "CASCADE_TO_CHILDREN")
220 .putAll("cloud-region", "THIS_NODE_ONLY")
221 .putAll("service-subscription", "CASCADE_TO_CHILDREN")
222 .putAll("service-instance", "CASCADE_TO_CHILDREN")
223 .putAll("tenant", "CASCADE_TO_CHILDREN")
224 .putAll("vserver", "CASCADE_TO_CHILDREN")
225 .putAll("volume", "THIS_NODE_ONLY")
226 .putAll("ipaddress", "THIS_NODE_ONLY")
227 .putAll("image", "ERROR_4_IN_EDGES_OR_CASCADE")
228 .putAll("pserver", "ERROR_4_IN_EDGES_OR_CASCADE")
229 .putAll("availability-zone", "ERROR_IF_ANY_IN_EDGES")
230 .putAll("flavor", "ERROR_IF_ANY_IN_EDGES")
231 .putAll("metadata", "THIS_NODE_ONLY")
232 .putAll("metadatum", "THIS_NODE_ONLY")
233 .putAll("model", "ERROR_4_IN_EDGES_OR_CASCADE")
234 .putAll("model-element", "CASCADE_TO_CHILDREN")
235 .putAll("named-query", "CASCADE_TO_CHILDREN")
236 .putAll("named-query-element", "CASCADE_TO_CHILDREN")
237 .putAll("collect-lookup", "THIS_NODE_ONLY")
238 .putAll("service", "ERROR_IF_ANY_IN_EDGES")
239 .putAll("l-interface", "CASCADE_TO_CHILDREN")
240 .putAll("vlan", "CASCADE_TO_CHILDREN")
241 .putAll("p-interface", "CASCADE_TO_CHILDREN")
242 .putAll("l3-interface-ipv6-address-list", "THIS_NODE_ONLY")
243 .putAll("l3-interface-ipv4-address-list", "THIS_NODE_ONLY")
244 .putAll("logical-link", "THIS_NODE_ONLY")
245 .putAll("physical-link", "THIS_NODE_ONLY")
246 .putAll("lag-interface", "CASCADE_TO_CHILDREN")
247 .putAll("l3-network", "CASCADE_TO_CHILDREN")
248 .putAll("subnet", "THIS_NODE_ONLY")
249 .putAll("vnfc", "THIS_NODE_ONLY")
250 .putAll("volume-group", "THIS_NODE_ONLY")
251 .putAll("ctag-assignment", "THIS_NODE_ONLY")
252 .putAll("pnf", "CASCADE_TO_CHILDREN")
253 .putAll("vf-module", "THIS_NODE_ONLY")
254 .putAll("snapshot", "THIS_NODE_ONLY")
255 .putAll("group-assignment", "THIS_NODE_ONLY")
256 .putAll("segmentation-assignment", "THIS_NODE_ONLY")
257 .putAll("generic-vnf", "CASCADE_TO_CHILDREN").build();
259 // NOTE -- Sorry, this is ugly, but we are mapping the nodeTypeCategory two
261 // make the code a little less bulky. But that means that we need to ensure
263 // nodeTypeCategory and nodeTypeCatMap are kept in synch.
265 // NodeTypeCategory: key is: nodeTypeCategory, value is:
266 // "nodeTypes,keyProperties,AltKeyProps,depNode4UniquenessFlag"
267 public static final Multimap<String, String> NodeTypeCategory = new ImmutableSetMultimap.Builder<String, String>()
268 .putAll("vnf", "generic-vnf,vnf-id,,true").build();
270 // NodeTypeCatMap: key is nodeType; value is: "nodeTypeCategory"
271 // So -- we're assuming that a nodeType can only be in one nodeTypeCategory.
272 public static final Map<String, String> NodeTypeCatMap;
274 NodeTypeCatMap = new HashMap<String, String>();
275 NodeTypeCatMap.put("generic-vnf", "vnf");
278 // ReservedPropNames: keys are property names of (node) properties that are
279 // common to all nodes and
280 // should not be removed if not passed in on an UPDATE request.
281 public static final Map<String, String> ReservedPropNames;
283 ReservedPropNames = new HashMap<String, String>();
284 ReservedPropNames.put("source-of-truth", "");
285 ReservedPropNames.put("last-mod-source-of-truth", "");
286 ReservedPropNames.put("aai-created-ts", "");
287 ReservedPropNames.put("aai-last-mod-ts", "");
290 // This just lists which node types can be connected to themselves recursively.
291 // It's temporary - since DbEdgeRules is going to be overhauled in 16-10, this will
292 // get generated automatically. But for 1607, it can work like this.
293 public static final Map<String, String> CanBeRecursiveNT;
295 CanBeRecursiveNT = new HashMap<String, String>();
296 CanBeRecursiveNT.put("model-element", "");
297 CanBeRecursiveNT.put("named-query-element", "");