From: Venkata Harish K Kajur Date: Fri, 15 Sep 2017 11:43:00 +0000 (-0400) Subject: Increase code coverage for aai-common repo to 30% X-Git-Tag: v1.1.0~39 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F12707%2F1;p=aai%2Faai-common.git Increase code coverage for aai-common repo to 30% Issue-ID: AAI-215 Change-Id: Ied7d885274d83fa183880ca683a2c440818e66dc Signed-off-by: Venkata Harish K Kajur --- diff --git a/aai-core/src/main/java/org/openecomp/aai/db/schema/AuditOXM.java b/aai-core/src/main/java/org/openecomp/aai/db/schema/AuditOXM.java index 4257bf4d..b7aab081 100644 --- a/aai-core/src/main/java/org/openecomp/aai/db/schema/AuditOXM.java +++ b/aai-core/src/main/java/org/openecomp/aai/db/schema/AuditOXM.java @@ -33,12 +33,13 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.openecomp.aai.serialization.db.EdgeRule; +import org.openecomp.aai.serialization.db.EdgeRules; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import org.openecomp.aai.db.props.AAIProperties; -import org.openecomp.aai.dbmodel.DbEdgeRules; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.introspection.LoaderFactory; @@ -221,14 +222,14 @@ public class AuditOXM extends Auditor { * Creates the edge labels. */ private void createEdgeLabels() { - Multimap edgeRules = DbEdgeRules.EdgeRules; + Multimap edgeRules = EdgeRules.getInstance().getAllRules(); for (String key : edgeRules.keySet()) { - Collection collection = edgeRules.get(key); + Collection collection = edgeRules.get(key); EdgeProperty prop = new EdgeProperty(); //there is only ever one, they used the wrong type for EdgeRules String label = ""; - for (String item : collection) { - label = item.split(",")[0]; + for (EdgeRule item : collection) { + label = item.getLabel(); } prop.setName(label); prop.setMultiplicity(Multiplicity.MULTI); diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java deleted file mode 100644 index 7fbf3954..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -//package org.openecomp.aai.dbmodel; -//import static com.jayway.jsonpath.Criteria.where; -//import static com.jayway.jsonpath.Filter.filter; -// -//import java.io.IOException; -//import java.nio.file.Files; -//import java.nio.file.Paths; -//import java.util.Collection; -//import java.util.List; -//import java.util.Map; -//import java.util.Map.Entry; -// -//import org.openecomp.aai.introspection.Version; -//import org.openecomp.aai.serialization.db.AAIDirection; -// -//import com.google.common.collect.Multimap; -//import com.jayway.jsonpath.Configuration; -//import com.jayway.jsonpath.DocumentContext; -//import com.jayway.jsonpath.JsonPath; -//import com.jayway.jsonpath.Option; -// -//public class ConvertDeleteScope { -// -// -// -// private static final String edgeClasspath = "org.openecomp.aai.dbmodel"; -// private static final String edgeClassSuffix = ".%s.gen"; -// private static final String jsonEdgeFile = "src/main/resources/dbedgerules/DbEdgeRules_%s.json"; -// -// public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, IllegalArgumentException, NoSuchFieldException, SecurityException { -// for (Version v : Version.values()) { -// convert(v); -// } -// } -// private static void convert(Version v) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, NoSuchFieldException, SecurityException { -// DocumentContext rulesDoc; -// Multimap deleteScope; -// Configuration conf = Configuration.defaultConfiguration().addOptions(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS); -// -// rulesDoc = JsonPath.using(conf).parse(readFile(String.format(jsonEdgeFile, v))); -// if (v.equals(Version.getLatest())) { -// Object rules = Class.forName(edgeClasspath + ".DbEdgeRules").newInstance(); -// deleteScope = (Multimap) rules.getClass().getField("DefaultDeleteScope").get(rules); -// } else { -// Object rules = Class.forName(edgeClasspath + String.format(edgeClassSuffix, v) + ".DbEdgeRules").newInstance(); -// deleteScope = (Multimap) rules.getClass().getField("DefaultDeleteScope").get(rules); -// } -// Collection> entries = deleteScope.entries(); -// for (Entry entry : entries) { -// String key = entry.getKey(); -// String value = entry.getValue(); -// -// addRule(rulesDoc, key, value); -// -// } -// List> results = rulesDoc.read("$.rules.[?]", filter(where("preventDelete").exists(false))); -// for (Map result : results) { -// result.put("preventDelete", AAIDirection.NONE.toString()); -// } -// System.out.println("Version: " + v + " " + rulesDoc.jsonString()); -// -// -// } -// -// private static String readFile (String path) throws IOException { -// return new String(Files.readAllBytes(Paths.get(path))); -// } -// -// private static void addRule(DocumentContext rulesDoc, String nodeType, String deleteScope) { -// -// if (deleteScope.equals("THIS_NODE_ONLY")) { -// List> results = rulesDoc.read("$.rules.[?]", filter( -// where("from").is(nodeType) -// ).and( -// filter(where("isParent").is("${direction}")).or( -// where("hasDelTarget").is("${direction}") -// ) -// ) -// ); -// for (Map result : results) { -// result.put("preventDelete", "${direction}"); -// } -// } else if (deleteScope.contains("_IN_")) { -// List> results = rulesDoc.read("$.rules.[?]", filter(where("to").is(nodeType).and("isParent").is("false"))); -// for (Map result : results) { -// result.put("preventDelete", "!${direction}"); -// } -// } else { -// -// } -// } -// -// -//} diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java deleted file mode 100644 index 1e6a1496..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java +++ /dev/null @@ -1,433 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel; - -import java.util.HashMap; -import java.util.Map; - -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; - -public class DbEdgeRules { - - /* - * The EdgeRules data is set up as a key (fromNodeTypeA|toNodeTypeB) mapped - * to a string which holds the info we need to build an edge from nodeTypeA - * to nodeTypeB. Note -- the MultiMap will let us define more than one type - * of edge between a given pair of nodeTypes, but for now we never define - * more than one. - * - * The edgeInfo part is comma separated and looks like this: - * "edgeLabel,direction,multiplicityRule,isParent,usesResource,hasDelTarget,SVC-INFRA" This - * format is encoded into the EdgeInfoMap below. - * MultiplicityRule can be either "Many2Many", "Many2One", "One2Many" or "One2One" - * The values for the things after multiplicityRule can be either "true", "false" or "reverse". "reverse" is - * really saying that this tag does apply, but the edge will be traversed - * the opposite way from the same tag that just has "true". - */ - public static final Map EdgeInfoMap; - static { - EdgeInfoMap = new HashMap(); - EdgeInfoMap.put(0, "edgeLabel"); - EdgeInfoMap.put(1, "direction"); - EdgeInfoMap.put(2, "multiplicityRule"); - EdgeInfoMap.put(3, "isParent"); - EdgeInfoMap.put(4, "usesResource"); - EdgeInfoMap.put(5, "hasDelTarget"); - EdgeInfoMap.put(6, "SVC-INFRA"); - } - - public static Integer firstTagIndex = 3; - - public static final Multimap EdgeRules = new ImmutableSetMultimap.Builder() - .putAll("availability-zone|complex", - "groupsResourcesIn,OUT,Many2Many,false,false,false,false") - .putAll("availability-zone|service-capability", - "supportsServiceCapability,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|complex", - "locatedIn,OUT,Many2One,false,false,false,false") - .putAll("cloud-region|l3-network", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|tenant", - "has,OUT,One2Many,true,false,false,reverse") - .putAll("cloud-region|image", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|flavor", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|availability-zone", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|oam-network", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|dvs-switch", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|volume-group", - "has,OUT,One2Many,true,true,false,false") - .putAll("cloud-region|group-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|snapshot", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("complex|ctag-pool", - "hasCtagPool,OUT,Many2Many,true,false,false,false") - .putAll("complex|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,true") - .putAll("ctag-pool|availability-zone", - "supportsAvailabilityZone,OUT,Many2Many,false,false,false,false") - .putAll("customer|service-subscription", - "subscribesTo,OUT,Many2Many,true,false,false,reverse") - .putAll("dvs-switch|availability-zone", - "existsIn,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,true") - .putAll("generic-vnf|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|l3-network", - "usesL3Network,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|pserver", - "runsOnPserver,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|vnf-image", - "usesVnfImage,OUT,Many2One,false,false,false,true") - .putAll("generic-vnf|vserver", - "runsOnVserver,OUT,One2Many,false,true,false,true") - .putAll("generic-vnf|service-instance", - "hasInstance,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|site-pair-set", - "hasSitePairSet,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|network-profile", - "hasNetworkProfile,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|tenant", - "has,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|pserver", - "has,OUT,One2Many,false,false,false,false") - .putAll("image|metadata", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("image|metadatum", - "hasMetaDatum,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("l-interface|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|l-interface", - "has,OUT,One2Many,true,false,false,true") - .putAll("l-interface|logical-link", - "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("lag-interface|logical-link", - "uses,OUT,Many2Many,false,false,true,true") - .putAll("l-interface|vlan","hasVlan,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|sriov-vf","has,OUT,One2One,true,false,false,false") - .putAll("l3-interface-ipv4-address-list|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("l3-interface-ipv6-address-list|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("l3-interface-ipv4-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv4-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|vpn-binding", - "usesVpnBinding,OUT,Many2Many,false,false,false,false") - .putAll("l3-network|instance-group", - "memberOf,OUT,Many2Many,false,false,false,false") - .putAll("l3-network|subnet", - "hasSubnet,OUT,Many2Many,true,false,false,reverse") - .putAll("l3-network|service-instance", - "hasInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("l3-network|ctag-assignment", - "hasCtagAssignment,OUT,Many2Many,true,false,false,true") - .putAll("l3-network|network-policy", - "uses,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|segmentation-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("l3-network|route-table-reference", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("lag-interface|lag-link", - "usesLAGLink,OUT,Many2Many,false,true,true,true") - .putAll("lag-interface|p-interface", - "usesPInterface,OUT,Many2Many,false,true,false,true") - .putAll("lag-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("logical-link|lag-link", - "usesLAGLink,OUT,Many2Many,false,true,false,true") - .putAll("logical-link|pnf", - "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|logical-link", - "uses,OUT,One2Many,false,false,false,true") - .putAll("model|model-ver", - "has,OUT,One2Many,true,false,false,false") - .putAll("model-ver|model-element", - "startsWith,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-ver", - "isA,OUT,Many2One,false,false,false,false") - .putAll("model-ver|metadatum", - "hasMetaData,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-element", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("model-element|constrained-element-set", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-constraint|constrained-element-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("constrained-element-set|element-choice-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("element-choice-set|model-element", - "has,OUT,One2Many,true,false,false,false") - .putAll("named-query|model", - "relatedTo,OUT,One2Many,false,false,false,false") - .putAll("named-query|named-query-element", - "startsWith,OUT,One2One,true,false,false,false") - .putAll("named-query-element|named-query-element", - "connectsTo,OUT,Many2Many,true,false,false,false") - .putAll("named-query-element|model", - "isA,OUT,Many2One,false,false,false,false") - .putAll("named-query-element|property-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("named-query-element|related-lookup", - "uses,OUT,One2Many,true,false,false,false") - .putAll("instance-group|model", - "targets,OUT,Many2Many,false,false,false,false") - .putAll("newvce|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,false") - .putAll("oam-network|complex", - "definedFor,OUT,Many2Many,false,false,false,false") - .putAll("oam-network|service-capability", - "supportsServiceCapability,OUT,Many2Many,false,false,false,false") - .putAll("p-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("p-interface|physical-link", - "usesPhysicalLink,OUT,Many2Many,false,false,true,false") - .putAll("p-interface|logical-link", - "usesLogicalLink,OUT,Many2One,false,false,false,true") - .putAll("port-group|cvlan-tag", "hasCTag,OUT,Many2Many,true,true,false,true") - .putAll("pserver|complex", "locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|cloud-region","locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|availability-zone","existsIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("pserver|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pserver|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("pnf|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pnf|lag-interface", - "has,OUT,One2Many,true,false,false,true") - .putAll("pnf|complex", - "locatedIn,OUT,Many2One,false,false,false,false") - .putAll("pnf|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("pnf|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("service-instance|cvlan-tag", - "hasIPAGFacingVLAN,OUT,Many2Many,false,true,false,false") - .putAll("service-instance|pnf", - "uses,OUT,One2Many,false,true,false,false") - .putAll("service-subscription|service-instance", - "hasInstance,OUT,Many2Many,true,false,false,reverse") - .putAll("site-pair-set|routing-instance", - "hasRoutingInstance,OUT,Many2Many,true,false,false,false") - .putAll("routing-instance|site-pair", - "hasSitePair,OUT,Many2Many,true,false,false,false") - .putAll("site-pair|class-of-service", - "hasClassOfService,OUT,Many2Many,true,false,false,false") - .putAll("tenant|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,false") - .putAll("tenant|service-subscription", - "relatedTo,OUT,Many2Many,false,false,false,false") - .putAll("tenant|vserver", "owns,OUT,One2Many,true,false,false,reverse") - .putAll("vce|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,false") - .putAll("vce|complex", "locatedIn,OUT,Many2Many,false,false,false,true") - .putAll("vce|port-group", "hasPortGroup,OUT,Many2Many,true,true,false,true") - .putAll("vce|vserver", "runsOnVserver,OUT,Many2Many,false,true,false,true") - .putAll("vce|service-instance", - "hasServiceInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("virtual-data-center|generic-vnf", - "hasVNF,OUT,Many2Many,false,false,false,reverse") - .putAll("vlan|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vlan|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vpe|complex", "locatedIn,OUT,Many2Many,false,false,false,false") - .putAll("vpe|ctag-pool", "usesCtagPool,OUT,Many2Many,false,false,false,false") - .putAll("vpe|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,false") - .putAll("vpe|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,false") - .putAll("vpe|vserver", "runsOnVserver,OUT,Many2Many,false,true,false,false") - .putAll("vpls-pe|complex", "locatedIn,OUT,Many2Many,false,false,false,false") - .putAll("vpls-pe|ctag-pool", - "usesCtagPool,OUT,Many2Many,false,false,false,false") - .putAll("vpls-pe|p-interface", - "hasPinterface,OUT,Many2Many,true,false,false,false") - .putAll("vpls-pe|lag-interface", - "hasLAGinterface,OUT,Many2Many,true,false,false,false") - .putAll("vserver|flavor", "hasFlavor,OUT,Many2One,false,false,false,true") - .putAll("vserver|image", "hasImage,OUT,Many2One,false,false,false,true") - .putAll("vserver|ipaddress", - "hasIpAddress,OUT,Many2Many,true,true,false,false") - .putAll("vserver|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("vserver|pserver", - "runsOnPserver,OUT,Many2One,false,true,false,true") - .putAll("vserver|volume", "hasVolume,OUT,Many2Many,true,true,false,true") - .putAll("vserver|vnfc", "hosts,OUT,Many2Many,false,true,false,true") - .putAll("vserver|snapshot", "uses,OUT,One2One,false,false,false,true") - .putAll("service-instance|connector", "uses,OUT,Many2Many,false,true,false,false") - .putAll("service-instance|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|logical-link", "uses,OUT,Many2Many,false,false,true,false") - .putAll("service-instance|vlan", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("service-instance|service-instance", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("connector|virtual-data-center", "contains,OUT,Many2Many,false,false,false,false") - .putAll("connector|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("virtual-data-center|logical-link", "contains,OUT,Many2Many,false,true,false,false") - .putAll("logical-link|generic-vnf", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|pserver", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("vlan|multicast-configuration", "uses,OUT,Many2Many,false,true,false,false") - .putAll("volume-group|complex", "existsIn,OUT,Many2Many,false,false,false,true") - .putAll("volume-group|tenant", "belongsTo,OUT,Many2Many,false,false,false,true") - .putAll("ipsec-configuration|vig-server", "hasVigServer,OUT,One2Many,true,true,false,false") - .putAll("generic-vnf|ipsec-configuration", "uses,OUT,Many2One,false,true,false,false") - .putAll("vf-module|volume-group", "uses,OUT,One2One,false,false,false,true") - .putAll("vserver|vf-module", "isPartOf,OUT,Many2One,false,false,false,true") - .putAll("vf-module|l3-network", "uses,OUT,Many2Many,false,false,false,true") - .putAll("vf-module|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("generic-vnf|vf-module", "has,OUT,One2Many,true,false,false,true") - .putAll("generic-vnf|volume-group", "uses,OUT,One2Many,false,false,false,true") - .putAll("generic-vnf|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("vlan|logical-link", "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("vpn-binding|route-target", "has,OUT,One2Many,true,false,false,false") - .putAll("service-instance|ctag-assignment","uses,OUT,One2Many,false,false,false,false") - // The next edge is needed in 1702 but will be worked in user story AAI-6848 - //.putAll("service-instance|allotted-resource", "uses,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|generic-vnf", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|l3-network", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|network-policy", "uses,OUT,One2One,false,false,false,false") - .putAll("allotted-resource|vlan", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|l-interface", "uses,OUT,One2Many,false,false,false,false") - .putAll("generic-vnf|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("service-instance|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|tunnel-xconnect", "has,OUT,One2One,true,false,false,false") - .putAll("logical-link|cloud-region", "existsIn,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|vpn-binding", "uses,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("generic-vnf|license", "has,OUT,One2Many,true,false,false,false") - .putAll("vce|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("vce|license", "has,OUT,One2Many,true,false,false,false") - .putAll("vpe|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("vpe|license", "has,OUT,One2Many,true,false,false,false") - .putAll("zone|complex", "existsIn,OUT,Many2One,false,false,false,false") - .putAll("service-instance|allotted-resource", "has,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|allotted-resource", "uses,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|vpn-binding", "belongsTo,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|allotted-resource", "bindsTo,OUT,One2One,false,false,false,false") - .build(); - - public static final Multimap DefaultDeleteScope = new ImmutableSetMultimap.Builder() - .putAll("customer", "CASCADE_TO_CHILDREN") - .putAll("cloud-region", "THIS_NODE_ONLY") - .putAll("service-subscription", "CASCADE_TO_CHILDREN") - .putAll("service-instance", "CASCADE_TO_CHILDREN") - .putAll("vce", "CASCADE_TO_CHILDREN") - .putAll("port-group", "CASCADE_TO_CHILDREN") - .putAll("cvlan-tag", "THIS_NODE_ONLY") - .putAll("tenant", "THIS_NODE_ONLY") - .putAll("vserver", "CASCADE_TO_CHILDREN") - .putAll("volume", "THIS_NODE_ONLY") - .putAll("ipaddress", "THIS_NODE_ONLY") - .putAll("image", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("pserver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("availability-zone", "ERROR_IF_ANY_IN_EDGES") - .putAll("oam-network", "ERROR_IF_ANY_IN_EDGES") - .putAll("dvs-switch", "THIS_NODE_ONLY") - .putAll("service-capability", "ERROR_IF_ANY_IN_EDGES") - .putAll("complex", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("flavor", "ERROR_IF_ANY_IN_EDGES") - .putAll("metadata", "THIS_NODE_ONLY") - .putAll("metadatum", "THIS_NODE_ONLY") - .putAll("model", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-ver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-element", "CASCADE_TO_CHILDREN") - .putAll("model-constraint", "CASCADE_TO_CHILDREN") - .putAll("property-constraint", "CASCADE_TO_CHILDREN") - .putAll("related-lookup", "CASCADE_TO_CHILDREN") - .putAll("constrained-element-set", "CASCADE_TO_CHILDREN") - .putAll("element-choice-set", "CASCADE_TO_CHILDREN") - .putAll("named-query", "CASCADE_TO_CHILDREN") - .putAll("named-query-element", "CASCADE_TO_CHILDREN") - .putAll("network-policy", "THIS_NODE_ONLY") - .putAll("collect-lookup", "THIS_NODE_ONLY") - .putAll("service", "ERROR_IF_ANY_IN_EDGES") - .putAll("newvce", "CASCADE_TO_CHILDREN") - .putAll("vpe", "CASCADE_TO_CHILDREN") - .putAll("vpls-pe", "CASCADE_TO_CHILDREN") - .putAll("l-interface", "CASCADE_TO_CHILDREN") - .putAll("vlan", "CASCADE_TO_CHILDREN") - .putAll("p-interface", "CASCADE_TO_CHILDREN") - .putAll("l3-interface-ipv6-address-list", "THIS_NODE_ONLY") - .putAll("l3-interface-ipv4-address-list", "THIS_NODE_ONLY") - .putAll("logical-link", "THIS_NODE_ONLY") - .putAll("physical-link", "THIS_NODE_ONLY") - .putAll("lag-link", "THIS_NODE_ONLY") - .putAll("lag-interface", "CASCADE_TO_CHILDREN") - .putAll("virtual-data-center", "CASCADE_TO_CHILDREN") - .putAll("generic-vnf", "CASCADE_TO_CHILDREN") - .putAll("l3-network", "CASCADE_TO_CHILDREN") - .putAll("ctag-pool", "THIS_NODE_ONLY") - .putAll("subnet", "ERROR_IF_ANY_IN_EDGES") - .putAll("sriov-vf", "THIS_NODE_ONLY") - .putAll("vpn-binding", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("vnf-image", "ERROR_IF_ANY_IN_EDGES") - .putAll("site-pair-set", "CASCADE_TO_CHILDREN") - .putAll("routing-instance", "CASCADE_TO_CHILDREN") - .putAll("site-pair", "CASCADE_TO_CHILDREN") - .putAll("class-of-service", "THIS_NODE_ONLY") - .putAll("connector", "CASCADE_TO_CHILDREN") - .putAll("vnfc", "THIS_NODE_ONLY") - .putAll("multicast-configuration", "THIS_NODE_ONLY") - .putAll("volume-group", "THIS_NODE_ONLY") - .putAll("ctag-assignment", "THIS_NODE_ONLY") - .putAll("pnf", "CASCADE_TO_CHILDREN") - .putAll("ipsec-configuration", "CASCADE_TO_CHILDREN") - .putAll("vig-server", "THIS_NODE_ONLY") - .putAll("vf-module", "THIS_NODE_ONLY") - .putAll("snapshot", "THIS_NODE_ONLY") - .putAll("group-assignment", "THIS_NODE_ONLY") - .putAll("segmentation-assignment", "THIS_NODE_ONLY") - .putAll("route-table-reference", "THIS_NODE_ONLY") - .putAll("network-profile", "THIS_NODE_ONLY") - .putAll("allotted-resource", "CASCADE_TO_CHILDREN") - .putAll("tunnel-xconnect", "THIS_NODE_ONLY") - .putAll("instance-group","THIS_NODE_ONLY") - .putAll("entitlement","THIS_NODE_ONLY") - .putAll("license","THIS_NODE_ONLY") - .putAll("zone", "THIS_NODE_ONLY") - .putAll("route-target", "CASCADE_TO_CHILDREN") - .putAll("sriov-pf", "THIS_NODE_ONLY").build(); -} diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverter.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverter.java deleted file mode 100644 index bbb456bd..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverter.java +++ /dev/null @@ -1,222 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.openecomp.aai.introspection.Version; - -import com.google.common.collect.Multimap; - -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; -import freemarker.template.TemplateExceptionHandler; - -/** - * Converts the old DbEdgeRules multimap to new json format - */ -public class DbEdgeRulesConverter { - private static final int LABEL = 0; - private static final int DIRECTION = 1; - private static final int MULTIPLICITY = 2; - private static final int ISPARENT = 3; - private static final int USESRESOURCE = 4; - private static final int HASDELTARGET = 5; - private static final int SVCINFRA = 6; - - private Configuration config = new Configuration(); - private Template template; - private String destDirectory; - private FileOutputStream writeStream; - - public DbEdgeRulesConverter(){ /*pretty much just so I can test functionality without dealing with template setup*/ } - - public DbEdgeRulesConverter(String destinationDir) { - destDirectory = destinationDir; - try { - setup(destinationDir); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Sets up the freemarker template and the directory to be written to. Run this once before - * doing any converting, does not need to be run per file generated (unless you want different directories for each file). - * - * @param destinationDir - String of the path to the directory where you want the new format files written to, - * relative to aai-core/ - * @throws IOException if it can't find the template loading directory or the template file itself - */ - public void setup(String destinationDir) throws IOException { - config.setDirectoryForTemplateLoading(new File("src/main/resources/dbedgerules/conversion")); - config.setDefaultEncoding("UTF-8"); - config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); - template = config.getTemplate("edgerulesTemplate.ftlh"); - - File destination = new File(destinationDir); - if (!destination.exists()) { - destination.mkdir(); - } - } - - /** - * Converts the given DbEdgeRules multimap representation into a json file of the new format. - * - * @param rules - a Multimap of the old DbEdgeRules format - * @param writer - writes to the output file (designate that file when you instantiate the writer) - */ - public void convert(Multimap rules, Writer writer) { - - List rulesToWrite = new ArrayList<>(); - for (Entry rule : rules.entries()) { - rulesToWrite.add(extractData(rule)); - } - Map> wrappedRules = new HashMap<>(); - wrappedRules.put("wrappedRules", rulesToWrite); - try { - template.process(wrappedRules, writer); - } catch (TemplateException e) { - System.out.println("Something went wrong when trying to combine the data and the template"); - e.printStackTrace(); - } catch (IOException e) { - System.out.println("There was a problem writing to the output file"); - e.printStackTrace(); - } - } - - /** - * Extracts the pieces of information that go in each field of the new json format from the old - * DbEdgeRules format. - * - * @param rule - one entry from the DbEdgeRules multimap representation - * Takes the form <"from-node|to-node", "label,direction,multiplicity,isParent,usesResource,hasDelTarget,svc-infra"> - * @return EdgeRuleBean with the pieces of information the template needs, in a format the template can understand - */ - public EdgeRuleBean extractData(Entry rule){ - EdgeRuleBean data = new EdgeRuleBean(); - - String oldName = rule.getKey(); - String[] nodes = oldName.split("\\|"); - data.setFrom(nodes[0]); - data.setTo(nodes[1]); - - String oldSpecs = rule.getValue(); - String[] specs = oldSpecs.split(","); - data.setLabel(specs[LABEL]); - data.setDirection(specs[DIRECTION]); - data.setMultiplicity(specs[MULTIPLICITY]); - data.setParent(specs[ISPARENT]); - data.setUsesResource(specs[USESRESOURCE]); - data.setHasDelTarget(specs[HASDELTARGET]); - data.setSvcInfra(specs[SVCINFRA]); - - return data; - } - - private Multimap getEdgeRules(Version v) { - try { - Class dbEdgeRules; - //use reflection to get the corresponding DbEdgeRules class - //need this weird if-else bc current version doesn't sit in a v.gen subdirectory - if (Version.isLatest(v)) { - dbEdgeRules = Class.forName("org.openecomp.aai.dbmodel.DbEdgeRules"); - } else { - dbEdgeRules = Class.forName("org.openecomp.aai.dbmodel." + v + ".gen.DbEdgeRules"); - } - - @SuppressWarnings("unchecked") - Multimap rules = (Multimap)dbEdgeRules.getDeclaredField("EdgeRules").get(null); - - return rules; - } catch (ClassNotFoundException e) { - System.out.println("could not find DbEdgeRules class for version " + v); - e.printStackTrace(); - return null; - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - System.out.println("Something went wrong trying to retrieve the rules"); - e.printStackTrace(); - return null; - } - } - - private Writer buildOutputWriter(Version v) { - try { - File output = new File(destDirectory + "DbEdgeRules_" + v + ".json"); - writeStream = new FileOutputStream(output); - return new OutputStreamWriter(writeStream); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } - } - - /** - * Runs all the conversion steps for the specified version. - * - * @param v - */ - public void convertVersion(Version v) { - try { - Multimap rules = getEdgeRules(v); - if (rules == null) { //something went wrong, we've already logged it in the helper so just stop execution - return; - } - - Writer writer = buildOutputWriter(v); - if (writer == null) { //something went wrong, we've already logged it in the helper so just stop execution - return; - } - convert(rules, writer); - - writer.close(); - writeStream.close(); - } catch (IOException e) { - System.out.println("Something went wrong closing the writer/writestream"); - e.printStackTrace(); - } - } - - /** - * Runs the converter for each DbEdgeRules version currently supported (2, 7, 8, 9, and 10) - * - * @param args - none actually - */ - public static void main(String[] args) { - String destDirectory = "src/main/resources/dbedgerules/"; - DbEdgeRulesConverter dberConverter = new DbEdgeRulesConverter(destDirectory); - - for (Version v : Version.values()) { - dberConverter.convertVersion(v); - } - } -} diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/EdgeRuleBean.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/EdgeRuleBean.java deleted file mode 100644 index f80bbca9..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/EdgeRuleBean.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel; - -public class EdgeRuleBean { - private String from; - private String to; - private String label; - private String direction; - private String multiplicity; - private String isParent; - private String usesResource; - private String hasDelTarget; - private String svcInfra; - - public String getFrom() { - return from; - } - public void setFrom(String from) { - this.from = from; - } - public String getTo() { - return to; - } - public void setTo(String to) { - this.to = to; - } - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - public String getDirection() { - return direction; - } - public void setDirection(String direction) { - this.direction = direction; - } - public String getMultiplicity() { - return multiplicity; - } - public void setMultiplicity(String multiplicity) { - this.multiplicity = multiplicity; - } - public String getIsParent() { - return isParent; - } - public void setParent(String isParent) { - this.isParent = isParent; - } - public String getUsesResource() { - return usesResource; - } - public void setUsesResource(String usesResource) { - this.usesResource = usesResource; - } - public String getHasDelTarget() { - return hasDelTarget; - } - public void setHasDelTarget(String hasDelTarget) { - this.hasDelTarget = hasDelTarget; - } - public String getSvcInfra() { - return svcInfra; - } - public void setSvcInfra(String svcInfra) { - this.svcInfra = svcInfra; - } -} diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/v10/gen/DbEdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/v10/gen/DbEdgeRules.java deleted file mode 100644 index 1069e849..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/v10/gen/DbEdgeRules.java +++ /dev/null @@ -1,475 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel.v10.gen; - -import java.util.HashMap; -import java.util.Map; - -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; - -public class DbEdgeRules { - - /* - * The EdgeRules data is set up as a key (fromNodeTypeA|toNodeTypeB) mapped - * to a string which holds the info we need to build an edge from nodeTypeA - * to nodeTypeB. Note -- the MultiMap will let us define more than one type - * of edge between a given pair of nodeTypes, but for now we never define - * more than one. - * - * The edgeInfo part is comma separated and looks like this: - * "edgeLabel,direction,multiplicityRule,isParent,usesResource,hasDelTarget,SVC-INFRA" This - * format is encoded into the EdgeInfoMap below. - * MultiplicityRule can be either "Many2Many", "Many2One", "One2Many" or "One2One" - * The values for the things after multiplicityRule can be either "true", "false" or "reverse". "reverse" is - * really saying that this tag does apply, but the edge will be traversed - * the opposite way from the same tag that just has "true". - */ - public static final Map EdgeInfoMap; - static { - EdgeInfoMap = new HashMap(); - EdgeInfoMap.put(0, "edgeLabel"); - EdgeInfoMap.put(1, "direction"); - EdgeInfoMap.put(2, "multiplicityRule"); - EdgeInfoMap.put(3, "isParent"); - EdgeInfoMap.put(4, "usesResource"); - EdgeInfoMap.put(5, "hasDelTarget"); - EdgeInfoMap.put(6, "SVC-INFRA"); - } - - public static Integer firstTagIndex = 3; - - public static final Multimap EdgeRules = new ImmutableSetMultimap.Builder() - .putAll("availability-zone|complex", - "groupsResourcesIn,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|license-key-resource", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("availability-zone|service-capability", - "supportsServiceCapability,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|complex", - "locatedIn,OUT,Many2One,false,false,false,false") - .putAll("cloud-region|l3-network", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|tenant", - "has,OUT,One2Many,true,false,false,reverse") - .putAll("cloud-region|image", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|flavor", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|availability-zone", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|oam-network", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|dvs-switch", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|volume-group", - "has,OUT,One2Many,true,true,false,false") - .putAll("cloud-region|group-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|snapshot", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("complex|ctag-pool", - "hasCtagPool,OUT,Many2Many,true,false,false,false") - .putAll("complex|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,true") - .putAll("ctag-pool|availability-zone", - "supportsAvailabilityZone,OUT,Many2Many,false,false,false,false") - .putAll("customer|service-subscription", - "subscribesTo,OUT,Many2Many,true,false,false,reverse") - .putAll("dvs-switch|availability-zone", - "existsIn,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,true") - .putAll("generic-vnf|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|l3-network", - "usesL3Network,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|pserver", - "runsOnPserver,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|vnf-image", - "usesVnfImage,OUT,Many2One,false,false,false,true") - .putAll("generic-vnf|vserver", - "runsOnVserver,OUT,One2Many,false,true,false,true") - .putAll("generic-vnf|service-instance", - "hasInstance,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|site-pair-set", - "hasSitePairSet,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|network-profile", - "hasNetworkProfile,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|tenant", - "has,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|pserver", - "has,OUT,One2Many,false,false,false,false") - .putAll("image|metadata", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("image|metadatum", - "hasMetaDatum,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("l-interface|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|l-interface", - "has,OUT,One2Many,true,false,false,true") - .putAll("l-interface|logical-link", - "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("lag-interface|logical-link", - "uses,OUT,Many2Many,false,false,true,true") - .putAll("l-interface|vlan","hasVlan,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|sriov-vf","has,OUT,One2One,true,false,false,false") - .putAll("l3-interface-ipv4-address-list|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("l3-interface-ipv6-address-list|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("l3-interface-ipv4-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv4-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|vpn-binding", - "usesVpnBinding,OUT,Many2Many,false,false,false,false") - .putAll("l3-network|subnet", - "hasSubnet,OUT,Many2Many,true,false,false,reverse") - .putAll("l3-network|service-instance", - "hasInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("l3-network|ctag-assignment", - "hasCtagAssignment,OUT,Many2Many,true,false,false,true") - .putAll("l3-network|network-policy", - "uses,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|segmentation-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("l3-network|route-table-reference", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("lag-interface|lag-link", - "usesLAGLink,OUT,Many2Many,false,true,true,true") - .putAll("lag-interface|p-interface", - "usesPInterface,OUT,Many2Many,false,true,false,true") - .putAll("lag-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("logical-link|lag-link", - "usesLAGLink,OUT,Many2Many,false,true,false,true") - .putAll("logical-link|pnf", - "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|logical-link", - "uses,OUT,One2Many,false,false,false,true") - .putAll("model|model-ver", - "has,OUT,One2Many,true,false,false,false") - .putAll("model-ver|model-element", - "startsWith,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-ver", - "isA,OUT,Many2One,false,false,false,false") - .putAll("model-ver|metadatum", - "hasMetaData,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-element", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("model-element|constrained-element-set", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-constraint|constrained-element-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("constrained-element-set|element-choice-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("element-choice-set|model-element", - "has,OUT,One2Many,true,false,false,false") - .putAll("named-query|model", - "relatedTo,OUT,One2Many,false,false,false,false") - .putAll("named-query|named-query-element", - "startsWith,OUT,One2One,true,false,false,false") - .putAll("named-query-element|named-query-element", - "connectsTo,OUT,Many2Many,true,false,false,false") - .putAll("named-query-element|model", - "isA,OUT,Many2One,false,false,false,false") - .putAll("named-query-element|property-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("named-query-element|related-lookup", - "uses,OUT,One2Many,true,false,false,false") - .putAll("instance-group|model", - "targets,OUT,Many2Many,false,false,false,false") - .putAll("newvce|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,false") - .putAll("oam-network|complex", - "definedFor,OUT,Many2Many,false,false,false,false") - .putAll("oam-network|service-capability", - "supportsServiceCapability,OUT,Many2Many,false,false,false,false") - .putAll("p-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("p-interface|physical-link", - "usesPhysicalLink,OUT,Many2Many,false,false,true,false") - .putAll("p-interface|logical-link", - "usesLogicalLink,OUT,Many2One,false,false,false,true") - .putAll("port-group|cvlan-tag", "hasCTag,OUT,Many2Many,true,true,false,true") - .putAll("pserver|complex", "locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|cloud-region","locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|availability-zone","existsIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("pserver|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pserver|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("pnf|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pnf|lag-interface", - "has,OUT,One2Many,true,false,false,true") - .putAll("pnf|complex", - "locatedIn,OUT,Many2One,false,false,false,false") - .putAll("pnf|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("pnf|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("service-instance|cvlan-tag", - "hasIPAGFacingVLAN,OUT,Many2Many,false,true,false,false") - .putAll("service-instance|pnf", - "uses,OUT,One2Many,false,true,false,false") - .putAll("service-subscription|service-instance", - "hasInstance,OUT,Many2Many,true,false,false,reverse") - .putAll("site-pair-set|routing-instance", - "hasRoutingInstance,OUT,Many2Many,true,false,false,false") - .putAll("routing-instance|site-pair", - "hasSitePair,OUT,Many2Many,true,false,false,false") - .putAll("site-pair|class-of-service", - "hasClassOfService,OUT,Many2Many,true,false,false,false") - .putAll("tenant|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,false") - .putAll("tenant|service-subscription", - "relatedTo,OUT,Many2Many,false,false,false,false") - .putAll("tenant|vserver", "owns,OUT,One2Many,true,false,false,reverse") - .putAll("vce|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,false") - .putAll("vce|complex", "locatedIn,OUT,Many2Many,false,false,false,true") - .putAll("vce|port-group", "hasPortGroup,OUT,Many2Many,true,true,false,true") - .putAll("vce|vserver", "runsOnVserver,OUT,Many2Many,false,true,false,true") - .putAll("vce|service-instance", - "hasServiceInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("virtual-data-center|generic-vnf", - "hasVNF,OUT,Many2Many,false,false,false,reverse") - .putAll("vlan|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vlan|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vpe|complex", "locatedIn,OUT,Many2Many,false,false,false,false") - .putAll("vpe|ctag-pool", "usesCtagPool,OUT,Many2Many,false,false,false,false") - .putAll("vpe|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,false") - .putAll("vpe|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,false") - .putAll("vpe|vserver", "runsOnVserver,OUT,Many2Many,false,true,false,false") - .putAll("vpls-pe|complex", "locatedIn,OUT,Many2Many,false,false,false,false") - .putAll("vpls-pe|ctag-pool", - "usesCtagPool,OUT,Many2Many,false,false,false,false") - .putAll("vpls-pe|p-interface", - "hasPinterface,OUT,Many2Many,true,false,false,false") - .putAll("vpls-pe|lag-interface", - "hasLAGinterface,OUT,Many2Many,true,false,false,false") - .putAll("vserver|flavor", "hasFlavor,OUT,Many2One,false,false,false,true") - .putAll("vserver|image", "hasImage,OUT,Many2One,false,false,false,true") - .putAll("vserver|ipaddress", - "hasIpAddress,OUT,Many2Many,true,true,false,false") - .putAll("vserver|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("vserver|pserver", - "runsOnPserver,OUT,Many2One,false,true,false,true") - .putAll("vserver|volume", "hasVolume,OUT,Many2Many,true,true,false,true") - .putAll("vserver|vnfc", "hosts,OUT,Many2Many,false,true,false,true") - .putAll("vserver|snapshot", "uses,OUT,One2One,false,false,false,true") - .putAll("service-instance|connector", "uses,OUT,Many2Many,false,true,false,false") - .putAll("service-instance|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|logical-link", "uses,OUT,Many2Many,false,false,true,false") - .putAll("service-instance|vlan", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("service-instance|service-instance", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("connector|virtual-data-center", "contains,OUT,Many2Many,false,false,false,false") - .putAll("connector|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("virtual-data-center|logical-link", "contains,OUT,Many2Many,false,true,false,false") - .putAll("logical-link|generic-vnf", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|pserver", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("vlan|multicast-configuration", "uses,OUT,Many2Many,false,true,false,false") - .putAll("volume-group|complex", "existsIn,OUT,Many2Many,false,false,false,true") - .putAll("volume-group|tenant", "belongsTo,OUT,Many2Many,false,false,false,true") - .putAll("ipsec-configuration|vig-server", "hasVigServer,OUT,One2Many,true,true,false,false") - .putAll("generic-vnf|ipsec-configuration", "uses,OUT,Many2One,false,true,false,false") - .putAll("vf-module|volume-group", "uses,OUT,One2One,false,false,false,true") - .putAll("vserver|vf-module", "isPartOf,OUT,Many2One,false,false,false,true") - .putAll("vf-module|l3-network", "uses,OUT,Many2Many,false,false,false,true") - .putAll("vf-module|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("generic-vnf|vf-module", "has,OUT,One2Many,true,false,false,true") - .putAll("generic-vnf|volume-group", "uses,OUT,One2Many,false,false,false,true") - .putAll("generic-vnf|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("vlan|logical-link", "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("vpn-binding|route-target", "has,OUT,One2Many,true,false,false,false") - .putAll("service-instance|ctag-assignment","uses,OUT,One2Many,false,false,false,false") - // The next edge is needed in 1702 but will be worked in user story AAI-6848 - //.putAll("service-instance|allotted-resource", "uses,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|generic-vnf", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|l3-network", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|network-policy", "uses,OUT,One2One,false,false,false,false") - .putAll("allotted-resource|vlan", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("service-instance|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|tunnel-xconnect", "has,OUT,One2One,true,false,false,false") - .putAll("logical-link|cloud-region", "existsIn,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|vpn-binding", "uses,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("generic-vnf|license", "has,OUT,One2Many,true,false,false,false") - .putAll("vce|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("vce|license", "has,OUT,One2Many,true,false,false,false") - .putAll("vpe|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("vpe|license", "has,OUT,One2Many,true,false,false,false") - .putAll("zone|complex", "existsIn,OUT,Many2One,false,false,false,false") - .putAll("service-instance|allotted-resource", "has,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|allotted-resource", "uses,OUT,Many2Many,false,false,false,false") - .build(); - - public static final Multimap DefaultDeleteScope = new ImmutableSetMultimap.Builder() - .putAll("customer", "CASCADE_TO_CHILDREN") - .putAll("cloud-region", "THIS_NODE_ONLY") - .putAll("service-subscription", "CASCADE_TO_CHILDREN") - .putAll("service-instance", "CASCADE_TO_CHILDREN") - .putAll("vce", "CASCADE_TO_CHILDREN") - .putAll("port-group", "CASCADE_TO_CHILDREN") - .putAll("cvlan-tag", "THIS_NODE_ONLY") - .putAll("tenant", "THIS_NODE_ONLY") - .putAll("license-key-resource", "ERROR_IF_ANY_IN_EDGES") - .putAll("vserver", "CASCADE_TO_CHILDREN") - .putAll("volume", "THIS_NODE_ONLY") - .putAll("ipaddress", "THIS_NODE_ONLY") - .putAll("image", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("pserver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("availability-zone", "ERROR_IF_ANY_IN_EDGES") - .putAll("oam-network", "ERROR_IF_ANY_IN_EDGES") - .putAll("dvs-switch", "THIS_NODE_ONLY") - .putAll("service-capability", "ERROR_IF_ANY_IN_EDGES") - .putAll("complex", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("flavor", "ERROR_IF_ANY_IN_EDGES") - .putAll("metadata", "THIS_NODE_ONLY") - .putAll("metadatum", "THIS_NODE_ONLY") - .putAll("model", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-ver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-element", "CASCADE_TO_CHILDREN") - .putAll("model-constraint", "CASCADE_TO_CHILDREN") - .putAll("property-constraint", "CASCADE_TO_CHILDREN") - .putAll("related-lookup", "CASCADE_TO_CHILDREN") - .putAll("constrained-element-set", "CASCADE_TO_CHILDREN") - .putAll("element-choice-set", "CASCADE_TO_CHILDREN") - .putAll("named-query", "CASCADE_TO_CHILDREN") - .putAll("named-query-element", "CASCADE_TO_CHILDREN") - .putAll("network-policy", "THIS_NODE_ONLY") - .putAll("collect-lookup", "THIS_NODE_ONLY") - .putAll("service", "ERROR_IF_ANY_IN_EDGES") - .putAll("newvce", "CASCADE_TO_CHILDREN") - .putAll("vpe", "CASCADE_TO_CHILDREN") - .putAll("vpls-pe", "CASCADE_TO_CHILDREN") - .putAll("l-interface", "CASCADE_TO_CHILDREN") - .putAll("vlan", "CASCADE_TO_CHILDREN") - .putAll("p-interface", "CASCADE_TO_CHILDREN") - .putAll("l3-interface-ipv6-address-list", "THIS_NODE_ONLY") - .putAll("l3-interface-ipv4-address-list", "THIS_NODE_ONLY") - .putAll("logical-link", "THIS_NODE_ONLY") - .putAll("physical-link", "THIS_NODE_ONLY") - .putAll("lag-link", "THIS_NODE_ONLY") - .putAll("lag-interface", "CASCADE_TO_CHILDREN") - .putAll("virtual-data-center", "CASCADE_TO_CHILDREN") - .putAll("generic-vnf", "CASCADE_TO_CHILDREN") - .putAll("l3-network", "CASCADE_TO_CHILDREN") - .putAll("ctag-pool", "THIS_NODE_ONLY") - .putAll("subnet", "ERROR_IF_ANY_IN_EDGES") - .putAll("sriov-vf", "THIS_NODE_ONLY") - .putAll("vpn-binding", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("vnf-image", "ERROR_IF_ANY_IN_EDGES") - .putAll("site-pair-set", "CASCADE_TO_CHILDREN") - .putAll("routing-instance", "CASCADE_TO_CHILDREN") - .putAll("site-pair", "CASCADE_TO_CHILDREN") - .putAll("class-of-service", "THIS_NODE_ONLY") - .putAll("connector", "CASCADE_TO_CHILDREN") - .putAll("vnfc", "THIS_NODE_ONLY") - .putAll("multicast-configuration", "THIS_NODE_ONLY") - .putAll("volume-group", "THIS_NODE_ONLY") - .putAll("ctag-assignment", "THIS_NODE_ONLY") - .putAll("pnf", "CASCADE_TO_CHILDREN") - .putAll("ipsec-configuration", "CASCADE_TO_CHILDREN") - .putAll("vig-server", "THIS_NODE_ONLY") - .putAll("vf-module", "THIS_NODE_ONLY") - .putAll("snapshot", "THIS_NODE_ONLY") - .putAll("group-assignment", "THIS_NODE_ONLY") - .putAll("segmentation-assignment", "THIS_NODE_ONLY") - .putAll("route-table-reference", "THIS_NODE_ONLY") - .putAll("network-profile", "THIS_NODE_ONLY") - .putAll("allotted-resource", "CASCADE_TO_CHILDREN") - .putAll("tunnel-xconnect", "THIS_NODE_ONLY") - .putAll("instance-group","THIS_NODE_ONLY") - .putAll("entitlement","THIS_NODE_ONLY") - .putAll("license","THIS_NODE_ONLY") - .putAll("zone", "THIS_NODE_ONLY") - .putAll("route-target", "CASCADE_TO_CHILDREN").build(); - - // NOTE -- Sorry, this is ugly, but we are mapping the nodeTypeCategory two - // ways just to - // make the code a little less bulky. But that means that we need to ensure - // that - // nodeTypeCategory and nodeTypeCatMap are kept in synch. - - // NodeTypeCategory: key is: nodeTypeCategory, value is: - // "nodeTypes,keyProperties,AltKeyProps,depNode4UniquenessFlag" - public static final Multimap NodeTypeCategory = new ImmutableSetMultimap.Builder() - .putAll("vnf", "vce|vpe|generic-vnf,vnf-id,,true").build(); - - // NodeTypeCatMap: key is nodeType; value is: "nodeTypeCategory" - // So -- we're assuming that a nodeType can only be in one nodeTypeCategory. - public static final Map NodeTypeCatMap; - static { - NodeTypeCatMap = new HashMap(); - NodeTypeCatMap.put("vpe", "vnf"); - NodeTypeCatMap.put("vce", "vnf"); - NodeTypeCatMap.put("generic-vnf", "vnf"); - } - - // ReservedPropNames: keys are property names of (node) properties that are - // common to all nodes and - // should not be removed if not passed in on an UPDATE request. - public static final Map ReservedPropNames; - static { - ReservedPropNames = new HashMap(); - ReservedPropNames.put("source-of-truth", ""); - ReservedPropNames.put("last-mod-source-of-truth", ""); - ReservedPropNames.put("aai-created-ts", ""); - ReservedPropNames.put("aai-last-mod-ts", ""); - } - - // This just lists which node types can be connected to themselves recursively. - // It's temporary - since DbEdgeRules is going to be overhauled in 16-10, this will - // get generated automatically. But for 1607, it can work like this. - public static final Map CanBeRecursiveNT; - static { - CanBeRecursiveNT = new HashMap(); - CanBeRecursiveNT.put("model-element", ""); - CanBeRecursiveNT.put("service-instance", ""); - CanBeRecursiveNT.put("named-query-element", ""); - } - -} diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/v8/gen/DbEdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/v8/gen/DbEdgeRules.java deleted file mode 100644 index fac0ae48..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/v8/gen/DbEdgeRules.java +++ /dev/null @@ -1,300 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel.v8.gen; - -import java.util.HashMap; -import java.util.Map; - -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; - -public class DbEdgeRules { - - /* - * The EdgeRules data is set up as a key (fromNodeTypeA|toNodeTypeB) mapped - * to a string which holds the info we need to build an edge from nodeTypeA - * to nodeTypeB. Note -- the MultiMap will let us define more than one type - * of edge between a given pair of nodeTypes, but for now we never define - * more than one. - * - * The edgeInfo part is comma separated and looks like this: - * "edgeLabel,direction,multiplicityRule,isParent,usesResource,hasDelTarget,SVC-INFRA" This - * format is encoded into the EdgeInfoMap below. - * MultiplicityRule can be either "Many2Many", "Many2One", "One2Many" or "One2One" - * The values for the things after multiplicityRule can be either "true", "false" or "reverse". "reverse" is - * really saying that this tag does apply, but the edge will be traversed - * the opposite way from the same tag that just has "true". - */ - public static final Map EdgeInfoMap; - static { - EdgeInfoMap = new HashMap(); - EdgeInfoMap.put(0, "edgeLabel"); - EdgeInfoMap.put(1, "direction"); - EdgeInfoMap.put(2, "multiplicityRule"); - EdgeInfoMap.put(3, "isParent"); - EdgeInfoMap.put(4, "usesResource"); - EdgeInfoMap.put(5, "hasDelTarget"); - EdgeInfoMap.put(6, "SVC-INFRA"); - } - - public static Integer firstTagIndex = 3; - - public static final Multimap EdgeRules = new ImmutableSetMultimap.Builder() - .putAll("cloud-region|l3-network", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|tenant", - "has,OUT,One2Many,true,false,false,reverse") - .putAll("cloud-region|image", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|flavor", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|availability-zone", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|volume-group", - "has,OUT,One2Many,true,true,false,false") - .putAll("cloud-region|group-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|snapshot", - "has,OUT,One2Many,true,false,false,false") - .putAll("customer|service-subscription", - "subscribesTo,OUT,Many2Many,true,false,false,reverse") - .putAll("generic-vnf|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,true") - .putAll("generic-vnf|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|l3-network", - "usesL3Network,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|pserver", - "runsOnPserver,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|vserver", - "runsOnVserver,OUT,One2Many,false,true,false,true") - .putAll("generic-vnf|service-instance", - "hasInstance,OUT,Many2Many,false,true,false,true") - .putAll("group-assignment|tenant", - "has,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|pserver", - "has,OUT,One2Many,false,false,false,false") - .putAll("image|metadata", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("image|metadatum", - "hasMetaDatum,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|logical-link", - "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("l-interface|vlan","hasVlan,OUT,Many2Many,true,false,false,false") - .putAll("l3-interface-ipv4-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv4-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|subnet", - "hasSubnet,OUT,Many2Many,true,false,false,reverse") - .putAll("l3-network|service-instance", - "hasInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("l3-network|ctag-assignment", - "hasCtagAssignment,OUT,Many2Many,true,false,false,true") - .putAll("l3-network|segmentation-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("lag-interface|p-interface", - "usesPInterface,OUT,Many2Many,false,true,false,true") - .putAll("lag-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("logical-link|pnf", - "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|logical-link", - "uses,OUT,One2Many,false,false,false,true") - .putAll("model|model-element", - "startsWith,OUT,One2Many,true,false,false,false") - .putAll("model-element|model", - "isA,OUT,Many2One,false,false,false,false") - .putAll("model|metadatum", - "hasMetaData,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-element", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("model-element|constrained-element-set", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-constraint|constrained-element-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("constrained-element-set|element-choice-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("element-choice-set|model-element", - "has,OUT,One2Many,true,false,false,false") - .putAll("named-query|model", - "relatedTo,OUT,One2Many,false,false,false,false") - .putAll("named-query|named-query-element", - "startsWith,OUT,One2One,true,false,false,false") - .putAll("named-query-element|named-query-element", - "connectsTo,OUT,Many2Many,true,false,false,false") - .putAll("named-query-element|model", - "isA,OUT,Many2One,false,false,false,false") - .putAll("named-query-element|property-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("named-query-element|related-lookup", - "uses,OUT,One2Many,true,false,false,false") - .putAll("p-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("p-interface|physical-link", - "usesPhysicalLink,OUT,Many2Many,false,false,true,false") - .putAll("p-interface|logical-link", - "usesLogicalLink,OUT,Many2One,false,false,false,true") - .putAll("pserver|cloud-region","locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|availability-zone","existsIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("pserver|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pnf|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pnf|lag-interface", - "has,OUT,One2Many,true,false,false,true") - .putAll("service-instance|pnf", - "uses,OUT,One2Many,false,true,false,false") - .putAll("service-subscription|service-instance", - "hasInstance,OUT,Many2Many,true,false,false,reverse") - .putAll("tenant|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,false") - .putAll("tenant|service-subscription", - "relatedTo,OUT,Many2Many,false,false,false,false") - .putAll("tenant|vserver", "owns,OUT,One2Many,true,false,false,reverse") - .putAll("vlan|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vlan|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vserver|flavor", "hasFlavor,OUT,Many2One,false,false,false,true") - .putAll("vserver|image", "hasImage,OUT,Many2One,false,false,false,true") - .putAll("vserver|ipaddress", - "hasIpAddress,OUT,Many2Many,true,true,false,false") - .putAll("vserver|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("vserver|pserver", - "runsOnPserver,OUT,Many2One,false,true,false,true") - .putAll("vserver|volume", "hasVolume,OUT,Many2Many,true,true,false,true") - .putAll("vserver|vnfc", "hosts,OUT,Many2Many,false,true,false,true") - .putAll("vserver|snapshot", "uses,OUT,One2One,false,false,false,true") - .putAll("service-instance|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|logical-link", "uses,OUT,Many2Many,false,false,true,false") - .putAll("service-instance|vlan", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("service-instance|service-instance", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("logical-link|generic-vnf", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|pserver", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("volume-group|tenant", "belongsTo,OUT,Many2Many,false,false,false,true") - .putAll("vf-module|volume-group", "uses,OUT,One2One,false,false,false,true") - .putAll("vserver|vf-module", "isPartOf,OUT,Many2One,false,false,false,true") - .putAll("vf-module|l3-network", "uses,OUT,Many2Many,false,false,false,true") - .putAll("vf-module|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("generic-vnf|vf-module", "has,OUT,One2Many,true,false,false,true") - .putAll("generic-vnf|volume-group", "uses,OUT,One2Many,false,false,false,true") - .putAll("generic-vnf|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("vlan|logical-link", "usesLogicalLink,OUT,One2One,false,false,true,true") - .build(); - - public static final Multimap DefaultDeleteScope = new ImmutableSetMultimap.Builder() - .putAll("customer", "CASCADE_TO_CHILDREN") - .putAll("cloud-region", "THIS_NODE_ONLY") - .putAll("service-subscription", "CASCADE_TO_CHILDREN") - .putAll("service-instance", "CASCADE_TO_CHILDREN") - .putAll("tenant", "CASCADE_TO_CHILDREN") - .putAll("vserver", "CASCADE_TO_CHILDREN") - .putAll("volume", "THIS_NODE_ONLY") - .putAll("ipaddress", "THIS_NODE_ONLY") - .putAll("image", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("pserver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("availability-zone", "ERROR_IF_ANY_IN_EDGES") - .putAll("flavor", "ERROR_IF_ANY_IN_EDGES") - .putAll("metadata", "THIS_NODE_ONLY") - .putAll("metadatum", "THIS_NODE_ONLY") - .putAll("model", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-element", "CASCADE_TO_CHILDREN") - .putAll("named-query", "CASCADE_TO_CHILDREN") - .putAll("named-query-element", "CASCADE_TO_CHILDREN") - .putAll("collect-lookup", "THIS_NODE_ONLY") - .putAll("service", "ERROR_IF_ANY_IN_EDGES") - .putAll("l-interface", "CASCADE_TO_CHILDREN") - .putAll("vlan", "CASCADE_TO_CHILDREN") - .putAll("p-interface", "CASCADE_TO_CHILDREN") - .putAll("l3-interface-ipv6-address-list", "THIS_NODE_ONLY") - .putAll("l3-interface-ipv4-address-list", "THIS_NODE_ONLY") - .putAll("logical-link", "THIS_NODE_ONLY") - .putAll("physical-link", "THIS_NODE_ONLY") - .putAll("lag-interface", "CASCADE_TO_CHILDREN") - .putAll("l3-network", "CASCADE_TO_CHILDREN") - .putAll("subnet", "THIS_NODE_ONLY") - .putAll("vnfc", "THIS_NODE_ONLY") - .putAll("volume-group", "THIS_NODE_ONLY") - .putAll("ctag-assignment", "THIS_NODE_ONLY") - .putAll("pnf", "CASCADE_TO_CHILDREN") - .putAll("vf-module", "THIS_NODE_ONLY") - .putAll("snapshot", "THIS_NODE_ONLY") - .putAll("group-assignment", "THIS_NODE_ONLY") - .putAll("segmentation-assignment", "THIS_NODE_ONLY") - .putAll("generic-vnf", "CASCADE_TO_CHILDREN").build(); - - // NOTE -- Sorry, this is ugly, but we are mapping the nodeTypeCategory two - // ways just to - // make the code a little less bulky. But that means that we need to ensure - // that - // nodeTypeCategory and nodeTypeCatMap are kept in synch. - - // NodeTypeCategory: key is: nodeTypeCategory, value is: - // "nodeTypes,keyProperties,AltKeyProps,depNode4UniquenessFlag" - public static final Multimap NodeTypeCategory = new ImmutableSetMultimap.Builder() - .putAll("vnf", "generic-vnf,vnf-id,,true").build(); - - // NodeTypeCatMap: key is nodeType; value is: "nodeTypeCategory" - // So -- we're assuming that a nodeType can only be in one nodeTypeCategory. - public static final Map NodeTypeCatMap; - static { - NodeTypeCatMap = new HashMap(); - NodeTypeCatMap.put("generic-vnf", "vnf"); - } - - // ReservedPropNames: keys are property names of (node) properties that are - // common to all nodes and - // should not be removed if not passed in on an UPDATE request. - public static final Map ReservedPropNames; - static { - ReservedPropNames = new HashMap(); - ReservedPropNames.put("source-of-truth", ""); - ReservedPropNames.put("last-mod-source-of-truth", ""); - ReservedPropNames.put("aai-created-ts", ""); - ReservedPropNames.put("aai-last-mod-ts", ""); - } - - // This just lists which node types can be connected to themselves recursively. - // It's temporary - since DbEdgeRules is going to be overhauled in 16-10, this will - // get generated automatically. But for 1607, it can work like this. - public static final Map CanBeRecursiveNT; - static { - CanBeRecursiveNT = new HashMap(); - CanBeRecursiveNT.put("model-element", ""); - CanBeRecursiveNT.put("named-query-element", ""); - } - -} diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/v9/gen/DbEdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/v9/gen/DbEdgeRules.java deleted file mode 100644 index 8e75c4d3..00000000 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/v9/gen/DbEdgeRules.java +++ /dev/null @@ -1,459 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel.v9.gen; - -import java.util.HashMap; -import java.util.Map; - -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; - -public class DbEdgeRules { - - /* - * The EdgeRules data is set up as a key (fromNodeTypeA|toNodeTypeB) mapped - * to a string which holds the info we need to build an edge from nodeTypeA - * to nodeTypeB. Note -- the MultiMap will let us define more than one type - * of edge between a given pair of nodeTypes, but for now we never define - * more than one. - * - * The edgeInfo part is comma separated and looks like this: - * "edgeLabel,direction,multiplicityRule,isParent,usesResource,hasDelTarget,SVC-INFRA" This - * format is encoded into the EdgeInfoMap below. - * MultiplicityRule can be either "Many2Many", "Many2One", "One2Many" or "One2One" - * The values for the things after multiplicityRule can be either "true", "false" or "reverse". "reverse" is - * really saying that this tag does apply, but the edge will be traversed - * the opposite way from the same tag that just has "true". - */ - public static final Map EdgeInfoMap; - static { - EdgeInfoMap = new HashMap(); - EdgeInfoMap.put(0, "edgeLabel"); - EdgeInfoMap.put(1, "direction"); - EdgeInfoMap.put(2, "multiplicityRule"); - EdgeInfoMap.put(3, "isParent"); - EdgeInfoMap.put(4, "usesResource"); - EdgeInfoMap.put(5, "hasDelTarget"); - EdgeInfoMap.put(6, "SVC-INFRA"); - } - - public static Integer firstTagIndex = 3; - - public static final Multimap EdgeRules = new ImmutableSetMultimap.Builder() - .putAll("availability-zone|complex", - "groupsResourcesIn,OUT,Many2Many,false,false,false,false") - .putAll("availability-zone|service-capability", - "supportsServiceCapability,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|complex", - "locatedIn,OUT,Many2One,false,false,false,false") - .putAll("cloud-region|l3-network", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("cloud-region|tenant", - "has,OUT,One2Many,true,false,false,reverse") - .putAll("cloud-region|image", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|flavor", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|availability-zone", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|oam-network", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|dvs-switch", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|volume-group", - "has,OUT,One2Many,true,true,false,false") - .putAll("cloud-region|group-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|snapshot", - "has,OUT,One2Many,true,false,false,false") - .putAll("cloud-region|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("complex|ctag-pool", - "hasCtagPool,OUT,Many2Many,true,false,false,false") - .putAll("complex|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,true") - .putAll("ctag-pool|availability-zone", - "supportsAvailabilityZone,OUT,Many2Many,false,false,false,false") - .putAll("customer|service-subscription", - "subscribesTo,OUT,Many2Many,true,false,false,reverse") - .putAll("dvs-switch|availability-zone", - "existsIn,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,true") - .putAll("generic-vnf|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("generic-vnf|l3-network", - "usesL3Network,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|pserver", - "runsOnPserver,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|vnf-image", - "usesVnfImage,OUT,Many2One,false,false,false,true") - .putAll("generic-vnf|vserver", - "runsOnVserver,OUT,One2Many,false,true,false,true") - .putAll("generic-vnf|service-instance", - "hasInstance,OUT,Many2Many,false,true,false,true") - .putAll("generic-vnf|site-pair-set", - "hasSitePairSet,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|network-profile", - "hasNetworkProfile,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|tenant", - "has,OUT,Many2Many,false,false,false,false") - .putAll("group-assignment|pserver", - "has,OUT,One2Many,false,false,false,false") - .putAll("image|metadata", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("image|metadatum", - "hasMetaDatum,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("l-interface|logical-link", - "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("l-interface|vlan","hasVlan,OUT,Many2Many,true,false,false,false") - .putAll("l-interface|sriov-vf","has,OUT,One2One,true,false,false,false") - .putAll("l3-interface-ipv4-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|l3-network", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv4-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-interface-ipv6-address-list|subnet", - "isMemberOf,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|vpn-binding", - "usesVpnBinding,OUT,Many2Many,false,false,false,false") - .putAll("l3-network|subnet", - "hasSubnet,OUT,Many2Many,true,false,false,reverse") - .putAll("l3-network|service-instance", - "hasInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("l3-network|ctag-assignment", - "hasCtagAssignment,OUT,Many2Many,true,false,false,true") - .putAll("l3-network|network-policy", - "uses,OUT,Many2Many,false,false,false,true") - .putAll("l3-network|segmentation-assignment", - "has,OUT,One2Many,true,false,false,false") - .putAll("l3-network|route-table-reference", - "uses,OUT,Many2Many,false,false,false,false") - .putAll("lag-interface|lag-link", - "usesLAGLink,OUT,Many2Many,false,true,true,true") - .putAll("lag-interface|p-interface", - "usesPInterface,OUT,Many2Many,false,true,false,true") - .putAll("lag-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("logical-link|lag-link", - "usesLAGLink,OUT,Many2Many,false,true,false,true") - .putAll("logical-link|pnf", - "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|logical-link", - "uses,OUT,One2Many,false,false,false,true") - .putAll("model|model-ver", - "has,OUT,One2Many,true,false,false,false") - .putAll("model-ver|model-element", - "startsWith,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-ver", - "isA,OUT,Many2One,false,false,false,false") - .putAll("model-ver|metadatum", - "hasMetaData,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-element", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-element|model-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("model-element|constrained-element-set", - "connectsTo,OUT,One2Many,true,false,false,false") - .putAll("model-constraint|constrained-element-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("constrained-element-set|element-choice-set", - "uses,OUT,One2Many,true,false,false,false") - .putAll("element-choice-set|model-element", - "has,OUT,One2Many,true,false,false,false") - .putAll("named-query|model", - "relatedTo,OUT,One2Many,false,false,false,false") - .putAll("named-query|named-query-element", - "startsWith,OUT,One2One,true,false,false,false") - .putAll("named-query-element|named-query-element", - "connectsTo,OUT,Many2Many,true,false,false,false") - .putAll("named-query-element|model", - "isA,OUT,Many2One,false,false,false,false") - .putAll("named-query-element|property-constraint", - "uses,OUT,One2Many,true,false,false,false") - .putAll("named-query-element|related-lookup", - "uses,OUT,One2Many,true,false,false,false") - .putAll("instance-group|model", - "targets,OUT,Many2Many,false,false,false,false") - .putAll("newvce|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,false") - .putAll("oam-network|complex", - "definedFor,OUT,Many2Many,false,false,false,false") - .putAll("oam-network|service-capability", - "supportsServiceCapability,OUT,Many2Many,false,false,false,false") - .putAll("p-interface|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("p-interface|physical-link", - "usesPhysicalLink,OUT,Many2Many,false,false,true,false") - .putAll("p-interface|logical-link", - "usesLogicalLink,OUT,Many2One,false,false,false,true") - .putAll("port-group|cvlan-tag", "hasCTag,OUT,Many2Many,true,true,false,true") - .putAll("pserver|complex", "locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|cloud-region","locatedIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|availability-zone","existsIn,OUT,Many2One,false,false,false,true") - .putAll("pserver|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,true") - .putAll("pserver|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pserver|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("pnf|p-interface", - "hasPinterface,OUT,Many2Many,true,true,false,true") - .putAll("pnf|lag-interface", - "has,OUT,One2Many,true,false,false,true") - .putAll("pnf|complex", - "locatedIn,OUT,Many2One,false,false,false,false") - .putAll("pnf|instance-group", - "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("pnf|zone", - "isMemberOf,OUT,Many2One,false,false,false,false") - .putAll("service-instance|cvlan-tag", - "hasIPAGFacingVLAN,OUT,Many2Many,false,true,false,false") - .putAll("service-instance|pnf", - "uses,OUT,One2Many,false,true,false,false") - .putAll("service-subscription|service-instance", - "hasInstance,OUT,Many2Many,true,false,false,reverse") - .putAll("site-pair-set|routing-instance", - "hasRoutingInstance,OUT,Many2Many,true,false,false,false") - .putAll("routing-instance|site-pair", - "hasSitePair,OUT,Many2Many,true,false,false,false") - .putAll("site-pair|class-of-service", - "hasClassOfService,OUT,Many2Many,true,false,false,false") - .putAll("tenant|l3-network", - "usesL3Network,OUT,Many2Many,false,false,false,false") - .putAll("tenant|service-subscription", - "relatedTo,OUT,Many2Many,false,false,false,false") - .putAll("tenant|vserver", "owns,OUT,One2Many,true,false,false,reverse") - .putAll("vce|availability-zone", - "hasAvailabilityZone,OUT,Many2Many,false,false,false,false") - .putAll("vce|complex", "locatedIn,OUT,Many2Many,false,false,false,true") - .putAll("vce|port-group", "hasPortGroup,OUT,Many2Many,true,true,false,true") - .putAll("vce|vserver", "runsOnVserver,OUT,Many2Many,false,true,false,true") - .putAll("vce|service-instance", - "hasServiceInstance,OUT,Many2Many,false,false,false,reverse") - .putAll("virtual-data-center|generic-vnf", - "hasVNF,OUT,Many2Many,false,false,false,reverse") - .putAll("vlan|l3-interface-ipv4-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vlan|l3-interface-ipv6-address-list", - "hasIpAddress,OUT,Many2Many,true,false,false,true") - .putAll("vpe|complex", "locatedIn,OUT,Many2Many,false,false,false,false") - .putAll("vpe|ctag-pool", "usesCtagPool,OUT,Many2Many,false,false,false,false") - .putAll("vpe|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,false") - .putAll("vpe|lag-interface", - "hasLAGInterface,OUT,Many2Many,true,false,false,false") - .putAll("vpe|vserver", "runsOnVserver,OUT,Many2Many,false,true,false,false") - .putAll("vpls-pe|complex", "locatedIn,OUT,Many2Many,false,false,false,false") - .putAll("vpls-pe|ctag-pool", - "usesCtagPool,OUT,Many2Many,false,false,false,false") - .putAll("vpls-pe|p-interface", - "hasPinterface,OUT,Many2Many,true,false,false,false") - .putAll("vpls-pe|lag-interface", - "hasLAGinterface,OUT,Many2Many,true,false,false,false") - .putAll("vserver|flavor", "hasFlavor,OUT,Many2One,false,false,false,true") - .putAll("vserver|image", "hasImage,OUT,Many2One,false,false,false,true") - .putAll("vserver|ipaddress", - "hasIpAddress,OUT,Many2Many,true,true,false,false") - .putAll("vserver|l-interface", - "hasLInterface,OUT,Many2Many,true,false,false,true") - .putAll("vserver|pserver", - "runsOnPserver,OUT,Many2One,false,true,false,true") - .putAll("vserver|volume", "hasVolume,OUT,Many2Many,true,true,false,true") - .putAll("vserver|vnfc", "hosts,OUT,Many2Many,false,true,false,true") - .putAll("vserver|snapshot", "uses,OUT,One2One,false,false,false,true") - .putAll("service-instance|connector", "uses,OUT,Many2Many,false,true,false,false") - .putAll("service-instance|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|logical-link", "uses,OUT,Many2Many,false,false,true,false") - .putAll("service-instance|vlan", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("service-instance|service-instance", "dependsOn,OUT,One2Many,false,true,false,false") - .putAll("connector|virtual-data-center", "contains,OUT,Many2Many,false,false,false,false") - .putAll("connector|metadatum", "hasMetaData,OUT,Many2Many,true,false,false,false") - .putAll("virtual-data-center|logical-link", "contains,OUT,Many2Many,false,true,false,false") - .putAll("logical-link|generic-vnf", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|pserver", "bridgedTo,OUT,Many2Many,false,false,false,false") - .putAll("vlan|multicast-configuration", "uses,OUT,Many2Many,false,true,false,false") - .putAll("volume-group|complex", "existsIn,OUT,Many2Many,false,false,false,true") - .putAll("volume-group|tenant", "belongsTo,OUT,Many2Many,false,false,false,true") - .putAll("ipsec-configuration|vig-server", "hasVigServer,OUT,One2Many,true,true,false,false") - .putAll("generic-vnf|ipsec-configuration", "uses,OUT,Many2One,false,true,false,false") - .putAll("vf-module|volume-group", "uses,OUT,One2One,false,false,false,true") - .putAll("vserver|vf-module", "isPartOf,OUT,Many2One,false,false,false,true") - .putAll("vf-module|l3-network", "uses,OUT,Many2Many,false,false,false,true") - .putAll("vf-module|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("generic-vnf|vf-module", "has,OUT,One2Many,true,false,false,true") - .putAll("generic-vnf|volume-group", "uses,OUT,One2Many,false,false,false,true") - .putAll("generic-vnf|vnfc", "uses,OUT,One2Many,false,false,true,true") - .putAll("vlan|logical-link", "usesLogicalLink,OUT,Many2Many,false,false,true,true") - .putAll("service-instance|ctag-assignment","uses,OUT,One2Many,false,false,false,false") - // The next edge is needed in 1702 but will be worked in user story AAI-6848 - //.putAll("service-instance|allotted-resource", "uses,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|generic-vnf", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|l3-network", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|vlan", "isPartOf,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("service-instance|instance-group", "isMemberOf,OUT,Many2Many,false,false,false,false") - .putAll("allotted-resource|tunnel-xconnect", "has,OUT,One2One,true,false,false,false") - .putAll("logical-link|cloud-region", "existsIn,OUT,Many2Many,false,false,false,false") - .putAll("logical-link|vpn-binding", "uses,OUT,Many2Many,false,false,false,false") - .putAll("generic-vnf|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("generic-vnf|license", "has,OUT,One2Many,true,false,false,false") - .putAll("vce|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("vce|license", "has,OUT,One2Many,true,false,false,false") - .putAll("vpe|entitlement", "has,OUT,One2Many,true,false,false,false") - .putAll("vpe|license", "has,OUT,One2Many,true,false,false,false") - .putAll("zone|complex", "existsIn,OUT,Many2One,false,false,false,false") - .putAll("service-instance|allotted-resource", "has,OUT,Many2Many,true,false,false,false") - .putAll("service-instance|allotted-resource", "uses,OUT,Many2Many,false,false,false,false") - .build(); - - public static final Multimap DefaultDeleteScope = new ImmutableSetMultimap.Builder() - .putAll("customer", "CASCADE_TO_CHILDREN") - .putAll("cloud-region", "THIS_NODE_ONLY") - .putAll("service-subscription", "CASCADE_TO_CHILDREN") - .putAll("service-instance", "CASCADE_TO_CHILDREN") - .putAll("vce", "CASCADE_TO_CHILDREN") - .putAll("port-group", "CASCADE_TO_CHILDREN") - .putAll("cvlan-tag", "THIS_NODE_ONLY") - .putAll("tenant", "THIS_NODE_ONLY") - .putAll("vserver", "CASCADE_TO_CHILDREN") - .putAll("volume", "THIS_NODE_ONLY") - .putAll("ipaddress", "THIS_NODE_ONLY") - .putAll("image", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("pserver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("availability-zone", "ERROR_IF_ANY_IN_EDGES") - .putAll("oam-network", "ERROR_IF_ANY_IN_EDGES") - .putAll("dvs-switch", "THIS_NODE_ONLY") - .putAll("service-capability", "ERROR_IF_ANY_IN_EDGES") - .putAll("complex", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("flavor", "ERROR_IF_ANY_IN_EDGES") - .putAll("metadata", "THIS_NODE_ONLY") - .putAll("metadatum", "THIS_NODE_ONLY") - .putAll("model", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-ver", "ERROR_4_IN_EDGES_OR_CASCADE") - .putAll("model-element", "CASCADE_TO_CHILDREN") - .putAll("model-constraint", "CASCADE_TO_CHILDREN") - .putAll("property-constraint", "CASCADE_TO_CHILDREN") - .putAll("related-lookup", "CASCADE_TO_CHILDREN") - .putAll("constrained-element-set", "CASCADE_TO_CHILDREN") - .putAll("element-choice-set", "CASCADE_TO_CHILDREN") - .putAll("named-query", "CASCADE_TO_CHILDREN") - .putAll("named-query-element", "CASCADE_TO_CHILDREN") - .putAll("network-policy", "THIS_NODE_ONLY") - .putAll("collect-lookup", "THIS_NODE_ONLY") - .putAll("service", "ERROR_IF_ANY_IN_EDGES") - .putAll("newvce", "CASCADE_TO_CHILDREN") - .putAll("vpe", "CASCADE_TO_CHILDREN") - .putAll("vpls-pe", "CASCADE_TO_CHILDREN") - .putAll("l-interface", "CASCADE_TO_CHILDREN") - .putAll("vlan", "CASCADE_TO_CHILDREN") - .putAll("p-interface", "CASCADE_TO_CHILDREN") - .putAll("l3-interface-ipv6-address-list", "THIS_NODE_ONLY") - .putAll("l3-interface-ipv4-address-list", "THIS_NODE_ONLY") - .putAll("logical-link", "THIS_NODE_ONLY") - .putAll("physical-link", "THIS_NODE_ONLY") - .putAll("lag-link", "THIS_NODE_ONLY") - .putAll("lag-interface", "CASCADE_TO_CHILDREN") - .putAll("virtual-data-center", "CASCADE_TO_CHILDREN") - .putAll("generic-vnf", "CASCADE_TO_CHILDREN") - .putAll("l3-network", "CASCADE_TO_CHILDREN") - .putAll("ctag-pool", "THIS_NODE_ONLY") - .putAll("subnet", "THIS_NODE_ONLY") - .putAll("sriov-vf", "THIS_NODE_ONLY") - .putAll("vpn-binding", "ERROR_IF_ANY_IN_EDGES") - .putAll("vnf-image", "ERROR_IF_ANY_IN_EDGES") - .putAll("site-pair-set", "CASCADE_TO_CHILDREN") - .putAll("routing-instance", "CASCADE_TO_CHILDREN") - .putAll("site-pair", "CASCADE_TO_CHILDREN") - .putAll("class-of-service", "THIS_NODE_ONLY") - .putAll("connector", "CASCADE_TO_CHILDREN") - .putAll("vnfc", "THIS_NODE_ONLY") - .putAll("multicast-configuration", "THIS_NODE_ONLY") - .putAll("volume-group", "THIS_NODE_ONLY") - .putAll("ctag-assignment", "THIS_NODE_ONLY") - .putAll("pnf", "CASCADE_TO_CHILDREN") - .putAll("ipsec-configuration", "CASCADE_TO_CHILDREN") - .putAll("vig-server", "THIS_NODE_ONLY") - .putAll("vf-module", "THIS_NODE_ONLY") - .putAll("snapshot", "THIS_NODE_ONLY") - .putAll("group-assignment", "THIS_NODE_ONLY") - .putAll("segmentation-assignment", "THIS_NODE_ONLY") - .putAll("route-table-reference", "THIS_NODE_ONLY") - .putAll("network-profile", "THIS_NODE_ONLY") - .putAll("allotted-resource", "CASCADE_TO_CHILDREN") - .putAll("tunnel-xconnect", "THIS_NODE_ONLY") - .putAll("instance-group","THIS_NODE_ONLY") - .putAll("entitlement","THIS_NODE_ONLY") - .putAll("license","THIS_NODE_ONLY") - .putAll("zone", "THIS_NODE_ONLY").build(); - - // NOTE -- Sorry, this is ugly, but we are mapping the nodeTypeCategory two - // ways just to - // make the code a little less bulky. But that means that we need to ensure - // that - // nodeTypeCategory and nodeTypeCatMap are kept in synch. - - // NodeTypeCategory: key is: nodeTypeCategory, value is: - // "nodeTypes,keyProperties,AltKeyProps,depNode4UniquenessFlag" - public static final Multimap NodeTypeCategory = new ImmutableSetMultimap.Builder() - .putAll("vnf", "vce|vpe|generic-vnf,vnf-id,,true").build(); - - // NodeTypeCatMap: key is nodeType; value is: "nodeTypeCategory" - // So -- we're assuming that a nodeType can only be in one nodeTypeCategory. - public static final Map NodeTypeCatMap; - static { - NodeTypeCatMap = new HashMap(); - NodeTypeCatMap.put("vpe", "vnf"); - NodeTypeCatMap.put("vce", "vnf"); - NodeTypeCatMap.put("generic-vnf", "vnf"); - } - - // ReservedPropNames: keys are property names of (node) properties that are - // common to all nodes and - // should not be removed if not passed in on an UPDATE request. - public static final Map ReservedPropNames; - static { - ReservedPropNames = new HashMap(); - ReservedPropNames.put("source-of-truth", ""); - ReservedPropNames.put("last-mod-source-of-truth", ""); - ReservedPropNames.put("aai-created-ts", ""); - ReservedPropNames.put("aai-last-mod-ts", ""); - } - - // This just lists which node types can be connected to themselves recursively. - // It's temporary - since DbEdgeRules is going to be overhauled in 16-10, this will - // get generated automatically. But for 1607, it can work like this. - public static final Map CanBeRecursiveNT; - static { - CanBeRecursiveNT = new HashMap(); - CanBeRecursiveNT.put("model-element", ""); - CanBeRecursiveNT.put("service-instance", ""); - CanBeRecursiveNT.put("named-query-element", ""); - } - -} diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java index 22a94554..8dbff6c4 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java @@ -56,7 +56,7 @@ import com.jayway.jsonpath.JsonPath; public class EdgeRules { private EELFLogger logger = EELFManager.getInstance().getLogger(EdgeRules.class); - + private DocumentContext rulesDoc; /** @@ -75,17 +75,17 @@ public class EdgeRules { String json = this.getEdgeRuleJson(rulesFilename); rulesDoc = JsonPath.parse(json); } - + private String getEdgeRuleJson(String rulesFilename) { InputStream is = getClass().getResourceAsStream(rulesFilename); Scanner scanner = new Scanner(is); String json = scanner.useDelimiter("\\Z").next(); scanner.close(); - + return json; } - + /** * Loads the versioned DbEdgeRules json file for later parsing. */ @@ -93,6 +93,13 @@ public class EdgeRules { private EdgeRules(Version version) { String json = this.getEdgeRuleJson(version); rulesDoc = JsonPath.parse(json); + + if (!Version.isLatest(version)) { + try { + Class dbEdgeRules = Class.forName("org.openecomp.aai.dbmodel." + version.toString() + ".gen.DbEdgeRules"); + } catch (Exception e) { + } + } } private String getEdgeRuleJson(Version version) { @@ -108,11 +115,11 @@ public class EdgeRules { private static class Helper { private static final EdgeRules INSTANCE = new EdgeRules(); private static final Map INSTANCEMAP = new ConcurrentHashMap<>(); - + private static EdgeRules getEdgeRulesByFilename(String rulesFilename) { return new EdgeRules(rulesFilename); } - + private static EdgeRules getVersionedEdgeRules(Version v) { if (Version.isLatest(v)) { return INSTANCE; @@ -146,14 +153,14 @@ public class EdgeRules { /** * Loads edge rules from the given file. - * + * * @param rulesFilename - name of the file to load rules from * @return the EdgeRules instance */ public static EdgeRules getInstance(String rulesFilename) { return Helper.getEdgeRulesByFilename(rulesFilename); } - + /** * Adds the tree edge. * @@ -318,8 +325,8 @@ public class EdgeRules { return result; } - - + + /** * Gets the edge rule of the given type that exists between A and B. * Will check B|A as well, and flips the direction accordingly if that succeeds @@ -492,7 +499,7 @@ public class EdgeRules { /** * Verifies that all required properties are defined in the given edge rule. * If they are not, throws a RuntimeException. - * + * * @param rule - Map representing * an edge rule */ @@ -512,21 +519,21 @@ public class EdgeRules { } } } - + /** * Reads all the edge rules from the loaded json file. - * + * * @return List> * Each map represents a rule read from the json. */ private List> readRules() { return readRules(null); } - + /** * Reads the edge rules from the loaded json file, using the given filter * to get specific rules. If filter is null, will get all rules. - * + * * @param filter - may be null to indicate get all * @return List> * Each map represents a rule read from the json. @@ -543,7 +550,7 @@ public class EdgeRules { } return results; } - + /** * Gets all the edge rules we define. * @@ -562,10 +569,10 @@ public class EdgeRules { return result; } - /** + /** * Gets all edge rules that define a child relationship from * the given node type. - * + * * @param nodeType * @return */ diff --git a/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java b/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java index b3c78410..15ea8a32 100644 --- a/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java +++ b/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java @@ -20,49 +20,22 @@ package org.openecomp.aai.util; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Scanner; -import java.util.StringTokenizer; -import java.util.Vector; +import com.google.common.base.Joiner; +import com.jayway.jsonpath.JsonPath; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.serialization.db.EdgeProperty; +import org.w3c.dom.*; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.openecomp.aai.dbmodel.DbEdgeRules; -import org.openecomp.aai.introspection.Version; -import org.openecomp.aai.serialization.db.EdgeProperty; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.NodeList; - -import com.google.common.base.Joiner; -import com.google.common.collect.Multimap; -import com.jayway.jsonpath.JsonPath; +import javax.xml.xpath.*; +import java.io.*; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; @@ -78,7 +51,6 @@ public class GenerateXsd { static Map generatedJavaType; static Map appliedPaths; static NodeList javaTypeNodes; - static Class versionedClass; public static final int VALUE_NONE = 0; @@ -803,19 +775,6 @@ public class GenerateXsd { return result; } - private static Class getEdgeRulesClass() throws ClassNotFoundException { - Class result = null; - - // If a class matching the apiVersion exists, we are generating documentation for a prior release - // Otherwise, we're generated documentation for the current release. - try { - result = Class.forName("org.openecomp.aai.dbmodel." + apiVersion +".gen.DbEdgeRules"); - } catch (ClassNotFoundException ex) { - result = Class.forName("org.openecomp.aai.dbmodel.DbEdgeRules"); - } - return result; - } - /** * Guaranteed to at least return non null but empty collection of edge descriptions * @param nodeName name of the vertex whose edge relationships to return @@ -891,44 +850,7 @@ public class GenerateXsd { return edges; } - /** - * Finds the default delete scope from DBEdgeRules - * @param nodeName name of vertex whose delete scope to return - * @return default delete scope of the input nodeName, null if none. - */ - private static String getDeleteRules( String nodeName ) - { - String result = null; - Iterator delRulesIterator; - - try { - - Field mapfield = versionedClass.getField("DefaultDeleteScope"); - Object map = mapfield.get(null); - if (map instanceof Multimap) { - delRulesIterator = ((Multimap) map).keySet().iterator(); - } else { - throw new NoSuchFieldException ("Didn't get back the multimap field expected"); - } - - while( delRulesIterator.hasNext() ){ - String ruleKey = delRulesIterator.next(); - if ( ruleKey.equals(nodeName)) { - Collection deRuleColl = DbEdgeRules.DefaultDeleteScope.get(ruleKey); - Iterator ruleItr = deRuleColl.iterator(); - if( ruleItr.hasNext() ){ - result = ruleItr.next(); - } - } - } - - } catch (Exception ex) { - ex.printStackTrace(); - } - return result; - } - - public static String processJavaTypeElementSwagger( String javaTypeName, Element javaTypeElement, + public static String processJavaTypeElementSwagger( String javaTypeName, Element javaTypeElement, StringBuffer pathSb, StringBuffer definitionsSb, String path, String tag, String opId, String getItemName, StringBuffer pathParams, String queryParams, String validEdges) { @@ -1626,17 +1548,14 @@ public class GenerateXsd { validEdges = sbEdge.toString(); } - String deleteRule = getDeleteRules(xmlRootElementName); // Handle description property. Might have a description OR valid edges OR both OR neither. // Only put a description: tag if there is at least one. - if (pathDescriptionProperty != null || deleteRule != null || validEdges != null) { + if (pathDescriptionProperty != null || validEdges != null) { definitionsSb.append(" description: |\n"); if ( pathDescriptionProperty != null ) definitionsSb.append(" " + pathDescriptionProperty + "\n" ); - if (deleteRule != null) - definitionsSb.append(" ###### Default Delete Scope\n ").append(deleteRule).append("\n"); - if (validEdges != null) + if (validEdges != null) definitionsSb.append(validEdges); } @@ -1670,7 +1589,6 @@ public class GenerateXsd { sb.append(" description: bad request\n"); */ try { - versionedClass = getEdgeRulesClass(); File initialFile = new File("src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json"); InputStream is = new FileInputStream(initialFile); diff --git a/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java b/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java deleted file mode 100644 index 7cf5ac71..00000000 --- a/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.aai.dbmodel; - -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; -import org.apache.commons.io.FileUtils; -import org.junit.Test; - -import java.io.*; -import java.util.Map.Entry; - -import static org.junit.Assert.*; - -public class DbEdgeRulesConverterTest { - - @Test - public void testExtractData() { - Multimap EdgeRules = new ImmutableSetMultimap.Builder() - .putAll("availability-zone|complex", - "groupsResourcesIn,OUT,Many2Many,false,true,false,true").build(); - - DbEdgeRulesConverter dberConverter = new DbEdgeRulesConverter(); - - for (Entry r : EdgeRules.entries()) { - EdgeRuleBean bean = dberConverter.extractData(r); - assertEquals("from availability-zone", "availability-zone", bean.getFrom()); - assertEquals("to complex", "complex", bean.getTo()); - assertEquals("label", "groupsResourcesIn", bean.getLabel()); - assertEquals("direction", "OUT", bean.getDirection()); - assertEquals("multiplicity", "Many2Many", bean.getMultiplicity()); - assertEquals("isParent", "false", bean.getIsParent()); - assertEquals("usesResource", "true", bean.getUsesResource()); - assertEquals("hasDelTarget", "false", bean.getHasDelTarget()); - assertEquals("SVC-INFRA", "true", bean.getSvcInfra()); - } - } - - @Test - public void testConvert(){ - DbEdgeRulesConverter dberCon = new DbEdgeRulesConverter(); - String dest = "src/test/resources/dbEdgeRulesConversion"; - String outFile = dest + "/testOutput.json"; - - Multimap EdgeRules = new ImmutableSetMultimap.Builder() - .putAll("foo|bar", - "has,OUT,Many2Many,false,false,false,false") - .putAll("baz|quux", - "treatsVeryKindly,IN,One2One,true,true,true,true") - .build(); - - try { - dberCon.setup(dest); - File result = new File(outFile); - //Add delete hook to delete the temporary result file on exit/ - result.deleteOnExit(); - FileOutputStream writeStream = new FileOutputStream(result); - Writer writer = new OutputStreamWriter(writeStream); - dberCon.convert(EdgeRules, writer); - File compare = new File("src/test/resources/dbEdgeRulesConversion/conversionTestCompare.json"); - assertTrue(FileUtils.contentEquals(result, compare)); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - fail("IOException on setup"); - } - } -} diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java new file mode 100644 index 00000000..8752e6f1 --- /dev/null +++ b/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.logging; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; +import ch.qos.logback.classic.spi.ILoggingEvent; +import org.junit.*; + +public class EelfClassOfCallerTest { + + EelfClassOfCaller _eelfClassOfCaller; + ILoggingEvent mockEvent; + StackTraceElement[] cdafive = new StackTraceElement[5]; + StackTraceElement[] cdaone = new StackTraceElement[1]; + StackTraceElement[] cdazero = new StackTraceElement[0]; + + + @Before + public void setUp() throws Exception { + + mockEvent = mock(ILoggingEvent.class); + _eelfClassOfCaller= spy(EelfClassOfCaller.class); + + } + + + @Test + public void getFullyQualifiedNameCDALENFiveTest(){ + StackTraceElement temp = new StackTraceElement("classname_five","methodname","filename", 4); + cdafive[2]=temp; + when(mockEvent.getCallerData()).thenReturn(cdafive); + assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"classname_five"); + + } + @Test + public void getFullyQualifiedNameCDALenOneTest(){ + StackTraceElement temp = new StackTraceElement("classname_one","methodname","filename", 4); + cdaone[0]=temp; + when(mockEvent.getCallerData()).thenReturn(cdaone); + assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"classname_one"); + + } + + @Test + public void getFullyQualifiedNameCDALenZeroTest(){ + when(mockEvent.getCallerData()).thenReturn(cdazero); + assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"?"); + + } + +} diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java index 5c68fc67..baaad6c9 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java @@ -92,7 +92,6 @@ public class LegacyQueryTest extends AAISetup { * @throws UnsupportedEncodingException the unsupported encoding exception * @throws AAIException the AAI exception */ - @Ignore @Test public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers/pserver/key1/lag-interfaces/lag-interface/key2").build(); @@ -125,7 +124,6 @@ public class LegacyQueryTest extends AAISetup { * @throws UnsupportedEncodingException the unsupported encoding exception * @throws AAIException the AAI exception */ - @Ignore @Test public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build(); diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java index bc20af11..092d5c66 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java @@ -84,8 +84,6 @@ public class RelationshipToURITest extends AAISetup { thrown.expect(AAIIdentityMapParseException.class); thrown.expect(hasProperty("code", is("AAI_3000"))); RelationshipToURI parse = new RelationshipToURI(loader, obj); - - URI uri = parse.getUri(); } @@ -97,8 +95,6 @@ public class RelationshipToURITest extends AAISetup { URI expected = new URI("/network/test-objects/test-object/key2"); RelationshipToURI parse = new RelationshipToURI(loader, obj); - - URI uri = parse.getUri(); assertEquals("related-link is equal", expected, uri); @@ -121,6 +117,20 @@ public class RelationshipToURITest extends AAISetup { } + @Test + public void failNothingToParse() throws AAIException, URISyntaxException, IOException { + Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10); + Introspector obj = loader.unmarshal("relationship", this.getJsonString("nothing-to-parse.json")); + URI expected = new URI("/aai/v10/network/test-objects/test-object/key1"); + + thrown.expect(AAIIdentityMapParseException.class); + thrown.expect(hasProperty("code", is("AAI_3000"))); + RelationshipToURI parse = new RelationshipToURI(loader, obj); + + URI uri = parse.getUri(); + + } + @Test public void successV10() throws AAIException, URISyntaxException, IOException { Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10); diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java index 9aabdf1a..626e97ab 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java @@ -26,6 +26,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.openecomp.aai.AAISetup; import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.parsers.exceptions.DoesNotStartWithValidNamespaceException; +import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.introspection.*; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -39,11 +41,11 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; -@Ignore + @PrepareForTest(ModelInjestor.class) public class URIToDBKeyTest extends AAISetup { - private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8); + private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -58,11 +60,11 @@ public class URIToDBKeyTest extends AAISetup { */ @Test public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { - URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); + URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build(); URIToDBKey parse = new URIToDBKey(loader, uri); Object result = parse.getResult(); - String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3"; + String expected = "cloud-region/tenant/vserver/l-interface"; assertEquals("blah", expected, result); @@ -78,11 +80,11 @@ public class URIToDBKeyTest extends AAISetup { */ @Test public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { - URI uri = UriBuilder.fromPath("/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); + URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build(); URIToDBKey parse = new URIToDBKey(loader, uri); Object result = parse.getResult(); - String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3"; + String expected = "cloud-region/tenant/vserver/l-interface"; assertEquals("blah", expected, result); @@ -102,11 +104,27 @@ public class URIToDBKeyTest extends AAISetup { URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build(); thrown.expect(AAIException.class); - thrown.expect(hasProperty("code", is("AAI_3000"))); + thrown.expect(hasProperty("code", is("AAI_3001"))); new URIToDBKey(loader, uri); } + /** + * NotValid namespace. + * + * @throws JAXBException the JAXB exception + * @throws DoesNotStartWithValidNamespaceException the AAI exception + * @throws IllegalArgumentException the illegal argument exception + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + @Test + public void notValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { + URI uri = UriBuilder.fromPath("/cloud-region/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build(); + thrown.expect(DoesNotStartWithValidNamespaceException.class); + URIToDBKey parse = new URIToDBKey(loader, uri); + } + + /** * No valid tokens. * @@ -120,7 +138,7 @@ public class URIToDBKeyTest extends AAISetup { URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud/blah/blah").build(); thrown.expect(AAIException.class); - thrown.expect(hasProperty("code", is("AAI_3001"))); + thrown.expect(hasProperty("code", is("AAI_3000"))); new URIToDBKey(loader, uri); } @@ -135,12 +153,12 @@ public class URIToDBKeyTest extends AAISetup { */ @Test public void startsWithValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { - URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); + URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build(); URIToDBKey parse = new URIToDBKey(loader, uri); Object result = parse.getResult(); - String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3"; + String expected = "cloud-region/tenant/vserver/l-interface"; assertEquals("blah", expected, result); } @@ -158,7 +176,7 @@ public class URIToDBKeyTest extends AAISetup { URIToDBKey parse = new URIToDBKey(loader, uri); Object result = parse.getResult(); - String expected = "vce/key1/port-group/key2/cvlan-tag/655"; + String expected = "vce/port-group/cvlan-tag"; assertEquals("blah", expected, result); diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java index ee665d31..38377f73 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java @@ -37,10 +37,10 @@ import java.net.URI; import static org.junit.Assert.assertEquals; -@Ignore + public class URIToExtensionInformationTest extends AAISetup { - private Loader v8Loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8); + private Loader v8Loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10); /** * Vservers V 7. diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java index 7261a2dc..9eb013f6 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java @@ -41,10 +41,10 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; -@Ignore + public class URIToObjectTest extends AAISetup { - private Version version = Version.v8; + private Version version = Version.v10; private Version currentVersion = AAIProperties.LATEST; private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version); diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java index 42c602ba..ee7b8651 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java @@ -40,10 +40,10 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertTrue; -@Ignore + public class URIToRelationshipObjectTest extends AAISetup { - private Version latest = AAIProperties.LATEST; + private Version latest = Version.v10; private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, latest); @Rule @@ -61,10 +61,11 @@ public class URIToRelationshipObjectTest extends AAISetup { */ @Test public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, URISyntaxException { + URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri); Introspector result = parse.getResult(); - String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\".*?:8443/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}"; + String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}"; assertTrue("blah", result.marshal(false).matches(expected)); } @@ -84,7 +85,7 @@ public class URIToRelationshipObjectTest extends AAISetup { URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri); Introspector result = parse.getResult(); - String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\".*?:8443/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}"; + String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}"; assertTrue("blah", result.marshal(false).matches(expected)); @@ -105,7 +106,7 @@ public class URIToRelationshipObjectTest extends AAISetup { URI uri = UriBuilder.fromPath("/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3/").build(); URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri); Introspector result = parse.getResult(); - String expected = "\\{\"related-to\":\"ctag-pool\",\"related-link\":\".*?:8443/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"ctag-pool.target-pe\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"ctag-pool.availability-zone-name\",\"relationship-value\":\"key3\"\\}\\]\\}"; + String expected = "\\{\"related-to\":\"ctag-pool\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"ctag-pool.target-pe\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"ctag-pool.availability-zone-name\",\"relationship-value\":\"key3\"\\}\\]\\}"; assertTrue("blah", result.marshal(false).matches(expected)); } @@ -125,7 +126,7 @@ public class URIToRelationshipObjectTest extends AAISetup { URI uri = UriBuilder.fromPath("/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144").build(); URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri); Introspector result = parse.getResult(); - String expected = "\\{\"related-to\":\"cvlan-tag\",\"related-link\":\".*?:8443/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144\",\"relationship-data\":\\[\\{\"relationship-key\":\"vce.vnf-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"port-group.interface-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"cvlan-tag.cvlan-tag\",\"relationship-value\":\"144\"\\}\\]\\}"; + String expected = "\\{\"related-to\":\"cvlan-tag\",\"related-link\":\"/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144\",\"relationship-data\":\\[\\{\"relationship-key\":\"vce.vnf-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"port-group.interface-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"cvlan-tag.cvlan-tag\",\"relationship-value\":\"144\"\\}\\]\\}"; assertTrue("blah", result.marshal(false).matches(expected)); } /** diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java index 87bb6ca7..0257e6b1 100644 --- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java @@ -111,7 +111,7 @@ public class EdgeRulesTest extends AAISetup { Vertex v2 = graph.addVertex("aai-node-type", "tenant"); assertEquals(true, EdgeRules.getInstance().hasEdgeRule(v1, v2)); } - + @Test public void getEdgeRuleByTypeAndVertices() throws AAIException { Graph graph = TinkerGraph.open(); @@ -125,7 +125,7 @@ public class EdgeRulesTest extends AAISetup { assertEquals(true, "IN".equalsIgnoreCase(rule.getServiceInfrastructure())); assertEquals(true, "OUT".equalsIgnoreCase(rule.getPreventDelete())); } - + @Test public void addTreeEdgeTest() throws AAIException { Graph graph = TinkerGraph.open(); @@ -135,11 +135,11 @@ public class EdgeRulesTest extends AAISetup { GraphTraversalSource g = graph.traversal(); rules.addTreeEdge(g, v1, v2); assertEquals(true, g.V(v1).out("has").has("aai-node-type", "tenant").hasNext()); - + Vertex v3 = graph.addVertex(T.id, "2", "aai-node-type", "cloud-region"); assertEquals(null, rules.addTreeEdgeIfPossible(g, v3, v2)); } - + @Test public void addCousinEdgeTest() throws AAIException { Graph graph = TinkerGraph.open(); @@ -149,27 +149,27 @@ public class EdgeRulesTest extends AAISetup { GraphTraversalSource g = graph.traversal(); rules.addEdge(g, v1, v2); assertEquals(true, g.V(v2).out("hasFlavor").has("aai-node-type", "flavor").hasNext()); - + Vertex v3 = graph.addVertex(T.id, "2", "aai-node-type", "flavor"); assertEquals(null, rules.addEdgeIfPossible(g, v3, v2)); } - + @Test public void multiplicityViolationTest() throws AAIException { thrown.expect(EdgeMultiplicityException.class); thrown.expectMessage("multiplicity rule violated: only one edge can exist with label: uses between vf-module and volume-group"); - + Graph graph = TinkerGraph.open(); Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "vf-module"); Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "volume-group"); EdgeRules rules = EdgeRules.getInstance(Version.getLatest()); GraphTraversalSource g = graph.traversal(); - + rules.addEdge(g, v2, v1); Vertex v3 = graph.addVertex(T.id, "3", "aai-node-type", "vf-module"); rules.addEdge(g, v2, v3); } - + @Test public void getChildrenTest() { EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json"); @@ -178,15 +178,15 @@ public class EdgeRulesTest extends AAISetup { boolean sawBazRule = false; boolean sawQuuxRule = false; for (EdgeRule r : children) { - if ("isVeryHappyAbout".equals(r.getLabel())) { - sawBazRule = true; + if ("isVeryHappyAbout".equals(r.getLabel())) { + sawBazRule = true; } else if ("dancesWith".equals(r.getLabel())) { sawQuuxRule = true; } } assertEquals(true, sawBazRule && sawQuuxRule); } - + @Test public void getAllRulesTest() { EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json"); @@ -196,34 +196,34 @@ public class EdgeRulesTest extends AAISetup { assertEquals(true, allRules.containsKey("foo|bar")); assertEquals(true, allRules.containsKey("quux|foo")); } - + @Test public void getAllRulesMissingPropertyTest() { EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json"); - + thrown.expect(RuntimeException.class); thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between foo and bar is missing property delete-other-v."); rules.getAllRules(); } - + @Test public void getChildrenMissingPropertyTest() { EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json"); - + thrown.expect(RuntimeException.class); thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between quux and foo is missing property SVC-INFRA."); rules.getChildren("foo"); } - + @Test public void getEdgeRuleMissingPropertyTest() throws AAIException { EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json"); - + thrown.expect(RuntimeException.class); thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between quux and foo is missing property SVC-INFRA."); rules.getEdgeRules("foo", "quux"); } - + @Test public void verifyAllRules() { // This will cause every rule in the real json files to be verified diff --git a/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java b/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java new file mode 100644 index 00000000..c990e309 --- /dev/null +++ b/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.util; + +import org.junit.Test; +import org.openecomp.aai.introspection.Version; + +public class GenerateXsdTest { + + @Test + public void testGenerationOfXsdAndYaml() throws Exception { + + GenerateXsd generateXsd = new GenerateXsd(); + System.setProperty("gen_version", Version.getLatest().toString()); + System.setProperty("gen_type", "XSD"); + System.setProperty("yamlresponses_url", ""); + System.setProperty("yamlresponses_label", ""); + + generateXsd.main(new String[]{}); + + System.setProperty("gen_version", Version.getLatest().toString()); + System.setProperty("gen_type", "YAML"); + + String wikiLink = System.getProperty("aai.wiki.link"); + + if(wikiLink == null){ + wikiLink = "https://wiki.onap.org/"; + } + + System.setProperty("yamlresponses_url", wikiLink); + System.setProperty("yamlresponses_label", "Response codes found in [response codes]"); + + generateXsd.main(new String[]{}); + } + +} diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/relationship/nothing-to-parse.json b/aai-core/src/test/resources/bundleconfig-local/etc/relationship/nothing-to-parse.json new file mode 100644 index 00000000..ea5ff2fe --- /dev/null +++ b/aai-core/src/test/resources/bundleconfig-local/etc/relationship/nothing-to-parse.json @@ -0,0 +1,4 @@ +{ + "related-to": "test-object", + "relationship-data" : [] +} \ No newline at end of file diff --git a/aai-schema/src/main/resources/oxm/aai_oxm_v11.xml b/aai-schema/src/main/resources/oxm/aai_oxm_v11.xml index d86d8c6d..5479cfa7 100644 --- a/aai-schema/src/main/resources/oxm/aai_oxm_v11.xml +++ b/aai-schema/src/main/resources/oxm/aai_oxm_v11.xml @@ -234,10 +234,10 @@ - + - + @@ -247,7 +247,7 @@ - + @@ -272,7 +272,7 @@ - + @@ -282,7 +282,7 @@ - + @@ -306,7 +306,7 @@ - + @@ -317,7 +317,7 @@ - + @@ -327,7 +327,7 @@ - + @@ -362,7 +362,7 @@ - + @@ -489,7 +489,7 @@ - + @@ -1042,7 +1042,7 @@ - + @@ -3832,7 +3832,7 @@ - + @@ -3842,9 +3842,9 @@ - + - + @@ -4606,7 +4606,7 @@ - + @@ -5921,7 +5921,7 @@ - + @@ -6014,7 +6014,7 @@ - +