aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-ingest/src
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2019-01-11 14:13:38 -0500
committerKajur, Harish (vk250x) <vk250x@att.com>2019-01-13 20:30:47 -0500
commit5a4ff0ea07e8f5b5dde84c9ef171f188dd8a134c (patch)
tree8440af5a79557c99f42a29eb07b0f519d6c4a1a6 /aai-schema-ingest/src
parent1dd67efcaf40c5b4278ad8594b78f63a838514ca (diff)
Sync up the changes for v15
Issue-ID: AAI-1811 Change-Id: I307731ee35d8a644ae995c4b372345a7ebeca0a1 Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com> Signed-off-by: Harish Venkata Kajur <vk250x@att.com>
Diffstat (limited to 'aai-schema-ingest/src')
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java2
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java78
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java3
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java31
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java2
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java31
7 files changed, 107 insertions, 44 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
index 94bc6da5..50738df9 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
@@ -68,7 +68,7 @@ public class NodesConfiguration {
LOGGER.info("Translator is SchemaServiceTranslator");
translators.add(schemaConfiguration.schemaServiceTranslator());
} else {
- LOGGER.info("Translator is SchemaServiceTranslator");
+ LOGGER.info("Translator is ConfigTranslator");
translators.add(translatorConfiguration.configTranslator);
}
return translators;
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 71225340..213ff590 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
@@ -59,7 +59,7 @@ import static com.jayway.jsonpath.Filter.filter;
@Component
public class EdgeIngestor {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(EdgeIngestor.class);
- private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
+ private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap = new TreeMap<>();
private static final String READ_START = "$.rules.[?]";
private static final String READ_ALL_START = "$.rules.*";
private SchemaVersions schemaVersions;
@@ -94,7 +94,7 @@ public class EdgeIngestor {
}
}
if (versionJsonFilesMap.isEmpty() || schemaVersions==null ) {
- throw new ExceptionInInitializerError();
+ throw new ExceptionInInitializerError("EdgeIngestor could not ingest edgerules");
}
}
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 d6fec83d..c25fc789 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
@@ -60,26 +60,26 @@ public class EdgeRuleQuery {
private static final String FROM_ONLY = "FromOnly";
- //required
+ //required
private String nodeA;
-
+
//optional - null will translate to any value of the param
- private String nodeB = null;
+ private String nodeB = null;
private String label = null;
private EdgeType type = null;
private AAIDirection direction = null;
private boolean isPrivate = false;
private SchemaVersion version = null;
-
+
public Builder(String nodeA) {
this.nodeA = nodeA;
}
-
+
public Builder(String nodeA, String nodeB) {
this.nodeA = nodeA;
this.nodeB = nodeB;
}
-
+
private String getFirstNodeType() {
return nodeA;
}
@@ -87,7 +87,7 @@ public class EdgeRuleQuery {
this.nodeB = FROM_ONLY;
return this;
}
-
+
private String getSecondNodeType() {
return nodeB;
}
@@ -105,35 +105,35 @@ public class EdgeRuleQuery {
this.nodeA = TO_ONLY;
return this;
}
-
+
public Builder label(String label) {
this.label = label;
return this;
}
-
+
private String getLabel() {
return label;
}
-
+
public Builder edgeType(EdgeType type) {
this.type = type;
return this;
}
-
+
private EdgeType getEdgeType() {
return type;
}
-
+
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;
@@ -151,12 +151,12 @@ public class EdgeRuleQuery {
private Optional<SchemaVersion> getSchemaVersion() {
return Optional.ofNullable(version);
}
-
+
public EdgeRuleQuery build() {
return new EdgeRuleQuery(this);
}
}
-
+
private EdgeRuleQuery(Builder builder) {
this.v = builder.getSchemaVersion();
this.nodeA = builder.getFirstNodeType();
@@ -165,7 +165,7 @@ public class EdgeRuleQuery {
this.type = builder.getEdgeType();
this.direction = builder.getDirection();
this.isPrivate = builder.isPrivate();
-
+
//will cover from A to B case
List<Predicate> criteriaFromTo = new ArrayList<>();
//Special logic to allow for A to B case only
@@ -187,8 +187,8 @@ public class EdgeRuleQuery {
criteriaFromTo.add(labelPred);
criteriaToFrom.add(labelPred);
}
-
- if (builder.getEdgeType() != null) {
+
+ if (builder.getEdgeType() != null && builder.getEdgeType() != EdgeType.ALL) {
Predicate typePred = addType(builder.getEdgeType());
criteriaFromTo.add(typePred);
criteriaToFrom.add(typePred);
@@ -199,7 +199,7 @@ public class EdgeRuleQuery {
criteriaFromTo.add(privatePredicate);
criteriaToFrom.add(privatePredicate);
}
-
+
if (builder.getDirection() != null) {
Predicate directionPred = addDirection(builder.getDirection());
criteriaFromTo.add(directionPred);
@@ -213,14 +213,14 @@ public class EdgeRuleQuery {
this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
}
}
-
+
private Predicate buildToFromPart(String from, String to) {
if (from == null && to == null) { //shouldn't ever happen though
throw new IllegalStateException("must have at least one node defined");
}
-
+
Predicate p;
-
+
if (to == null) {
p = where(EdgeField.FROM.toString()).is(from);
} else if (from == null) {
@@ -228,14 +228,14 @@ public class EdgeRuleQuery {
} else {
p = where(EdgeField.FROM.toString()).is(from).and(EdgeField.TO.toString()).is(to);
}
-
+
return p;
}
-
+
private Predicate addLabel(String label) {
return where(EdgeField.LABEL.toString()).is(label);
}
-
+
private Predicate addType(EdgeType type) {
if (type == EdgeType.COUSIN) {
return where(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString());
@@ -243,7 +243,7 @@ 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());
@@ -256,7 +256,7 @@ public class EdgeRuleQuery {
}
return where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
}
-
+
/**
* Provides the JsonPath filter for actually querying the edge rule schema files
* @return Filter
@@ -264,24 +264,24 @@ public class EdgeRuleQuery {
public Filter getFilter() {
return this.filter;
}
-
+
/**
* 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
@@ -289,21 +289,21 @@ public class EdgeRuleQuery {
public Optional<SchemaVersion> getVersion() {
return this.v;
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
-
+
sb.append("EdgeRuleQuery with filter params node type: ").append(nodeA);
-
+
if (nodeB != null) {
sb.append(", node type: ").append(nodeB);
}
-
+
if (label != null) {
sb.append(", label: ").append(label);
- }
-
+ }
+
sb.append(", type: ");
if (type != null) {
sb.append(type.toString());
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 3ae59ab7..4662f862 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
@@ -21,5 +21,6 @@ package org.onap.aai.edges.enums;
public enum EdgeType {
COUSIN,
- TREE;
+ TREE,
+ ALL;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java
new file mode 100644
index 00000000..96fd65cc
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java
@@ -0,0 +1,31 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * 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.
+ * 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.edges.exceptions;
+
+public class EdgeIngestorException extends Exception {
+ public EdgeIngestorException(String msg) {
+ super(msg);
+ }
+
+ public EdgeIngestorException(Throwable throwable){
+ super(throwable);
+ }
+}
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 1945a1ef..69cd51ab 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
@@ -98,7 +98,7 @@ public class NodeIngestor {
}
}
if (versionContextMap.isEmpty() || schemaPerVersion.isEmpty() || typesPerVersion.isEmpty()) {
- throw new ExceptionInInitializerError();
+ throw new ExceptionInInitializerError("NodeIngestor could not ingest schema");
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java
new file mode 100644
index 00000000..adaf538e
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java
@@ -0,0 +1,31 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * 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.
+ * 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.nodes.exceptions;
+
+public class NodeIngestorException extends Exception {
+ public NodeIngestorException(String msg) {
+ super(msg);
+ }
+
+ public NodeIngestorException(Throwable throwable){
+ super(throwable);
+ }
+}