aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-ingest/src/main/java/org/onap
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2018-08-10 12:42:00 -0400
committerKajur, Harish (vk250x) <vk250x@att.com>2018-08-12 16:48:34 -0400
commita86d6a6644d6de3f3f814cd6e25cfe2213d5dd05 (patch)
tree9935a64d7f830ebedf2742e0febef40e898cea91 /aai-schema-ingest/src/main/java/org/onap
parenta395fa69a28a04d0a667fe458b4f10497a1d6794 (diff)
Integrate aai-schema-ingest library into aai-core
Integrate the aai-core into using the aai-schema-ingest library to be agnostic to the schema changes Remove any references to aai-schema dependency in aai-core Reorder the components so the aai-schema-ingest is first installed Moved the edge rules to the aai-schema as they are linked to schema Rework the generation of the aai-schema to using aai-schema-ingest library Also remove the yaml and html folders as they get generated on the fly So when maven pushes the aai-schema jar, the jar contains the generated yaml, html and xsd files at runtime due to the gerrit limit of filesize Issue-ID: AAI-1455 Change-Id: I87ecd9eb2fc96a09d3a6399955637674f6e7fb21 Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-schema-ingest/src/main/java/org/onap')
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java119
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java42
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java140
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java23
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java5
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java145
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java112
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java18
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java61
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java85
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java159
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java41
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java12
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java15
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java12
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java10
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java8
37 files changed, 818 insertions, 279 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
index c39a1c2e..dfcd0db3 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges;
@@ -34,7 +32,8 @@ import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -46,27 +45,29 @@ import com.jayway.jsonpath.Filter;
import static com.jayway.jsonpath.Filter.filter;
import static com.jayway.jsonpath.Criteria.where;
-@Component
/**
* EdgeIngestor - ingests A&AI edge rule schema files per given config, serves that edge rule
* information, including allowing various filters to extract particular rules.
*/
+@Component
public class EdgeIngestor {
- private Map<Version, List<DocumentContext>> versionJsonFilesMap;
+ private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
private static final String READ_START = "$.rules.[?]";
private static final String READ_ALL_START = "$.rules.*";
-
+
+ private SchemaVersions schemaVersions;
//-----ingest-----//
- @Autowired
/**
* Instantiates the EdgeIngestor bean.
*
* @param translator - ConfigTranslator autowired in by Spring framework which
* contains the configuration information needed to ingest the desired files.
*/
- public EdgeIngestor(ConfigTranslator translator) {
- Map<Version, List<String>> filesToIngest = translator.getEdgeFiles();
+ @Autowired
+ public EdgeIngestor(ConfigTranslator translator, SchemaVersions schemaVersions) {
+ Map<SchemaVersion, List<String>> filesToIngest = translator.getEdgeFiles();
JsonIngestor ji = new JsonIngestor();
+ this.schemaVersions = schemaVersions;
versionJsonFilesMap = ji.ingest(filesToIngest);
}
@@ -87,7 +88,7 @@ public class EdgeIngestor {
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getAllCurrentRules() throws EdgeRuleNotFoundException {
- return getAllRules(Version.getLatest());
+ return getAllRules(schemaVersions.getDefaultVersion());
}
/**
@@ -104,7 +105,7 @@ public class EdgeIngestor {
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
* @throws EdgeRuleNotFoundException if none found
*/
- public Multimap<String, EdgeRule> getAllRules(Version v) throws EdgeRuleNotFoundException {
+ public Multimap<String, EdgeRule> getAllRules(SchemaVersion v) throws EdgeRuleNotFoundException {
Multimap<String, EdgeRule> found = extractRules(null, v);
if (found.isEmpty()) {
throw new EdgeRuleNotFoundException("No rules found for version " + v.toString() + ".");
@@ -130,10 +131,28 @@ public class EdgeIngestor {
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getRules(EdgeRuleQuery q) throws EdgeRuleNotFoundException {
- Multimap<String, EdgeRule> found = extractRules(q.getFilter(), q.getVersion());
+ Multimap<String, EdgeRule> found = null;
+ if(q.getVersion().isPresent()){
+ found = extractRules(q.getFilter(), q.getVersion().get());
+ } else {
+ found = extractRules(q.getFilter(), schemaVersions.getDefaultVersion());
+ }
if (found.isEmpty()) {
throw new EdgeRuleNotFoundException("No rules found for " + q.toString());
} else {
+ for (EdgeRule rule : found.values()) {
+ if (!q.getFromType().equals(rule.getFrom())) {
+ /* To maintain backwards compatibility with old EdgeRules API,
+ * where the direction of the returned EdgeRule would be
+ * flipped (if necessary) to match the directionality of
+ * the input params.
+ * ie, If the rule is from=A,to=B,direction=OUT,
+ * if the user asked (A,B) the direction would be OUT,
+ * if they asked (B,A), it would be IN to match.
+ */
+ rule.flipDirection();
+ }
+ }
return found;
}
}
@@ -155,8 +174,13 @@ public class EdgeIngestor {
* ex: which l-interface|logical-link rule to default to.
*/
public EdgeRule getRule(EdgeRuleQuery q) throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- Multimap<String, EdgeRule> found = extractRules(q.getFilter(), q.getVersion());
-
+ Multimap<String, EdgeRule> found = null;
+ if(q.getVersion().isPresent()){
+ found = extractRules(q.getFilter(), q.getVersion().get());
+ } else {
+ found = extractRules(q.getFilter(), schemaVersions.getDefaultVersion());
+ }
+
if (found.isEmpty()) {
throw new EdgeRuleNotFoundException("No rule found for " + q.toString() + ".");
}
@@ -173,6 +197,17 @@ public class EdgeIngestor {
if (rule == null) { //should never get here though
throw new EdgeRuleNotFoundException("No rule found for " + q.toString() + ".");
} else {
+ if (!q.getFromType().equals(rule.getFrom())) {
+ /* To maintain backwards compatibility with old EdgeRules API,
+ * where the direction of the returned EdgeRule would be
+ * flipped (if necessary) to match the directionality of
+ * the input params.
+ * ie, If the rule is from=A,to=B,direction=OUT,
+ * if the user asked (A,B) the direction would be OUT,
+ * if they asked (B,A), it would be IN to match.
+ */
+ rule.flipDirection();
+ }
return rule;
}
}
@@ -211,7 +246,11 @@ public class EdgeIngestor {
* @return boolean
*/
public boolean hasRule(EdgeRuleQuery q) {
- return !extractRules(q.getFilter(), q.getVersion()).isEmpty();
+ if(q.getVersion().isPresent()){
+ return !extractRules(q.getFilter(), q.getVersion().get()).isEmpty();
+ } else {
+ return !extractRules(q.getFilter(), schemaVersions.getDefaultVersion()).isEmpty();
+ }
}
/**
@@ -228,7 +267,7 @@ public class EdgeIngestor {
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getCousinRules(String nodeType) {
- return getCousinRules(nodeType, Version.getLatest()); //default to latest
+ return getCousinRules(nodeType, schemaVersions.getDefaultVersion()); //default to latest
}
/**
@@ -245,7 +284,7 @@ public class EdgeIngestor {
* This is alphabetical order to normalize the keys, as sometimes there will be multiple
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
- public Multimap<String, EdgeRule> getCousinRules(String nodeType, Version v) {
+ public Multimap<String, EdgeRule> getCousinRules(String nodeType, SchemaVersion v) {
return extractRules(new EdgeRuleQuery.Builder(nodeType).edgeType(EdgeType.COUSIN).build().getFilter(), v);
}
@@ -255,7 +294,7 @@ public class EdgeIngestor {
* @return boolean
*/
public boolean hasCousinRule(String nodeType) {
- return hasCousinRule(nodeType, Version.getLatest());
+ return hasCousinRule(nodeType, schemaVersions.getDefaultVersion());
}
/**
@@ -263,7 +302,7 @@ public class EdgeIngestor {
* @param nodeType
* @return boolean
*/
- public boolean hasCousinRule(String nodeType, Version v) {
+ public boolean hasCousinRule(String nodeType, SchemaVersion v) {
return !getCousinRules(nodeType, v).isEmpty();
}
@@ -281,7 +320,7 @@ public class EdgeIngestor {
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getChildRules(String nodeType) {
- return getChildRules(nodeType, Version.getLatest());
+ return getChildRules(nodeType, schemaVersions.getDefaultVersion());
}
/**
@@ -297,7 +336,7 @@ public class EdgeIngestor {
* This is alphabetical order to normalize the keys, as sometimes there will be multiple
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
- public Multimap<String, EdgeRule> getChildRules(String nodeType, Version v) {
+ public Multimap<String, EdgeRule> getChildRules(String nodeType, SchemaVersion v) {
Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getSameDirectionContainmentCriteria());
Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
Filter total = from.or(to);
@@ -311,7 +350,7 @@ public class EdgeIngestor {
* @return boolean
*/
public boolean hasChildRule(String nodeType) {
- return hasChildRule(nodeType, Version.getLatest());
+ return hasChildRule(nodeType, schemaVersions.getDefaultVersion());
}
/**
@@ -319,7 +358,7 @@ public class EdgeIngestor {
* @param nodeType
* @return boolean
*/
- public boolean hasChildRule(String nodeType, Version v) {
+ public boolean hasChildRule(String nodeType, SchemaVersion v) {
return !getChildRules(nodeType, v).isEmpty();
}
@@ -337,7 +376,7 @@ public class EdgeIngestor {
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getParentRules(String nodeType) {
- return getParentRules(nodeType, Version.getLatest());
+ return getParentRules(nodeType, schemaVersions.getDefaultVersion());
}
/**
@@ -353,7 +392,7 @@ public class EdgeIngestor {
* This is alphabetical order to normalize the keys, as sometimes there will be multiple
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
- public Multimap<String, EdgeRule> getParentRules(String nodeType, Version v) {
+ public Multimap<String, EdgeRule> getParentRules(String nodeType, SchemaVersion v) {
Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getSameDirectionContainmentCriteria());
Filter total = from.or(to);
@@ -367,7 +406,7 @@ public class EdgeIngestor {
* @return boolean
*/
public boolean hasParentRule(String nodeType) {
- return hasParentRule(nodeType, Version.getLatest());
+ return hasParentRule(nodeType, schemaVersions.getDefaultVersion());
}
/**
@@ -375,7 +414,7 @@ public class EdgeIngestor {
* @param nodeType
* @return boolean
*/
- public boolean hasParentRule(String nodeType, Version v) {
+ public boolean hasParentRule(String nodeType, SchemaVersion v) {
return !getParentRules(nodeType, v).isEmpty();
}
@@ -395,7 +434,7 @@ public class EdgeIngestor {
* This is alphabetical order to normalize the keys, as sometimes there will be multiple
* rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
- private Multimap<String, EdgeRule> extractRules(Filter filter, Version v) {
+ private Multimap<String, EdgeRule> extractRules(Filter filter, SchemaVersion v) {
List<Map<String, String>> foundRules = new ArrayList<>();
List<DocumentContext> docs = versionJsonFilesMap.get(v);
if (docs != null) {
@@ -486,7 +525,7 @@ public class EdgeIngestor {
/**
* Converts the raw output from reading the json file to the Multimap<String key, EdgeRule> format
*
- * @param List<Map<String, String>> allFound - raw edge rule output read from json file(s)
+ * @param allFound - raw edge rule output read from json file(s)
* (could be empty if none found)
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
* {alphabetically first nodetype}|{alphabetically second nodetype}. Will be empty if input
@@ -502,14 +541,24 @@ public class EdgeIngestor {
TypeAlphabetizer alpher = new TypeAlphabetizer();
- if (!allFound.isEmpty()) {
- for (Map<String, String> raw : allFound) {
- EdgeRule converted = new EdgeRule(raw);
- String alphabetizedKey = alpher.buildAlphabetizedKey(raw.get(EdgeField.FROM.toString()), raw.get(EdgeField.TO.toString()));
- rules.put(alphabetizedKey, converted);
+ for (Map<String, String> raw : allFound) {
+ EdgeRule converted = new EdgeRule(raw);
+ if (converted.getFrom().equals(converted.getTo())) {
+ /* the way the code worked in the past was with outs and
+ * when we switched it to in the same-node-type to
+ * same-node-type parent child edges were failing because all
+ * of the calling code would pass the parent as the left argument,
+ * so it was either in that method swap the parent/child,
+ * flip the edge rule or make all callers swap. the last seemed
+ * like a bad idea. and felt like the edge flip was the better
+ * of the remaining 2 */
+ converted.flipDirection();
}
+ String alphabetizedKey = alpher.buildAlphabetizedKey(raw.get(EdgeField.FROM.toString()), raw.get(EdgeField.TO.toString()));
+ rules.put(alphabetizedKey, converted);
}
return rules;
}
+
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
index f859aae6..e1cb240e 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges;
@@ -43,6 +41,7 @@ public class EdgeRule {
private Map<EdgeProperty, AAIDirection> edgeFields;
private boolean isDefaultEdge;
private String description;
+ private boolean isPrivateEdge = false;
/**
* Instantiates a new edge rule.
@@ -59,7 +58,7 @@ public class EdgeRule {
label = fieldVals.get(EdgeField.LABEL.toString());
direction = Direction.valueOf(fieldVals.get(EdgeField.DIRECTION.toString()));
multiplicityRule = MultiplicityRule.getValue(fieldVals.get(EdgeField.MULTIPLICITY.toString()));
-
+ isPrivateEdge = Boolean.valueOf(fieldVals.getOrDefault(EdgeField.PRIVATE.toString(), "false"));
for (EdgeProperty prop : EdgeProperty.values()) {
String rawVal = fieldVals.get(prop.toString());
edgeFields.put(prop, convertNotation(direction, rawVal));
@@ -84,13 +83,13 @@ public class EdgeRule {
* translates the direction notation into the correct IN/OUT
*/
private AAIDirection convertNotation(Direction dir, String rawVal) {
- if (AAIDirection.NONE.toString().equals(rawVal)) {
+ if (AAIDirection.NONE.toString().equalsIgnoreCase(rawVal)) {
return AAIDirection.NONE;
- } else if (AAIDirection.BOTH.toString().equals(rawVal)) {
+ } else if (AAIDirection.BOTH.toString().equalsIgnoreCase(rawVal)) {
return AAIDirection.BOTH;
- } else if (AAIDirection.OUT.toString().equals(rawVal)) {
+ } else if (AAIDirection.OUT.toString().equalsIgnoreCase(rawVal)) {
return AAIDirection.OUT;
- } else if (AAIDirection.IN.toString().equals(rawVal)) {
+ } else if (AAIDirection.IN.toString().equalsIgnoreCase(rawVal)) {
return AAIDirection.IN;
}
@@ -188,4 +187,31 @@ public class EdgeRule {
public String getDescription() {
return this.description;
}
+
+ /**
+ * Flips the direction value
+ * IN -> OUT
+ * OUT -> IN
+ * BOTH -> BOTH
+ */
+ public void flipDirection() {
+ if (Direction.OUT.equals(direction)) {
+ direction = Direction.IN;
+ } else if (Direction.IN.equals(direction)) {
+ direction = Direction.OUT;
+ }
+ //else BOTH just stays the same
+ }
+
+ public boolean isPrivateEdge() {
+ return isPrivateEdge;
+ }
+
+ public void setPrivateEdge(boolean privateEdge) {
+ isPrivateEdge = privateEdge;
+ }
+
+ public void setPrivateEdge(String isPrivateEdge){
+ this.isPrivateEdge = "true".equals(isPrivateEdge);
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
index 3029685f..828968a5 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,17 +16,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges;
+import org.apache.commons.lang.StringUtils;
+//import org.apache.tinkerpop.gremlin.structure.Direction;
import org.onap.aai.edges.enums.AAIDirection;
import org.onap.aai.edges.enums.EdgeField;
import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.edges.enums.EdgeType;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import com.jayway.jsonpath.Filter;
import com.jayway.jsonpath.Predicate;
@@ -35,6 +35,7 @@ import static com.jayway.jsonpath.Filter.filter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import static com.jayway.jsonpath.Criteria.where;
@@ -44,11 +45,13 @@ import static com.jayway.jsonpath.Criteria.where;
*/
public class EdgeRuleQuery {
private Filter filter;
- private Version v;
+ private Optional<SchemaVersion> v;
private String nodeA;
private String nodeB;
private String label;
+ private AAIDirection direction;
private EdgeType type;
+ private boolean isPrivate;
public static class Builder {
//required
@@ -58,7 +61,9 @@ public class EdgeRuleQuery {
private String nodeB = null;
private String label = null;
private EdgeType type = null;
- private Version version = Version.getLatest(); //default
+ private AAIDirection direction = null;
+ private boolean isPrivate = false;
+ private SchemaVersion version = null;
public Builder(String nodeA) {
this.nodeA = nodeA;
@@ -72,10 +77,22 @@ public class EdgeRuleQuery {
private String getFirstNodeType() {
return nodeA;
}
+ public Builder fromOnly() {
+ this.nodeB = "FromOnly";
+ return this;
+ }
private String getSecondNodeType() {
return nodeB;
}
+ public Builder toOnly() {
+ //Allows this to be used with single parameter constructor Builder(String nodeA)
+ if(StringUtils.isEmpty(this.nodeB) && StringUtils.isNotEmpty(this.nodeA) ) {
+ this.nodeB=this.nodeA;
+ }
+ this.nodeA = "ToOnly";
+ return this;
+ }
public Builder label(String label) {
this.label = label;
@@ -95,12 +112,32 @@ public class EdgeRuleQuery {
return type;
}
- public Builder version(Version version) {
+
+ public Builder direction(AAIDirection direction) {
+ this.direction = direction;
+ return this;
+ }
+
+ private AAIDirection getDirection() {
+ return direction;
+ }
+
+ public Builder version(SchemaVersion version) {
this.version = version;
return this;
}
- private Version getVersion() {
- return version;
+
+ public Builder setPrivate(boolean isPrivate){
+ this.isPrivate = isPrivate;
+ return this;
+ }
+
+ public boolean isPrivate(){
+ return isPrivate;
+ }
+
+ private Optional<SchemaVersion> getSchemaVersion() {
+ return Optional.ofNullable(version);
}
public EdgeRuleQuery build() {
@@ -109,21 +146,30 @@ public class EdgeRuleQuery {
}
private EdgeRuleQuery(Builder builder) {
- this.v = builder.getVersion();
+ this.v = builder.getSchemaVersion();
this.nodeA = builder.getFirstNodeType();
this.nodeB = builder.getSecondNodeType();
this.label = builder.getLabel();
this.type = builder.getEdgeType();
+ this.direction = builder.getDirection();
+ this.isPrivate = builder.isPrivate();
//will cover from A to B case
List<Predicate> criteriaFromTo = new ArrayList<>();
- criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), builder.getSecondNodeType()));
+ //Special logic to allow for A to B case only
+ if(("FromOnly").equals(builder.getSecondNodeType())) {
+ criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), null));
+ } else {
+ criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), builder.getSecondNodeType()));
+ }
//will cover from B to A case - must be separate bc jsonpath won't let me OR predicates >:C
List<Predicate> criteriaToFrom = new ArrayList<>();
- criteriaToFrom.add(buildToFromPart(builder.getSecondNodeType(), builder.getFirstNodeType()));
-
-
-
+ //Special logic to allow for B to A case only
+ if(("ToOnly").equals(builder.getFirstNodeType())) {
+ criteriaToFrom.add(buildToFromPart(null, builder.getSecondNodeType()));
+ } else {
+ criteriaToFrom.add(buildToFromPart(builder.getSecondNodeType(), builder.getFirstNodeType()));
+ }
if (builder.getLabel() != null) {
Predicate labelPred = addLabel(builder.getLabel());
criteriaFromTo.add(labelPred);
@@ -135,10 +181,25 @@ public class EdgeRuleQuery {
criteriaFromTo.add(typePred);
criteriaToFrom.add(typePred);
}
-
+ Predicate privatePredicate = where("private").is(String.valueOf(isPrivate));
+ if(isPrivate){
+ criteriaFromTo.add(privatePredicate);
+ criteriaToFrom.add(privatePredicate);
+ }
- this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
+ if (builder.getDirection() != null) {
+ Predicate directionPred = addDirection(builder.getDirection());
+ criteriaFromTo.add(directionPred);
+ criteriaToFrom.add(directionPred);
+ }
+ if(("ToOnly").equals(builder.getFirstNodeType())) {
+ this.filter = filter(criteriaToFrom);
+ } else if(("FromOnly").equals(builder.getSecondNodeType())) {
+ this.filter = filter(criteriaFromTo);
+ } else {
+ this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
+ }
}
private Predicate buildToFromPart(String from, String to) {
@@ -170,6 +231,19 @@ public class EdgeRuleQuery {
return where(EdgeProperty.CONTAINS.toString()).ne(AAIDirection.NONE.toString());
}
}
+
+ private Predicate addDirection(AAIDirection direction) {
+ if (direction == AAIDirection.OUT) {
+ return where(EdgeField.DIRECTION.toString()).in(AAIDirection.OUT.toString(), AAIDirection.BOTH.toString());
+ } else if (direction == AAIDirection.IN) {
+ return where(EdgeField.DIRECTION.toString()).in(AAIDirection.IN.toString(), AAIDirection.BOTH.toString());
+ } else if (direction == AAIDirection.BOTH) {
+ return where(EdgeField.DIRECTION.toString()).is(AAIDirection.BOTH.toString());
+ } else if (direction == AAIDirection.NONE) {
+ return where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
+ }
+ return where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
+ }
/**
* Provides the JsonPath filter for actually querying the edge rule schema files
@@ -180,10 +254,27 @@ public class EdgeRuleQuery {
}
/**
+ * Gets the first node type given for the query.
+ *
+ * ie, If you called Builder(A,B) this would return A,
+ * if you called Builder(B,A), it would return B,
+ * if you called Builder(A), it would return A.
+ *
+ * This is to maintain backwards compatibility with the
+ * EdgeRules API which flipped the direction of
+ * the result EdgeRule to match the input directionality.
+ *
+ * @return String first node type of the query
+ */
+ public String getFromType() {
+ return this.nodeA;
+ }
+
+ /**
* So the Ingestor knows which version of the rules to search
* @return the Version
*/
- public Version getVersion() {
+ public Optional<SchemaVersion> getVersion() {
return this.v;
}
@@ -207,8 +298,15 @@ public class EdgeRuleQuery {
} else {
sb.append("any");
}
-
- sb.append(", for version: ").append(v.toString()).append(".");
- return sb.toString();
+
+ sb.append(", isPrivate: ");
+ sb.append(isPrivate);
+
+ if(v.isPresent()){
+ sb.append(", for version: ").append(v.get().toString()).append(".");
+ }
+ return sb.toString();
}
}
+
+
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
index 29a2e3b9..16562756 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges;
@@ -25,13 +23,10 @@ package org.onap.aai.edges;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
@@ -44,15 +39,15 @@ public class JsonIngestor {
/**
* Reads in given json files to queryable DocumentContexts.
*
- * @param Map<Version, List<String>> filesToIngest - map of filenames to ingest
+ * @param filesToIngest - map of filenames to ingest
* per Version
- * @return Map<Version, List<DocumentContext>> - map of DocumentContexts per Version
+ * @return Map<SchemaVersion, List<DocumentContext>> - map of DocumentContexts per Version
*/
- public Map<Version, List<DocumentContext>> ingest(Map<Version, List<String>> filesToIngest) {
- Map<Version, List<DocumentContext>> result = new EnumMap<>(Version.class);
+ public Map<SchemaVersion, List<DocumentContext>> ingest(Map<SchemaVersion, List<String>> filesToIngest) {
+ Map<SchemaVersion, List<DocumentContext>> result = new HashMap<>();
- for (Entry<Version, List<String>> verFiles : filesToIngest.entrySet()) {
- Version v = verFiles.getKey();
+ for (Entry<SchemaVersion, List<String>> verFiles : filesToIngest.entrySet()) {
+ SchemaVersion v = verFiles.getKey();
List<String> files = verFiles.getValue();
List<DocumentContext> docs = new ArrayList<>();
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java
index 2106d3a5..fd1f5113 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
index 3f748a50..aeb5d77d 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.enums;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
index 203249a4..5a69603b 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.enums;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
index 3e896f61..ff6bc82d 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.enums;
@@ -36,6 +34,7 @@ public enum EdgeField {
DELETE_OTHER_V("delete-other-v"),
PREVENT_DELETE("prevent-delete"),
DEFAULT("default"),
+ PRIVATE("private"),
DESCRIPTION("description");
private final String name;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
index 2f6afa47..18e82f5e 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.enums;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
index 00dce0fd..3ae59ab7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.enums;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
index 4fc8938d..a29b4a61 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.enums;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
index ebb9739b..b218cecd 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.exceptions;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
index e1a8fe6b..4d339de2 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.edges.exceptions;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
index bafc6b32..95232386 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
@@ -1,8 +1,8 @@
-/**
+/**
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.nodes;
@@ -27,14 +25,17 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.util.*;
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBException;
@@ -45,11 +46,13 @@ import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
+
import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -60,87 +63,133 @@ import com.google.common.base.CaseFormat;
* NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version
*/
public class NodeIngestor {
-
- private Map<Version, DynamicJAXBContext> versionContextMap = new EnumMap<>(Version.class);
- private Map<Version, Set<String>> typesPerVersion = new EnumMap<>(Version.class);
-
+
+
+ private Map<SchemaVersion, DynamicJAXBContext> versionContextMap = new TreeMap<>();
+ private Map<SchemaVersion, Set<String>> typesPerVersion = new TreeMap<>();
+ private Map<SchemaVersion, Document> schemaPerVersion = new TreeMap<>();
+ private static final Pattern classNamePattern = Pattern.compile("\\.(v\\d+)\\.");
+
+ private ConfigTranslator translator;
+
+
@Autowired
/**
* Instantiates the NodeIngestor bean.
- *
+ *
* @param translator - ConfigTranslator autowired in by Spring framework which
* contains the configuration information needed to ingest the desired files.
*/
public NodeIngestor(ConfigTranslator translator) {
- Map<Version, List<String>> filesToIngest = translator.getNodeFiles();
-
+ this.translator = translator;
+ Map<SchemaVersion, List<String>> filesToIngest = translator.getNodeFiles();
+
try {
- for (Entry<Version, List<String>> verFiles : filesToIngest.entrySet()) {
- Version v = verFiles.getKey();
+ for (Entry<SchemaVersion, List<String>> verFiles : filesToIngest.entrySet()) {
+ SchemaVersion v = verFiles.getKey();
List<String> files = verFiles.getValue();
final DynamicJAXBContext ctx = ingest(files);
versionContextMap.put(v, ctx);
typesPerVersion.put(v, getAllNodeTypes(files));
+ schemaPerVersion.put(v, createCombinedSchema(files, v));
}
} catch (JAXBException | ParserConfigurationException | SAXException | IOException e) {
throw new ExceptionInInitializerError(e);
}
}
-
+
/**
* Ingests the given OXM files into DynamicJAXBContext
- *
+ *
* @param files - List<String> of full filenames (ie including the path) to be ingested
- *
+ *
* @return DynamicJAXBContext including schema information from all given files
- *
+ *
* @throws FileNotFoundException if an OXM file can't be found
* @throws JAXBException if there's an error creating the DynamicJAXBContext
*/
private DynamicJAXBContext ingest(List<String> files) throws FileNotFoundException, JAXBException {
List<InputStream> streams = new ArrayList<>();
-
+
for (String name : files) {
streams.add(new FileInputStream(new File(name)));
}
-
- Map<String, Object> properties = new HashMap<>();
+
+ Map<String, Object> properties = new HashMap<>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, streams);
return DynamicJAXBContextFactory.createContextFromOXM(this.getClass().getClassLoader(), properties);
}
-
+
+
+
private Set<String> getAllNodeTypes(List<String> files) throws ParserConfigurationException, SAXException, IOException {
Set<String> types = new HashSet<>();
-
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-
+
+ ArrayList<Node> javaTypes = new ArrayList<Node>();
for (String file : files) {
InputStream inputStream = new FileInputStream(file);
-
+
final Document doc = docBuilder.parse(inputStream);
final NodeList list = doc.getElementsByTagName("java-type");
-
+
for (int i = 0; i < list.getLength(); i++) {
String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
+ javaTypes.add(list.item(i));
types.add(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, type));
}
}
-
+
return types;
}
+
+ private Document createCombinedSchema(List<String> files,SchemaVersion v) throws ParserConfigurationException, SAXException, IOException {
+ final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ DocumentBuilder masterDocBuilder = docFactory.newDocumentBuilder();
+ Document combinedDoc = masterDocBuilder.parse(getShell(v));
+ NodeList masterList = combinedDoc.getElementsByTagName("java-types");
+ Node javaTypesContainer = masterList.getLength() == 0 ? combinedDoc.getDocumentElement() : masterList.item(0);
+ for (String file : files) {
+ InputStream inputStream = new FileInputStream(file);
+
+ final Document doc = docBuilder.parse(inputStream);
+ final NodeList list = doc.getElementsByTagName("java-type");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node copy = combinedDoc.importNode(list.item(i),true);
+ javaTypesContainer.appendChild(copy);
+ }
+ }
+ return combinedDoc;
+ }
/**
* Gets the DynamicJAXBContext for the given version
- *
- * @param Version v
+ *
+ * @param v
* @return DynamicJAXBContext
*/
- public DynamicJAXBContext getContextForVersion(Version v) {
+ public DynamicJAXBContext getContextForVersion(SchemaVersion v) {
return versionContextMap.get(v);
}
-
+
+ /**
+ * Determines if the given version contains the given node type
+ *
+ * @param nodeType - node type to check, must be in lower hyphen form (ie "type-name")
+ * @param v - schema version to check against
+ * @return
+ */
+ public boolean hasNodeType(String nodeType, SchemaVersion v) {
+ return typesPerVersion.get(v).contains(nodeType);
+ }
+
+ public Set<String> getObjectsInVersion(SchemaVersion v){
+ return typesPerVersion.get(v);
+ }
/**
* Determines if the given version contains the given node type
*
@@ -148,7 +197,33 @@ public class NodeIngestor {
* @param v
* @return
*/
- public boolean hasNodeType(String nodeType, Version v) {
- return typesPerVersion.get(v).contains(nodeType);
+ public Document getSchema(SchemaVersion v) {
+ return schemaPerVersion.get(v);
+ }
+
+ private InputStream getShell(SchemaVersion v) {
+ String source = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org."+v.toString().toLowerCase()+"\" xml-mapping-metadata-complete=\"true\">\n" +
+ " <xml-schema element-form-default=\"QUALIFIED\">\n" +
+ " <xml-ns namespace-uri=\"http://org.onap.aai.inventory/"+v.toString().toLowerCase()+"\" />\n" +
+ " </xml-schema>\n" +
+ " <java-types>\n" +
+ " </java-types>\\n" +
+ "</xml-bindings>";
+// source.rep.replace("v11", v.toString());
+ return new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8));
+ }
+
+
+ public SchemaVersion getVersionFromClassName (String classname) {
+ Matcher m = classNamePattern.matcher(classname);
+ String version = null;
+ if (m.find()) {
+ version = m.group(1);
+ return new SchemaVersion(version);
+ } else {
+ return translator.getSchemaVersions().getDefaultVersion();
+ }
}
}
+
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
new file mode 100644
index 00000000..2cb0c99b
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
@@ -0,0 +1,112 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.setup;
+
+import java.io.File;
+import java.util.*;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * <b>AAIConfigTranslator</b> is responsible for looking at the
+ * schema files and edge files based on the available versions
+ * Also has the ability to exclude them based on the node.exclusion.pattern
+ */
+public class AAIConfigTranslator extends ConfigTranslator {
+
+ private static final String FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+
+ public AAIConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
+ super(bean, schemaVersions);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
+
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ List<String> container = getVersionNodeFiles(v);
+ files.put(v, container);
+ }
+
+ return files;
+ }
+
+
+ private List<String> getVersionNodeFiles(SchemaVersion v) {
+
+ return getVersionFiles(
+ bean.getNodeDirectory(),
+ v,
+ () -> bean.getNodesInclusionPattern().stream(),
+ () -> bean.getNodesExclusionPattern().stream()
+ );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ List<String> container = getVersionEdgeFiles(v);
+ files.put(v, container);
+ }
+
+ return files;
+ }
+
+ private List<String> getVersionEdgeFiles(SchemaVersion v) {
+
+ return getVersionFiles(
+ bean.getEdgeDirectory(),
+ v,
+ () -> bean.getEdgesInclusionPattern().stream(),
+ () -> bean.getEdgesExclusionPattern().stream()
+ );
+ }
+
+ private List<String> getVersionFiles(
+ String startDirectory,
+ SchemaVersion schemaVersion,
+ Supplier<Stream<String>> inclusionPattern,
+ Supplier<Stream<String>> exclusionPattern
+ ){
+
+ List<String> container;
+ final String directoryName = startDirectory + FILESEP + schemaVersion.toString() + FILESEP;
+
+ container = Arrays.stream(new File(directoryName).listFiles())
+ .map(File::getName)
+ .filter(name -> inclusionPattern.get().anyMatch(name::matches))
+ .map(name -> directoryName + name)
+ .filter(name -> exclusionPattern.get().noneMatch(name::matches))
+ .collect(Collectors.toList());
+
+ return container;
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
index b34622de..ccbe7065 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.setup;
@@ -35,10 +33,12 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
public abstract class ConfigTranslator {
protected SchemaLocationsBean bean;
+ protected SchemaVersions schemaVersions;
@Autowired
- public ConfigTranslator(SchemaLocationsBean bean) {
- this.bean = bean;
+ public ConfigTranslator(SchemaLocationsBean schemaLocationbean, SchemaVersions schemaVersions) {
+ this.bean = schemaLocationbean;
+ this.schemaVersions = schemaVersions;
}
/**
@@ -48,7 +48,7 @@ public abstract class ConfigTranslator {
* @return Map of Version to the list of (string) filenames to be
* ingested for that version
*/
- public abstract Map<Version, List<String>> getNodeFiles();
+ public abstract Map<SchemaVersion, List<String>> getNodeFiles();
/**
* Translates the contents of the schema config file
@@ -57,5 +57,9 @@ public abstract class ConfigTranslator {
* @return Map of Version to the List of (String) filenames to be
* ingested for that version
*/
- public abstract Map<Version, List<String>> getEdgeFiles();
+ public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
+
+ public SchemaVersions getSchemaVersions(){
+ return schemaVersions;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
index b5b878af..e3cd7236 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.setup;
@@ -28,32 +26,47 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import java.util.Collections;
+import java.util.List;
+
@Configuration
-@PropertySource(value = "classpath:schemaIngest.properties", ignoreResourceNotFound=true)
-@PropertySource(value = "file:${schemaIngestPropLoc}", ignoreResourceNotFound=true)
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
public class SchemaLocationsBean {
/*
* Per Spring documentation, the last PropertySource that works will
- * be applied. Here, schemaIngestPropLoc will be an environment variable
+ * be applied. Here, schema.ingest.file will be an environment variable
* set on install that tells Spring where to look for the schema
* ingest properties file (and the actual filename), but the former
* PropertySource gives the default of looking on the classpath for
- * schemaIngest.properties in case that second one doesn't work.
+ * schema-ingest.properties in case that second one doesn't work.
*
- * The schemaIngest.properties file (or its equivalent if you choose
+ * The schema-ingest.properties file (or its equivalent if you choose
* to name it otherwise) must contain the entries the below @Value
* annotations are looking for.
*/
- @Value("${schemaConfig}")
+ @Value("${schema.configuration.location}")
private String schemaConfigLoc;
- @Value("${nodeDir}")
+ @Value("${schema.nodes.location}")
private String nodeDirectory;
- @Value("${edgeDir}")
+ @Value("${schema.edges.location}")
private String edgeDirectory;
-
+
+ @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
+ private List<String> nodesInclusionPattern;
+
+ @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
+ private List<String> nodesExclusionPattern;
+
+ @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
+ private List<String> edgesInclusionPattern;
+
+ @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
+ private List<String> edgesExclusionPattern;
+
/**
* @return the file name/location with the list of schema files to be ingested
*/
@@ -64,7 +77,7 @@ public class SchemaLocationsBean {
/**
* Sets the name/location of the file with the list of schema files to ingest
*
- * @param String schemaConfigLoc - the file name/location
+ * @param schemaConfigLoc - the file name/location
*/
public void setSchemaConfigLocation(String schemaConfigLoc) {
this.schemaConfigLoc = schemaConfigLoc;
@@ -80,7 +93,7 @@ public class SchemaLocationsBean {
/**
* Sets the location of the OXM files
*
- * @param String nodeDirectory - the location of the OXM files
+ * @param nodeDirectory - the location of the OXM files
*/
public void setNodeDirectory(String nodeDirectory) {
this.nodeDirectory = nodeDirectory;
@@ -96,12 +109,28 @@ public class SchemaLocationsBean {
/**
* Sets the location of the edge rule json files
*
- * @param String edgeDirectory - the location of the edge rule files
+ * @param edgeDirectory - the location of the edge rule files
*/
public void setEdgeDirectory(String edgeDirectory) {
this.edgeDirectory = edgeDirectory;
}
-
+
+ public List<String> getNodesExclusionPattern(){
+ return this.nodesExclusionPattern;
+ }
+
+ public List<String> getNodesInclusionPattern(){
+ return this.nodesInclusionPattern;
+ }
+
+ public List<String> getEdgesExclusionPattern(){
+ return this.edgesExclusionPattern;
+ }
+
+ public List<String> getEdgesInclusionPattern(){
+ return this.edgesInclusionPattern;
+ }
+
//this allows the code to actually read the value from the config file
//without this those strings get set to literally "${edgeDir}" etc
@Bean
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java
new file mode 100644
index 00000000..c744c5a3
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java
@@ -0,0 +1,85 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.setup;
+
+import org.onap.aai.validation.AAISchemaValidationException;
+
+import java.util.Comparator;
+import java.util.regex.Pattern;
+
+public class SchemaVersion implements Comparable<SchemaVersion> {
+
+ public static final Pattern VERSION_PATTERN = Pattern.compile("v[1-9][0-9]*");
+
+ private final String value;
+
+ public SchemaVersion(String value){
+
+ if(!VERSION_PATTERN.matcher(value).matches()){
+ throw new AAISchemaValidationException("Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
+ }
+
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode(){
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other){
+ if(this == other){
+ return true;
+ }
+
+ if(other == null){
+ return false;
+ }
+
+ if(!(other instanceof SchemaVersion)){
+ return false;
+ }
+
+ SchemaVersion obj = (SchemaVersion)other;
+ return this.value.equals(obj.value);
+ }
+
+ @Override
+ public String toString(){
+ return value;
+ }
+
+ @Override
+ public int compareTo(SchemaVersion o) {
+
+ if(o == null){
+ return -1;
+ }
+
+ // Requires to convert to integer to match the past behavior
+ // Otherwise the string comparison of versions aren't working as expected
+
+ Integer tVal = Integer.parseInt(this.value.replaceAll("v", ""));
+ Integer oVal = Integer.parseInt(o.value.replaceAll("v", ""));
+
+ return tVal.compareTo(oVal);
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
new file mode 100644
index 00000000..2205b14b
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
@@ -0,0 +1,159 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.setup;
+
+import org.onap.aai.validation.AAISchemaValidationException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.xml.validation.Schema;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
+public class SchemaVersions {
+
+ @Value("#{'${schema.version.list}'.split(',')}")
+ private List<String> apiVersions;
+
+ @Value("${schema.version.api.default}")
+ private String defaultApiVersion;
+
+ @Value("${schema.version.edge.label.start}")
+ private String edgeLabelStartVersion;
+
+ @Value("${schema.version.depth.start}")
+ private String depthStartVersion;
+
+ @Value("${schema.version.app.root.start}")
+ private String appRootStartVersion;
+
+ @Value("${schema.version.related.link.start}")
+ private String relatedLinkStartVersion;
+
+ @Value("${schema.version.namespace.change.start}")
+ private String namespaceChangeStartVersion;
+
+ private List<SchemaVersion> versions;
+
+ private SchemaVersion edgeLabelVersion;
+ private SchemaVersion defaultVersion;
+ private SchemaVersion depthVersion;
+ private SchemaVersion appRootVersion;
+ private SchemaVersion relatedLinkVersion;
+ private SchemaVersion namespaceChangeVersion;
+
+ @PostConstruct
+ public void initialize() {
+ versions = apiVersions.stream().map(SchemaVersion::new).collect(Collectors.toList());
+
+ edgeLabelVersion = new SchemaVersion(edgeLabelStartVersion);
+ defaultVersion = new SchemaVersion(defaultApiVersion);
+ depthVersion = new SchemaVersion(depthStartVersion);
+ appRootVersion = new SchemaVersion(appRootStartVersion);
+ relatedLinkVersion = new SchemaVersion(relatedLinkStartVersion);
+ namespaceChangeVersion = new SchemaVersion(namespaceChangeStartVersion);
+
+ if (!versions.contains(edgeLabelVersion)) {
+ throw new AAISchemaValidationException(
+ "Invalid, edge label version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.edge.label.start is in that list"
+ );
+ }
+
+ if (!versions.contains(defaultVersion)) {
+ throw new AAISchemaValidationException(
+ "Invalid, default version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.api.default is in that list"
+ );
+ }
+
+ if (!versions.contains(depthVersion)) {
+ throw new AAISchemaValidationException(
+ "Invalid, depth version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.depth.start is in that list"
+ );
+ }
+
+ if(!versions.contains(appRootVersion)){
+ throw new AAISchemaValidationException(
+ "Invalid, app root version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.app.root.start is in that list"
+ );
+ }
+
+ if(!versions.contains(relatedLinkVersion)){
+ throw new AAISchemaValidationException(
+ "Invalid, related link version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.related.link.start is in that list"
+ );
+ }
+
+ if(!versions.contains(namespaceChangeVersion)){
+ throw new AAISchemaValidationException(
+ "Invalid, namespace change start version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.related.link.start is in that list"
+ );
+ }
+ }
+
+ public List<SchemaVersion> getVersions() {
+ return versions;
+ }
+
+ public SchemaVersion getEdgeLabelVersion() {
+ return edgeLabelVersion;
+ }
+
+ public SchemaVersion getDefaultVersion() {
+ return defaultVersion;
+ }
+
+ public SchemaVersion getDepthVersion() {
+ return depthVersion;
+ }
+
+ public SchemaVersion getAppRootVersion(){
+ return appRootVersion;
+ }
+
+ public SchemaVersion getRelatedLinkVersion(){
+ return relatedLinkVersion;
+ }
+
+ public SchemaVersion getNamespaceChangeVersion() {
+ return namespaceChangeVersion;
+ }
+
+ public void setNamespaceChangeVersion(SchemaVersion namespaceChangeVersion) {
+ this.namespaceChangeVersion = namespaceChangeVersion;
+ }
+
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java
deleted file mode 100644
index 1fd1481d..00000000
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 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=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.onap.aai.setup;
-
-public enum Version {
- V7,
- V8,
- V9,
- V10,
- V11,
- V12,
- V13;
-
- public static boolean isLatest(Version v) {
- return getLatest().equals(v);
- }
-
- public static Version getLatest(){
- Version[] vals = values(); //guaranteed to be in declaration order
- return vals[vals.length-1]; //requires we always have the latest version listed last
- }
-}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java
index a3784b77..3fd536b0 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java
index d8b4eb39..768c18bd 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
/**
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
index d1f5647b..7eae7508 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
/**
@@ -29,7 +27,7 @@ import java.util.List;
import java.util.Map;
import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -52,12 +50,12 @@ public class DefaultVersionValidationModule implements VersionValidationModule {
*/
@Override
public String validate() {
- Map<Version, List<String>> nodeConfig = config.getNodeFiles();
- Map<Version, List<String>> edgeConfig = config.getEdgeFiles();
+ Map<SchemaVersion, List<String>> nodeConfig = config.getNodeFiles();
+ Map<SchemaVersion, List<String>> edgeConfig = config.getEdgeFiles();
StringBuilder missingVers = new StringBuilder().append("Missing schema for the following versions: ");
boolean isMissing = false;
- for (Version v : Version.values()) {
+ for (SchemaVersion v : config.getSchemaVersions().getVersions()) {
if (nodeConfig.get(v) == null) {
isMissing = true;
missingVers.append(v.toString()).append(" has no OXM configured. ");
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java
index 07180855..2c21e685 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
/**
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java
index 0f2f2673..cefc29c2 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java
index e0b6e12a..b87be79a 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
index 24c05db0..612da353 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java
index 85b4dc64..05b79753 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.edges;
@@ -51,7 +49,7 @@ public class CousinDefaultingValidationModule {
*/
public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new EdgeRuleQuery.Builder(types[0], types[1]).edgeType(EdgeType.COUSIN).build();
+ EdgeRuleQuery lookup = new Builder(types[0], types[1]).edgeType(EdgeType.COUSIN).build();
List<Map<String, String>> rules = new ArrayList<>();
for (DocumentContext ctx : ctxs) {
rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java
index ff58e7dd..01e9e296 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
/**
@@ -47,7 +45,7 @@ public class DefaultEdgeFieldsValidationModule implements EdgeFieldsValidationMo
EnumSet<EdgeField> missingFields = EnumSet.complementOf(EnumSet.allOf(EdgeField.class));
for (EdgeField f : EdgeField.values()) {
- if (!rule.containsKey(f.toString()) && (f != EdgeField.DESCRIPTION)) { //description is optional
+ if (!rule.containsKey(f.toString()) && (f != EdgeField.DESCRIPTION) && (f != EdgeField.PRIVATE)) { //description is optional
missingFields.add(f);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java
index b2d153fa..10ac1892 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.edges;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
index 34c603aa..309d8945 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.edges;
@@ -26,14 +24,13 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.edges.TypeAlphabetizer;
import org.onap.aai.edges.enums.EdgeField;
import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.validation.SchemaErrorStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -45,7 +42,7 @@ import com.jayway.jsonpath.DocumentContext;
*/
@Component
public class EdgeRuleValidator {
- private Map<Version, List<DocumentContext>> versionJsonFilesMap;
+ private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
private final SchemaErrorStrategy strat;
protected final EdgeFieldsValidationModule fieldValidator;
protected final UniqueLabelValidationModule labelValidator;
@@ -69,8 +66,8 @@ public class EdgeRuleValidator {
public boolean validate() {
- for (Entry<Version, List<DocumentContext>> verEntry : versionJsonFilesMap.entrySet()) {
- Version v = verEntry.getKey();
+ for (Map.Entry<SchemaVersion, List<DocumentContext>> verEntry : versionJsonFilesMap.entrySet()) {
+ SchemaVersion v = verEntry.getKey();
List<DocumentContext> ctxs = verEntry.getValue();
List<Map<String, String>> rules = collectRules(ctxs);
Set<String> nodeTypePairs = new HashSet<>();
@@ -89,7 +86,7 @@ public class EdgeRuleValidator {
handleResult(typeValidator.validate(nodeTypePairs, v));
}
-
+
return strat.isOK();
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
index 6d061245..b4ed3782 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.edges;
@@ -27,7 +25,7 @@ import java.util.HashSet;
import java.util.Set;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -50,13 +48,13 @@ public class NodeTypesValidationModule {
* Validate that every node type in the given set is defined in
* the OXM for the given version
*
- * @param Collection<String> nodeTypes - all the node types in
+ * @param nodeTypePairs - all the node types in
* the edge rules for the given version being validated
- * @param Version v - the version being validated
+ * @param v - the version being validated
* @return empty string if all types are present in the given version's ingested OXM, else
* appropriate error message
*/
- public String validate(Collection<String> nodeTypePairs, Version v) {
+ public String validate(Collection<String> nodeTypePairs, SchemaVersion v) {
//setup
Set<String> nodeTypes = new HashSet<>();
for (String pair : nodeTypePairs) {
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java
index 15e1c2aa..4586ccce 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.edges;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java
index bed6cadd..103baaba 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.edges;
@@ -51,7 +49,7 @@ public class UniqueLabelValidationModule {
*/
public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new EdgeRuleQuery.Builder(types[0], types[1]).build();
+ EdgeRuleQuery lookup = new Builder(types[0], types[1]).build();
List<Map<String, String>> rules = new ArrayList<>();
for (DocumentContext ctx : ctxs) {
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java
index f8536684..bbb3388f 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.nodes;
@@ -33,7 +31,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -55,7 +53,7 @@ public class DefaultDuplicateNodeDefinitionValidationModule implements Duplicate
* @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
*/
@Override
- public String findDuplicates(List<String> files, Version v) {
+ public String findDuplicates(List<String> files, SchemaVersion v) {
try {
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
@@ -88,7 +86,7 @@ public class DefaultDuplicateNodeDefinitionValidationModule implements Duplicate
}
}
- private String buildErrorMsg(Multimap<String, String> types, Version v) {
+ private String buildErrorMsg(Multimap<String, String> types, SchemaVersion v) {
StringBuilder errorMsg = new StringBuilder().append("Duplicates found in version ").append(v.toString()).append(". ");
for (String nodeType : types.keySet()) {
Collection<String> files = types.get(nodeType);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java
index b7cd4a07..5484adda 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,15 +16,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.nodes;
import java.util.List;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
/**
* Defines rules for duplicate node definitions in a set of files
@@ -45,5 +43,5 @@ public interface DuplicateNodeDefinitionValidationModule {
* with appropriate information about what node types
* were found
*/
- public String findDuplicates(List<String> files, Version v);
+ String findDuplicates(List<String> files, SchemaVersion v);
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
index f8089a19..27a69f9b 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 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.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.validation.nodes;
@@ -26,7 +24,7 @@ import java.util.List;
import java.util.Map.Entry;
import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.validation.SchemaErrorStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -46,7 +44,7 @@ public class NodeValidator {
public boolean validate() {
- for(Entry<Version, List<String>> entry : translator.getNodeFiles().entrySet()) {
+ for(Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
if (!"".equals(result)) {
strat.notifyOnError(result);