aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-ingest/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-ingest/src/main/java')
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java11
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java13
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java9
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java3
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java532
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java370
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java80
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java13
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java22
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java76
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java69
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java47
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java30
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java20
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java5
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java30
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java2
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java21
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java79
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java2
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java50
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java38
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java15
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java135
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java75
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java10
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java216
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java99
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java14
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java28
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java19
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java58
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java50
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java67
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java17
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java57
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java64
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java17
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java42
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java94
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java73
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java48
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java119
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java103
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java51
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java67
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java111
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java18
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java45
54 files changed, 1655 insertions, 1603 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
index 11f0da6a..e4d18650 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.setup.SchemaConfigVersions;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java
index 605dc0cf..af4d8e8e 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java
@@ -19,8 +19,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,11 +37,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
@Import({SchemaServiceConfiguration.class, ConfigConfiguration.class, TranslatorConfiguration.class})
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
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 8c520aaa..a6675d43 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
@@ -19,10 +19,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,12 +40,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-
@Import({SchemaServiceConfiguration.class, ConfigConfiguration.class, TranslatorConfiguration.class})
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java
index 0a3dbf5e..9f523935 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.restclient.*;
@@ -59,21 +60,21 @@ public class RestConfiguration {
}
/*
- In the below cases bean name and method names are different because all of them qualify as restClient
+ * In the below cases bean name and method names are different because all of them qualify as restClient
*/
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@ConditionalOnProperty(name = "schema.service.client", havingValue = "two-way-ssl", matchIfMissing = true)
public RestClient getSchemaServiceTwoWayClient() {
return new SchemaServiceRestClient();
}
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@ConditionalOnProperty(name = "schema.service.client", havingValue = "no-auth")
public RestClient getSchemaServiceNoAuthClient() {
return new SchemaServiceNoAuthClient();
}
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@ConditionalOnProperty(name = "schema.service.client", havingValue = "one-way-ssl")
public RestClient getSchemaServiceOneWayClient() {
return new SchemaServiceOneWayClient();
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
index c6decb03..cdd87492 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.setup.*;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java
index 941e03d9..d49e6ec7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.setup.*;
@@ -29,7 +30,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnProperty(prefix = "schema.translator.list", value = "config", matchIfMissing = true)
public class TranslatorConfiguration {
- //TODO check if you can put dependsOn to reduce number of config files
+ // TODO check if you can put dependsOn to reduce number of config files
@Autowired(required = false)
ConfigTranslator configTranslator;
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 5d8c3d55..3cf67052 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
@@ -20,6 +20,9 @@
package org.onap.aai.edges;
+import static com.jayway.jsonpath.Criteria.where;
+import static com.jayway.jsonpath.Filter.filter;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.common.cache.CacheBuilder;
@@ -30,6 +33,15 @@ import com.google.common.collect.Multimap;
import com.jayway.jsonpath.Criteria;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.Filter;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.onap.aai.edges.enums.DirectionNotation;
import org.onap.aai.edges.enums.EdgeField;
@@ -42,19 +54,9 @@ import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.io.IOException;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
-import java.util.stream.Collectors;
-
-import static com.jayway.jsonpath.Criteria.where;
-import static com.jayway.jsonpath.Filter.filter;
-
/**
* EdgeIngestor - ingests A&AI edge rule schema files per given config, serves that edge rule
- * information, including allowing various filters to extract particular rules.
+ * information, including allowing various filters to extract particular rules.
*/
@Component
public class EdgeIngestor {
@@ -68,7 +70,7 @@ public class EdgeIngestor {
private Set<String> multipleLabelKeys;
- private LoadingCache<SchemaFilter,Multimap<String,EdgeRule>> cacheFilterStore;
+ private LoadingCache<SchemaFilter, Multimap<String, EdgeRule>> cacheFilterStore;
private LoadingCache<String, String[]> cousinLabelStore;
@@ -82,7 +84,7 @@ public class EdgeIngestor {
@PostConstruct
public void initialize() {
- for (Translator translator : translators) {
+ for (Translator translator : translators) {
try {
LOGGER.debug("Processing the translator");
translateAll(translator);
@@ -92,27 +94,29 @@ public class EdgeIngestor {
throw new ExceptionInInitializerError("EdgeIngestor could not ingest schema");
}
}
- if (versionJsonFilesMap.isEmpty() || schemaVersions==null ) {
+ if (versionJsonFilesMap.isEmpty() || schemaVersions == null) {
throw new ExceptionInInitializerError("EdgeIngestor could not ingest edgerules");
}
}
- public void translateAll(Translator translator) throws ExceptionInInitializerError{
+ public void translateAll(Translator translator) throws ExceptionInInitializerError {
/*
- Use SchemaVersions from the Translator
+ * Use SchemaVersions from the Translator
*/
this.schemaVersions = translator.getSchemaVersions();
List<SchemaVersion> schemaVersionList = this.schemaVersions.getVersions();
List<String> jsonPayloads = null;
JsonIngestor ji = new JsonIngestor();
- Map<SchemaVersion, List<String>> edgeRulesToIngest = new HashMap<>(); // Obtain a map of schema versions to a list of strings. One List per key
+ Map<SchemaVersion, List<String>> edgeRulesToIngest = new HashMap<>(); // Obtain a map of schema versions to a
+ // list of strings. One List per key
// Add to the map the JSON file per version.
for (SchemaVersion version : schemaVersionList) {
LOGGER.debug("Version being processed" + version);
// If the flag is set to not use the local files, obtain the Json from the service.
try {
- jsonPayloads = translator.getJsonPayload(version); // need to change this - need to receive the json files.
+ jsonPayloads = translator.getJsonPayload(version); // need to change this - need to receive the json
+ // files.
} catch (IOException e) {
LOGGER.error("Error in retrieving the JSON Payload" + e.getMessage());
throw new ExceptionInInitializerError("EdgeIngestor could not ingest schema");
@@ -125,43 +129,36 @@ public class EdgeIngestor {
}
versionJsonFilesMap = ji.ingestContent(edgeRulesToIngest);
- this.cacheFilterStore = CacheBuilder.newBuilder()
- .maximumSize(2000)
- .build(
- new CacheLoader<SchemaFilter, Multimap<String, EdgeRule>>() {
+ this.cacheFilterStore = CacheBuilder.newBuilder().maximumSize(2000)
+ .build(new CacheLoader<SchemaFilter, Multimap<String, EdgeRule>>() {
@Override
public Multimap<String, EdgeRule> load(SchemaFilter key) {
return extractRules(key);
}
- }
- );
+ });
- this.cousinLabelStore = CacheBuilder.newBuilder()
- .maximumSize(50)
- .build(
- new CacheLoader<String, String[]>() {
- @Override
- public String[] load(String key) throws Exception {
- return retrieveCousinLabels(key);
- }
- }
- );
+ this.cousinLabelStore = CacheBuilder.newBuilder().maximumSize(50).build(new CacheLoader<String, String[]>() {
+ @Override
+ public String[] load(String key) throws Exception {
+ return retrieveCousinLabels(key);
+ }
+ });
}
-// //-----methods for getting rule info-----//
-//
+ // //-----methods for getting rule info-----//
+ //
/**
* Gets list of all edge rules defined in the latest version's schema
*
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules associated with those types
- * where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * 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.
+ * where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * 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.
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getAllCurrentRules() throws EdgeRuleNotFoundException {
@@ -173,22 +170,22 @@ public class EdgeIngestor {
*
* A lazy instantiation to retrieve all this info on first call
*
- * @return a set containing a list of strings where each string is
- * concatenated by a pipe (|) character such as aNodeType|bNodeType
+ * @return a set containing a list of strings where each string is
+ * concatenated by a pipe (|) character such as aNodeType|bNodeType
*/
- public Set<String> getMultipleLabelKeys(){
+ public Set<String> getMultipleLabelKeys() {
- if(multipleLabelKeys == null){
+ if (multipleLabelKeys == null) {
multipleLabelKeys = new HashSet<>();
try {
final Multimap<String, EdgeRule> edges = this.getAllCurrentRules();
- if(edges == null || edges.isEmpty()){
+ if (edges == null || edges.isEmpty()) {
LOGGER.warn("Unable to find any edge rules for the latest version");
return multipleLabelKeys;
}
edges.keySet().forEach(key -> {
Collection<EdgeRule> rules = edges.get(key);
- if(rules.size() > 1){
+ if (rules.size() > 1) {
multipleLabelKeys.add(key);
}
});
@@ -199,18 +196,19 @@ public class EdgeIngestor {
return multipleLabelKeys;
}
+
/**
* Gets list of all edge rules defined in the given version's schema
*
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules associated with those types
- * where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * 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.
+ * where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * 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.
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getAllRules(SchemaVersion v) throws EdgeRuleNotFoundException {
@@ -229,19 +227,19 @@ public class EdgeIngestor {
* @param q - EdgeRuleQuery with filter criteria set
*
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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.
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getRules(EdgeRuleQuery q) throws EdgeRuleNotFoundException {
Multimap<String, EdgeRule> found = null;
- if(q.getVersion().isPresent()){
+ if (q.getVersion().isPresent()) {
found = extractRules(q.getFilter(), q.getVersion().get());
} else {
found = extractRules(q.getFilter(), schemaVersions.getDefaultVersion());
@@ -253,7 +251,8 @@ public class EdgeIngestor {
found.entries().stream().forEach((entry) -> {
EdgeRule rule = new EdgeRule(entry.getValue());
if (!q.getFromType().equals(rule.getFrom())) {
- /* To maintain backwards compatibility with old EdgeRules API,
+ /*
+ * 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.
@@ -270,8 +269,6 @@ public class EdgeIngestor {
}
}
-
-
/**
* Gets the rule satisfying the given filter criteria. If there are more than one
* that match, return the default rule. If there is no clear default to return, or
@@ -281,16 +278,16 @@ public class EdgeIngestor {
* @return EdgeRule satisfying given criteria
* @throws EdgeRuleNotFoundException if none found that match
* @throws AmbiguousRuleChoiceException if multiple match but no way to choice one from them
- * Specifically, if multiple node type pairs come back (ie bar|foo and asdf|foo,
- * no way to know which is appropriate over the others),
- * or if there is a mix of Tree and Cousin edges because again there is no way to
- * know which is "defaulter" than the other.
- * The default property only clarifies among multiple cousin edges of the same node pair,
- * ex: which l-interface|logical-link rule to default to.
+ * Specifically, if multiple node type pairs come back (ie bar|foo and asdf|foo,
+ * no way to know which is appropriate over the others),
+ * or if there is a mix of Tree and Cousin edges because again there is no way to
+ * know which is "defaulter" than the other.
+ * The default property only clarifies among multiple cousin edges of the same node pair,
+ * ex: which l-interface|logical-link rule to default to.
*/
public EdgeRule getRule(EdgeRuleQuery q) throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
Multimap<String, EdgeRule> found = null;
- if(q.getVersion().isPresent()){
+ if (q.getVersion().isPresent()) {
found = extractRules(q.getFilter(), q.getVersion().get());
} else {
found = extractRules(q.getFilter(), schemaVersions.getDefaultVersion());
@@ -301,7 +298,7 @@ public class EdgeIngestor {
}
EdgeRule rule = null;
- if (found.keys().size() == 1) { //only one found, cool we're done
+ if (found.keys().size() == 1) { // only one found, cool we're done
for (Entry<String, EdgeRule> e : found.entries()) {
rule = e.getValue();
}
@@ -309,12 +306,13 @@ public class EdgeIngestor {
rule = getDefaultRule(found);
}
- if (rule == null) { //should never get here though
+ if (rule == null) { // should never get here though
throw new EdgeRuleNotFoundException("No rule found for " + q.toString() + ".");
} else {
rule = new EdgeRule(rule);
if (!q.getFromType().equals(rule.getFrom())) {
- /* To maintain backwards compatibility with old EdgeRules API,
+ /*
+ * 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.
@@ -329,12 +327,13 @@ public class EdgeIngestor {
}
private EdgeRule getDefaultRule(Multimap<String, EdgeRule> found) throws AmbiguousRuleChoiceException {
- if (found.keySet().size() > 1) { //ie multiple node pairs (a|c and b|c not just all a|c) case
+ if (found.keySet().size() > 1) { // ie multiple node pairs (a|c and b|c not just all a|c) case
StringBuilder sb = new StringBuilder();
for (String k : found.keySet()) {
sb.append(k).append(" ");
}
- throw new AmbiguousRuleChoiceException("No way to select single rule from these pairs: " + sb.toString() + ".");
+ throw new AmbiguousRuleChoiceException(
+ "No way to select single rule from these pairs: " + sb.toString() + ".");
}
int defaultCount = 0;
@@ -354,6 +353,7 @@ public class EdgeIngestor {
return defRule;
}
+
/**
* Checks if there exists any rule that satisfies the given filter criteria.
*
@@ -361,7 +361,7 @@ public class EdgeIngestor {
* @return boolean
*/
public boolean hasRule(EdgeRuleQuery q) {
- if(q.getVersion().isPresent()){
+ if (q.getVersion().isPresent()) {
return !extractRules(q.getFilter(), q.getVersion().get()).isEmpty();
} else {
return !extractRules(q.getFilter(), schemaVersions.getDefaultVersion()).isEmpty();
@@ -373,28 +373,25 @@ public class EdgeIngestor {
*
* @param nodeType
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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) {
- return getCousinRules(nodeType, schemaVersions.getDefaultVersion()); //default to latest
+ return getCousinRules(nodeType, schemaVersions.getDefaultVersion()); // default to latest
}
- public String[] retrieveCousinLabels(String nodeType){
+ public String[] retrieveCousinLabels(String nodeType) {
Multimap<String, EdgeRule> cousinRules = getCousinRules(nodeType);
String[] cousinLabels = new String[cousinRules.size()];
- return cousinRules.entries()
- .stream()
- .map(entry -> entry.getValue().getLabel())
- .collect(Collectors.toList())
- .toArray(cousinLabels);
+ return cousinRules.entries().stream().map(entry -> entry.getValue().getLabel()).collect(Collectors.toList())
+ .toArray(cousinLabels);
}
public String[] retrieveCachedCousinLabels(String nodeType) throws ExecutionException {
@@ -407,13 +404,13 @@ public class EdgeIngestor {
* @param nodeType
* @param v - the version of the edge rules to query
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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, SchemaVersion v) {
return extractRules(new EdgeRuleQuery.Builder(nodeType).edgeType(EdgeType.COUSIN).build().getFilter(), v);
@@ -421,6 +418,7 @@ public class EdgeIngestor {
/**
* Returns if the given node type has any cousin relationships in the current version.
+ *
* @param nodeType
* @return boolean
*/
@@ -430,6 +428,7 @@ public class EdgeIngestor {
/**
* Returns if the given node type has any cousin relationships in the given version.
+ *
* @param nodeType
* @return boolean
*/
@@ -442,13 +441,13 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the container in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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) {
return getChildRules(nodeType, schemaVersions.getDefaultVersion());
@@ -459,24 +458,28 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the container in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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, SchemaVersion v) {
- Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getSameDirectionContainmentCriteria());
- Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
+ 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);
return extractRules(total, v);
}
/**
- * Returns if the given node type has any child relationships (ie it contains another node type) in the current version.
+ * Returns if the given node type has any child relationships (ie it contains another node type) in the current
+ * version.
+ *
* @param nodeType
* @return boolean
*/
@@ -485,7 +488,9 @@ public class EdgeIngestor {
}
/**
- * Returns if the given node type has any child relationships (ie it contains another node type) in the given version.
+ * Returns if the given node type has any child relationships (ie it contains another node type) in the given
+ * version.
+ *
* @param nodeType
* @return boolean
*/
@@ -498,13 +503,13 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the containee in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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) {
return getParentRules(nodeType, schemaVersions.getDefaultVersion());
@@ -515,24 +520,28 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the containee in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * 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.
+ * 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, SchemaVersion v) {
- Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
- Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getSameDirectionContainmentCriteria());
+ 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);
return extractRules(total, v);
}
/**
- * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the current version.
+ * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the
+ * current version.
+ *
* @param nodeType
* @return boolean
*/
@@ -541,7 +550,9 @@ public class EdgeIngestor {
}
/**
- * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the given version.
+ * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the
+ * given version.
+ *
* @param nodeType
* @return boolean
*/
@@ -549,22 +560,22 @@ public class EdgeIngestor {
return !getParentRules(nodeType, v).isEmpty();
}
- /**
- * Applies the given filter to the DocumentContext(s) for the given version to extract
- * edge rules, and converts this extracted information into the Multimap form
- *
- * @param filter - JsonPath filter to read the DocumentContexts with. May be null
- * to denote no filter, ie get all.
- * @param v - The schema version to extract from
- * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * 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.
- */
+ /**
+ * Applies the given filter to the DocumentContext(s) for the given version to extract
+ * edge rules, and converts this extracted information into the Multimap form
+ *
+ * @param filter - JsonPath filter to read the DocumentContexts with. May be null
+ * to denote no filter, ie get all.
+ * @param v - The schema version to extract from
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * 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, SchemaVersion v) {
SchemaFilter schemaFilter = new SchemaFilter(filter, v);
try {
@@ -575,7 +586,7 @@ public class EdgeIngestor {
}
}
- public Multimap<String, EdgeRule> extractRules(SchemaFilter schemaFilter){
+ public Multimap<String, EdgeRule> extractRules(SchemaFilter schemaFilter) {
List<Map<String, String>> foundRules = new ArrayList<>();
List<DocumentContext> docs = versionJsonFilesMap.get(schemaFilter.getSchemaVersion());
if (docs != null) {
@@ -591,115 +602,118 @@ public class EdgeIngestor {
return convertToEdgeRules(foundRules);
}
- //-----filter building helpers-----//
- /**
- * ANDs together the given start criteria with each criteria in the pieces list, and
- * then ORs together these segments into one filter.
- *
- * JsonPath doesn't have an OR method on Criteria, only on Filters, so assembling
- * a complete filter requires this sort of roundabout construction.
- *
- * @param start - Criteria of the form where(from/to).is(nodeType)
- * (ie the start of any A&AI edge rule query)
- * @param pieces - Other Criteria to be applied
- * @return Filter constructed from the given Criteria
- */
- private Filter assembleFilterSegments(Criteria start, List<Criteria> pieces) {
- List<Filter> segments = new ArrayList<>();
- for (Criteria c : pieces) {
- segments.add(filter(start).and(c));
- }
- Filter assembled = segments.remove(0);
- for (Filter f : segments) {
- assembled = assembled.or(f);
- }
- return assembled;
- }
-
- /**
- * Builds the sub-Criteria for a containment edge rule query where the direction
- * and containment fields must match.
- *
- * Used for getChildRules() where the container node type is in the "from" position and
- * for getParentRules() where the containee type is in the "to" position.
- *
- * @return List<Criteria> covering property permutations defined with either notation or explicit direction
- */
- private List<Criteria> getSameDirectionContainmentCriteria() {
- List<Criteria> crits = new ArrayList<>();
-
- crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.DIRECTION.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.OUT.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.IN.toString()));
-
- return crits;
- }
-
- /**
- * Builds the sub-Criteria for a containment edge rule query where the direction
- * and containment fields must not match.
- *
- * Used for getChildRules() where the container node type is in the "to" position and
- * for getParentRules() where the containee type is in the "from" position.
- *
- * @return List<Criteria> covering property permutations defined with either notation or explicit direction
- */
- private List<Criteria> getOppositeDirectionContainmentCriteria() {
- List<Criteria> crits = new ArrayList<>();
-
- crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.OPPOSITE.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.IN.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.OUT.toString()));
-
- return crits;
- }
-
- //-----rule packaging helpers-----//
- /**
- * Converts the raw output from reading the json file to the Multimap<String key, EdgeRule> format
- *
- * @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
- * was empty.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * 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> convertToEdgeRules(List<Map<String, String>> allFound) {
- Multimap<String, EdgeRule> rules = ArrayListMultimap.create();
-
- TypeAlphabetizer alpher = new TypeAlphabetizer();
-
- 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;
- }
+ // -----filter building helpers-----//
+ /**
+ * ANDs together the given start criteria with each criteria in the pieces list, and
+ * then ORs together these segments into one filter.
+ *
+ * JsonPath doesn't have an OR method on Criteria, only on Filters, so assembling
+ * a complete filter requires this sort of roundabout construction.
+ *
+ * @param start - Criteria of the form where(from/to).is(nodeType)
+ * (ie the start of any A&AI edge rule query)
+ * @param pieces - Other Criteria to be applied
+ * @return Filter constructed from the given Criteria
+ */
+ private Filter assembleFilterSegments(Criteria start, List<Criteria> pieces) {
+ List<Filter> segments = new ArrayList<>();
+ for (Criteria c : pieces) {
+ segments.add(filter(start).and(c));
+ }
+ Filter assembled = segments.remove(0);
+ for (Filter f : segments) {
+ assembled = assembled.or(f);
+ }
+ return assembled;
+ }
+
+ /**
+ * Builds the sub-Criteria for a containment edge rule query where the direction
+ * and containment fields must match.
+ *
+ * Used for getChildRules() where the container node type is in the "from" position and
+ * for getParentRules() where the containee type is in the "to" position.
+ *
+ * @return List<Criteria> covering property permutations defined with either notation or explicit direction
+ */
+ private List<Criteria> getSameDirectionContainmentCriteria() {
+ List<Criteria> crits = new ArrayList<>();
+
+ crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.DIRECTION.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.OUT.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.IN.toString()));
+
+ return crits;
+ }
+
+ /**
+ * Builds the sub-Criteria for a containment edge rule query where the direction
+ * and containment fields must not match.
+ *
+ * Used for getChildRules() where the container node type is in the "to" position and
+ * for getParentRules() where the containee type is in the "from" position.
+ *
+ * @return List<Criteria> covering property permutations defined with either notation or explicit direction
+ */
+ private List<Criteria> getOppositeDirectionContainmentCriteria() {
+ List<Criteria> crits = new ArrayList<>();
+
+ crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.OPPOSITE.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.IN.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.OUT.toString()));
+
+ return crits;
+ }
+
+ // -----rule packaging helpers-----//
+ /**
+ * Converts the raw output from reading the json file to the Multimap<String key, EdgeRule> format
+ *
+ * @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
+ * was empty.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * 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> convertToEdgeRules(List<Map<String, String>> allFound) {
+ Multimap<String, EdgeRule> rules = ArrayListMultimap.create();
+
+ TypeAlphabetizer alpher = new TypeAlphabetizer();
+
+ 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 f8f8caca..d3c9a599 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
@@ -17,211 +17,215 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.edges;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.onap.aai.edges.enums.*;
+package org.onap.aai.edges;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.onap.aai.edges.enums.*;
+
/**
* Container for A&AI edge rule information
*/
public class EdgeRule {
- private String from;
- private String to;
- private String label;
- private Direction direction;
- private MultiplicityRule multiplicityRule;
- private Map<EdgeProperty, AAIDirection> edgeFields;
- private boolean isDefaultEdge;
- private String description;
- private boolean isPrivateEdge = false;
-
- /**
- * Instantiates a new edge rule.
- *
- * @param fieldVals - Map<String, String> where first string is
- * an EdgeField value and second string is the
- * value of that field
- */
- public EdgeRule(Map<String, String> fieldVals) {
- edgeFields = new EnumMap<>(EdgeProperty.class);
-
- from = fieldVals.get(EdgeField.FROM.toString());
- to = fieldVals.get(EdgeField.TO.toString());
- 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"));
+ private String from;
+ private String to;
+ private String label;
+ private Direction direction;
+ private MultiplicityRule multiplicityRule;
+ private Map<EdgeProperty, AAIDirection> edgeFields;
+ private boolean isDefaultEdge;
+ private String description;
+ private boolean isPrivateEdge = false;
+
+ /**
+ * Instantiates a new edge rule.
+ *
+ * @param fieldVals - Map<String, String> where first string is
+ * an EdgeField value and second string is the
+ * value of that field
+ */
+ public EdgeRule(Map<String, String> fieldVals) {
+ edgeFields = new EnumMap<>(EdgeProperty.class);
+
+ from = fieldVals.get(EdgeField.FROM.toString());
+ to = fieldVals.get(EdgeField.TO.toString());
+ 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));
- }
-
- isDefaultEdge = Boolean.valueOf(fieldVals.get(EdgeField.DEFAULT.toString()));
+ String rawVal = fieldVals.get(prop.toString());
+ edgeFields.put(prop, convertNotation(direction, rawVal));
+ }
+
+ isDefaultEdge = Boolean.valueOf(fieldVals.get(EdgeField.DEFAULT.toString()));
description = fieldVals.get(EdgeField.DESCRIPTION.toString());
- if (description == null) { //bc description is optional and not in v12 and earlier
- description = "";
- }
- }
+ if (description == null) { // bc description is optional and not in v12 and earlier
+ description = "";
+ }
+ }
// Copy Constructor
- public EdgeRule(EdgeRule edgeRule){
+ public EdgeRule(EdgeRule edgeRule) {
this.from = edgeRule.from;
- this.to = edgeRule.to;
+ this.to = edgeRule.to;
this.label = edgeRule.label;
this.direction = Direction.valueOf(edgeRule.direction.toString());
this.multiplicityRule = MultiplicityRule.valueOf(edgeRule.multiplicityRule.toString());
this.edgeFields = new HashMap<>(edgeRule.edgeFields);
- this.isDefaultEdge = edgeRule.isDefaultEdge;
+ this.isDefaultEdge = edgeRule.isDefaultEdge;
this.description = edgeRule.description;
this.isPrivateEdge = edgeRule.isPrivateEdge;
}
- /**
- * Converts whatever string was in the json for an edge property value into
- * the appropriate AAIDirection
- *
- * @param Direction dir - the edge direction
- * @param String rawVal - property value from the json, may be
- * IN, OUT, BOTH, NONE, ${direction}, or !${direction}
- * @return AAIDirection - IN/OUT/BOTH/NONE if that's the rawVal, or
- * translates the direction notation into the correct IN/OUT
- */
- private AAIDirection convertNotation(Direction dir, String rawVal) {
- if (AAIDirection.NONE.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.NONE;
- } else if (AAIDirection.BOTH.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.BOTH;
- } else if (AAIDirection.OUT.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.OUT;
- } else if (AAIDirection.IN.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.IN;
- }
-
- DirectionNotation rawDN = DirectionNotation.getValue(rawVal);
- if (DirectionNotation.DIRECTION.equals(rawDN)) {
- return AAIDirection.getValue(dir);
- } else {
- return AAIDirection.getValue(dir.opposite());
- }
- }
-
- /**
- * Gets the name of the node type in the "from" field
- * @return String nodetype
- */
- public String getFrom() {
- return from;
- }
-
- /**
- * Gets the name of the node type in the "to" field
- * @return String nodetype
- */
- public String getTo() {
- return to;
- }
-
- /**
- * Gets the edge label
- *
- * @return String label
- */
- public String getLabel() {
- return label;
- }
-
- /**
- * Gets the multiplicity rule.
- *
- * @return MultiplicityRule
- */
- public MultiplicityRule getMultiplicityRule() {
- return multiplicityRule;
- }
-
- /**
- * Gets the edge direction
- *
- * @return Direction
- */
- public Direction getDirection() {
- return direction;
- }
-
- /**
- * Gets the value of contains-other-v
- *
- * @return the value of contains-other-v
- */
- public String getContains() {
- return edgeFields.get(EdgeProperty.CONTAINS).toString();
- }
-
- /**
- * Gets the value of delete-other-v
- *
- * @return the value of delete-other-v
- */
- public String getDeleteOtherV() {
- return edgeFields.get(EdgeProperty.DELETE_OTHER_V).toString();
- }
-
- /**
- * Gets the value of the prevent-delete property
- *
- * @return String prevent-delete property value
- */
- public String getPreventDelete() {
- return edgeFields.get(EdgeProperty.PREVENT_DELETE).toString();
- }
-
- /**
- * Returns if this rule is a default or not
- *
- * @return boolean
- */
- public boolean isDefault() {
- return isDefaultEdge;
- }
-
- /**
- * Gets the description on the edge rule (if there is one)
- * @return String description
- */
- 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);
- }
+ /**
+ * Converts whatever string was in the json for an edge property value into
+ * the appropriate AAIDirection
+ *
+ * @param Direction dir - the edge direction
+ * @param String rawVal - property value from the json, may be
+ * IN, OUT, BOTH, NONE, ${direction}, or !${direction}
+ * @return AAIDirection - IN/OUT/BOTH/NONE if that's the rawVal, or
+ * translates the direction notation into the correct IN/OUT
+ */
+ private AAIDirection convertNotation(Direction dir, String rawVal) {
+ if (AAIDirection.NONE.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.NONE;
+ } else if (AAIDirection.BOTH.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.BOTH;
+ } else if (AAIDirection.OUT.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.OUT;
+ } else if (AAIDirection.IN.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.IN;
+ }
+
+ DirectionNotation rawDN = DirectionNotation.getValue(rawVal);
+ if (DirectionNotation.DIRECTION.equals(rawDN)) {
+ return AAIDirection.getValue(dir);
+ } else {
+ return AAIDirection.getValue(dir.opposite());
+ }
+ }
+
+ /**
+ * Gets the name of the node type in the "from" field
+ *
+ * @return String nodetype
+ */
+ public String getFrom() {
+ return from;
+ }
+
+ /**
+ * Gets the name of the node type in the "to" field
+ *
+ * @return String nodetype
+ */
+ public String getTo() {
+ return to;
+ }
+
+ /**
+ * Gets the edge label
+ *
+ * @return String label
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * Gets the multiplicity rule.
+ *
+ * @return MultiplicityRule
+ */
+ public MultiplicityRule getMultiplicityRule() {
+ return multiplicityRule;
+ }
+
+ /**
+ * Gets the edge direction
+ *
+ * @return Direction
+ */
+ public Direction getDirection() {
+ return direction;
+ }
+
+ /**
+ * Gets the value of contains-other-v
+ *
+ * @return the value of contains-other-v
+ */
+ public String getContains() {
+ return edgeFields.get(EdgeProperty.CONTAINS).toString();
+ }
+
+ /**
+ * Gets the value of delete-other-v
+ *
+ * @return the value of delete-other-v
+ */
+ public String getDeleteOtherV() {
+ return edgeFields.get(EdgeProperty.DELETE_OTHER_V).toString();
+ }
+
+ /**
+ * Gets the value of the prevent-delete property
+ *
+ * @return String prevent-delete property value
+ */
+ public String getPreventDelete() {
+ return edgeFields.get(EdgeProperty.PREVENT_DELETE).toString();
+ }
+
+ /**
+ * Returns if this rule is a default or not
+ *
+ * @return boolean
+ */
+ public boolean isDefault() {
+ return isDefaultEdge;
+ }
+
+ /**
+ * Gets the description on the edge rule (if there is one)
+ *
+ * @return String description
+ */
+ 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 c25fc789..fc58dbb6 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
@@ -22,24 +22,23 @@
package org.onap.aai.edges;
-import org.apache.commons.lang.StringUtils;
-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.SchemaVersion;
+import static com.jayway.jsonpath.Criteria.where;
+import static com.jayway.jsonpath.Filter.filter;
import com.jayway.jsonpath.Filter;
import com.jayway.jsonpath.Predicate;
-import static com.jayway.jsonpath.Filter.filter;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import static com.jayway.jsonpath.Criteria.where;
+import org.apache.commons.lang.StringUtils;
+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.SchemaVersion;
/**
* For querying the edge rules schema (not the database)
@@ -60,10 +59,10 @@ 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
+ // optional - null will translate to any value of the param
private String nodeB = null;
private String label = null;
private EdgeType type = null;
@@ -83,6 +82,7 @@ public class EdgeRuleQuery {
private String getFirstNodeType() {
return nodeA;
}
+
public Builder fromOnly() {
this.nodeB = FROM_ONLY;
return this;
@@ -92,15 +92,15 @@ public class EdgeRuleQuery {
return nodeB;
}
- public Builder to(String nodeB){
+ public Builder to(String nodeB) {
this.nodeB = nodeB;
return this;
}
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;
+ // 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 = TO_ONLY;
return this;
@@ -124,7 +124,6 @@ public class EdgeRuleQuery {
return type;
}
-
public Builder direction(AAIDirection direction) {
this.direction = direction;
return this;
@@ -139,12 +138,12 @@ public class EdgeRuleQuery {
return this;
}
- public Builder setPrivate(boolean isPrivate){
+ public Builder setPrivate(boolean isPrivate) {
this.isPrivate = isPrivate;
return this;
}
- public boolean isPrivate(){
+ public boolean isPrivate() {
return isPrivate;
}
@@ -166,18 +165,18 @@ public class EdgeRuleQuery {
this.direction = builder.getDirection();
this.isPrivate = builder.isPrivate();
- //will cover from A to B case
+ // will cover from A to B case
List<Predicate> criteriaFromTo = new ArrayList<>();
- //Special logic to allow for A to B case only
- if(("FromOnly").equals(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
+ // will cover from B to A case - must be separate bc jsonpath won't let me OR predicates >:C
List<Predicate> criteriaToFrom = new ArrayList<>();
- //Special logic to allow for B to A case only
- if(("ToOnly").equals(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()));
@@ -195,7 +194,7 @@ public class EdgeRuleQuery {
}
Predicate privatePredicate = where("private").is(String.valueOf(isPrivate));
- if(isPrivate){
+ if (isPrivate) {
criteriaFromTo.add(privatePredicate);
criteriaToFrom.add(privatePredicate);
}
@@ -205,9 +204,9 @@ public class EdgeRuleQuery {
criteriaFromTo.add(directionPred);
criteriaToFrom.add(directionPred);
}
- if(("ToOnly").equals(builder.getFirstNodeType())) {
+ if (("ToOnly").equals(builder.getFirstNodeType())) {
this.filter = filter(criteriaToFrom);
- } else if(("FromOnly").equals(builder.getSecondNodeType())) {
+ } else if (("FromOnly").equals(builder.getSecondNodeType())) {
this.filter = filter(criteriaFromTo);
} else {
this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
@@ -215,7 +214,7 @@ public class EdgeRuleQuery {
}
private Predicate buildToFromPart(String from, String to) {
- if (from == null && to == null) { //shouldn't ever happen though
+ if (from == null && to == null) { // shouldn't ever happen though
throw new IllegalStateException("must have at least one node defined");
}
@@ -239,7 +238,7 @@ public class EdgeRuleQuery {
private Predicate addType(EdgeType type) {
if (type == EdgeType.COUSIN) {
return where(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString());
- } else { //equals TREE
+ } else { // equals TREE
return where(EdgeProperty.CONTAINS.toString()).ne(AAIDirection.NONE.toString());
}
}
@@ -259,6 +258,7 @@ public class EdgeRuleQuery {
/**
* Provides the JsonPath filter for actually querying the edge rule schema files
+ *
* @return Filter
*/
public Filter getFilter() {
@@ -284,6 +284,7 @@ public class EdgeRuleQuery {
/**
* So the Ingestor knows which version of the rules to search
+ *
* @return the Version
*/
public Optional<SchemaVersion> getVersion() {
@@ -314,7 +315,7 @@ public class EdgeRuleQuery {
sb.append(", isPrivate: ");
sb.append(isPrivate);
- if(v.isPresent()){
+ if (v.isPresent()) {
sb.append(", for version: ").append(v.get().toString()).append(".");
}
return sb.toString();
@@ -322,21 +323,19 @@ public class EdgeRuleQuery {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
EdgeRuleQuery ruleQuery = (EdgeRuleQuery) o;
- return isPrivate == ruleQuery.isPrivate &&
- Objects.equals(v, ruleQuery.v) &&
- Objects.equals(nodeA, ruleQuery.nodeA) &&
- Objects.equals(nodeB, ruleQuery.nodeB) &&
- Objects.equals(label, ruleQuery.label) &&
- direction == ruleQuery.direction &&
- type == ruleQuery.type;
+ return isPrivate == ruleQuery.isPrivate && Objects.equals(v, ruleQuery.v)
+ && Objects.equals(nodeA, ruleQuery.nodeA) && Objects.equals(nodeB, ruleQuery.nodeB)
+ && Objects.equals(label, ruleQuery.label) && direction == ruleQuery.direction && type == ruleQuery.type;
}
@Override
public int hashCode() {
- if(v.isPresent()){
+ if (v.isPresent()) {
return Objects.hash(v.get(), nodeA, nodeB, label, direction, type, isPrivate);
} else {
return Objects.hash(nodeA, nodeB, label, direction, type, isPrivate);
@@ -344,4 +343,3 @@ public class EdgeRuleQuery {
}
}
-
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 713103a0..b686b3a6 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
@@ -24,7 +24,6 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
-import org.onap.aai.setup.SchemaVersion;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -35,17 +34,19 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import org.onap.aai.setup.SchemaVersion;
+
/**
* JsonIngestor produces DocumentContexts from json files
*/
public class JsonIngestor {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(JsonIngestor.class);
-
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(JsonIngestor.class);
+
/**
* Reads in given json files to queryable DocumentContexts.
*
* @param filesToIngest - map of filenames to ingest
- * per Version
+ * per Version
* @return Map<SchemaVersion, List<DocumentContext>> - map of DocumentContexts per Version
*/
public Map<SchemaVersion, List<DocumentContext>> ingest(Map<SchemaVersion, List<String>> filesToIngest) {
@@ -90,13 +91,13 @@ public class JsonIngestor {
*/
public String readInJsonFile(String rulesFilename) {
StringBuilder sb = new StringBuilder();
- try(BufferedReader br = new BufferedReader(new FileReader(rulesFilename))) {
+ try (BufferedReader br = new BufferedReader(new FileReader(rulesFilename))) {
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
- LOGGER.warn("Exception in file"+e.getMessage());
+ LOGGER.warn("Exception in file" + e.getMessage());
throw new ExceptionInInitializerError(e);
}
return sb.toString();
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java
index 792e3c51..4d2c8455 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java
@@ -17,21 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges;
import com.jayway.jsonpath.Filter;
-import org.onap.aai.setup.SchemaVersion;
import java.util.Objects;
+import org.onap.aai.setup.SchemaVersion;
+
public class SchemaFilter {
private String filter;
private SchemaVersion schemaVersion;
- public SchemaFilter(Filter filter, SchemaVersion schemaVersion){
- if(filter != null){
+ public SchemaFilter(Filter filter, SchemaVersion schemaVersion) {
+ if (filter != null) {
this.filter = filter.toString();
}
this.schemaVersion = schemaVersion;
@@ -47,11 +49,12 @@ public class SchemaFilter {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
SchemaFilter that = (SchemaFilter) o;
- return Objects.equals(filter, that.filter) &&
- Objects.equals(schemaVersion, that.schemaVersion);
+ return Objects.equals(filter, that.filter) && Objects.equals(schemaVersion, that.schemaVersion);
}
@Override
@@ -61,9 +64,6 @@ public class SchemaFilter {
@Override
public String toString() {
- return "SchemaFilter{" +
- "filter='" + filter + '\'' +
- ", schemaVersion=" + schemaVersion +
- '}';
+ return "SchemaFilter{" + "filter='" + filter + '\'' + ", schemaVersion=" + schemaVersion + '}';
}
}
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 fd1f5113..4cae19ea 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
@@ -24,42 +24,42 @@ package org.onap.aai.edges;
* Helper class to produce alphabetized keys for EdgeIngestor and EdgeValidator
*/
public class TypeAlphabetizer {
- /**
- * Builds key for edge rules, where nodetypes are alphabetically sorted
- * (ignoring dashes).
- *
- * @param nodeA - first nodetype
- * @param nodeB - second nodetype
- * @return {alphabetically first nodetype}|{alphabetically second nodetype}
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * 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 String buildAlphabetizedKey(String nodeA, String nodeB) {
- if (nodeA == null) {
- nodeA = "";
- }
- if (nodeB == null) {
- nodeB = "";
- }
-
- //normalize
- String normalizedNodeA = nodeA.replace("-", "");
- String normalizedNodeB = nodeB.replace("-", "");
- int cmp = normalizedNodeA.compareTo(normalizedNodeB);
-
- StringBuilder sb = new StringBuilder();
- if (cmp <= 0) {
- sb.append(nodeA);
- sb.append("|");
- sb.append(nodeB);
- } else {
- sb.append(nodeB);
- sb.append("|");
- sb.append(nodeA);
- }
- return sb.toString();
- }
+ /**
+ * Builds key for edge rules, where nodetypes are alphabetically sorted
+ * (ignoring dashes).
+ *
+ * @param nodeA - first nodetype
+ * @param nodeB - second nodetype
+ * @return {alphabetically first nodetype}|{alphabetically second nodetype}
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * 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 String buildAlphabetizedKey(String nodeA, String nodeB) {
+ if (nodeA == null) {
+ nodeA = "";
+ }
+ if (nodeB == null) {
+ nodeB = "";
+ }
+
+ // normalize
+ String normalizedNodeA = nodeA.replace("-", "");
+ String normalizedNodeB = nodeB.replace("-", "");
+ int cmp = normalizedNodeA.compareTo(normalizedNodeB);
+
+ StringBuilder sb = new StringBuilder();
+ if (cmp <= 0) {
+ sb.append(nodeA);
+ sb.append("|");
+ sb.append(nodeB);
+ } else {
+ sb.append(nodeB);
+ sb.append("|");
+ sb.append(nodeA);
+ }
+ return sb.toString();
+ }
}
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 aeb5d77d..04c97fc4 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
@@ -17,44 +17,45 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges.enums;
import org.apache.tinkerpop.gremlin.structure.Direction;
public enum AAIDirection {
- IN, OUT, BOTH, NONE;
+ IN, OUT, BOTH, NONE;
+
+ public AAIDirection opposite() {
+ if (this.equals(OUT)) {
+ return IN;
+ } else if (this.equals(IN)) {
+ return OUT;
+ } else {
+ return BOTH;
+ }
+ }
+
+ public static AAIDirection getValue(String aaidir) {
+ if (OUT.toString().equals(aaidir)) {
+ return OUT;
+ } else if (IN.toString().equals(aaidir)) {
+ return IN;
+ } else if (NONE.toString().equals(aaidir)) {
+ return NONE;
+ } else { // should be BOTH
+ return BOTH;
+ }
+ }
- public AAIDirection opposite() {
- if (this.equals(OUT)) {
- return IN;
- } else if (this.equals(IN)) {
- return OUT;
- } else {
- return BOTH;
- }
- }
-
- public static AAIDirection getValue(String aaidir) {
- if (OUT.toString().equals(aaidir)) {
- return OUT;
- } else if (IN.toString().equals(aaidir)) {
- return IN;
- } else if (NONE.toString().equals(aaidir)) {
- return NONE;
- } else { //should be BOTH
- return BOTH;
- }
- }
-
- public static AAIDirection getValue(Direction dir) {
- if (dir == Direction.OUT) {
- return OUT;
- } else if (dir == Direction.IN) {
- return IN;
- } else if (dir == Direction.BOTH) {
- return BOTH;
- } else {
- return NONE;
- }
- }
+ public static AAIDirection getValue(Direction dir) {
+ if (dir == Direction.OUT) {
+ return OUT;
+ } else if (dir == Direction.IN) {
+ return IN;
+ } else if (dir == Direction.BOTH) {
+ return BOTH;
+ } else {
+ return NONE;
+ }
+ }
}
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 5a69603b..49a094b9 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
@@ -20,28 +20,27 @@
package org.onap.aai.edges.enums;
-public enum DirectionNotation {
- DIRECTION("${direction}"),
- OPPOSITE("!${direction}");
+public enum DirectionNotation {
+ DIRECTION("${direction}"), OPPOSITE("!${direction}");
- private final String val;
-
- DirectionNotation(String dir) {
- this.val = dir;
- }
-
- public static DirectionNotation getValue(String val) {
- if (DIRECTION.toString().equals(val)) {
- return DIRECTION;
- } else if (OPPOSITE.toString().equals(val)) {
- return OPPOSITE;
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- @Override
- public String toString() {
- return this.val;
- }
-} \ No newline at end of file
+ private final String val;
+
+ DirectionNotation(String dir) {
+ this.val = dir;
+ }
+
+ public static DirectionNotation getValue(String val) {
+ if (DIRECTION.toString().equals(val)) {
+ return DIRECTION;
+ } else if (OPPOSITE.toString().equals(val)) {
+ return OPPOSITE;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.val;
+ }
+}
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 ff6bc82d..35ea1131 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
@@ -25,25 +25,17 @@ package org.onap.aai.edges.enums;
*
*/
public enum EdgeField {
- FROM("from"),
- TO("to"),
- LABEL("label"),
- DIRECTION("direction"),
- MULTIPLICITY("multiplicity"),
- CONTAINS("contains-other-v"),
- DELETE_OTHER_V("delete-other-v"),
- PREVENT_DELETE("prevent-delete"),
- DEFAULT("default"),
- PRIVATE("private"),
- DESCRIPTION("description");
- private final String name;
+ FROM("from"), TO("to"), LABEL("label"), DIRECTION("direction"), MULTIPLICITY("multiplicity"), CONTAINS(
+ "contains-other-v"), DELETE_OTHER_V("delete-other-v"), PREVENT_DELETE(
+ "prevent-delete"), DEFAULT("default"), PRIVATE("private"), DESCRIPTION("description");
+ private final String name;
- private EdgeField(String name) {
- this.name = name;
- }
+ private EdgeField(String name) {
+ this.name = name;
+ }
- @Override
- public String toString() {
- return name;
- }
+ @Override
+ public String toString() {
+ return 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 18e82f5e..c4e945b0 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
@@ -25,17 +25,15 @@ package org.onap.aai.edges.enums;
* (ie which have a directional value)
*/
public enum EdgeProperty {
- CONTAINS("contains-other-v"),
- DELETE_OTHER_V("delete-other-v"),
- PREVENT_DELETE("prevent-delete");
- private final String name;
+ CONTAINS("contains-other-v"), DELETE_OTHER_V("delete-other-v"), PREVENT_DELETE("prevent-delete");
+ private final String name;
- private EdgeProperty(String name) {
- this.name = name;
- }
+ private EdgeProperty(String name) {
+ this.name = name;
+ }
- @Override
- public String toString() {
- return name;
- }
+ @Override
+ public String toString() {
+ return name;
+ }
}
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 4662f862..0725c92b 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
@@ -17,10 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges.enums;
public enum EdgeType {
- COUSIN,
- TREE,
- ALL;
+ COUSIN, TREE, ALL;
}
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 a29b4a61..ed00f152 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
@@ -17,23 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges.enums;
public enum MultiplicityRule {
- MANY2ONE,
- ONE2MANY,
- ONE2ONE,
- MANY2MANY;
-
- public static MultiplicityRule getValue(String multiplicity) {
- if ("Many2Many".equalsIgnoreCase(multiplicity)) {
- return MANY2MANY;
- } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
- return ONE2MANY;
- } else if ("One2One".equalsIgnoreCase(multiplicity)) {
- return ONE2ONE;
- } else { //should be "Many2One"
- return MANY2ONE;
- }
- }
+ MANY2ONE, ONE2MANY, ONE2ONE, MANY2MANY;
+
+ public static MultiplicityRule getValue(String multiplicity) {
+ if ("Many2Many".equalsIgnoreCase(multiplicity)) {
+ return MANY2MANY;
+ } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
+ return ONE2MANY;
+ } else if ("One2One".equalsIgnoreCase(multiplicity)) {
+ return ONE2ONE;
+ } else { // should be "Many2One"
+ return MANY2ONE;
+ }
+ }
}
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 da79d9c7..0f226733 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
@@ -21,11 +21,11 @@
package org.onap.aai.edges.exceptions;
public class AmbiguousRuleChoiceException extends Exception {
- public AmbiguousRuleChoiceException(String msg) {
- super(msg);
- }
+ public AmbiguousRuleChoiceException(String msg) {
+ super(msg);
+ }
- public AmbiguousRuleChoiceException(Throwable throwable){
+ public AmbiguousRuleChoiceException(Throwable throwable) {
super(throwable);
}
}
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
index 96fd65cc..cbd7aac9 100644
--- 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
@@ -25,7 +25,7 @@ public class EdgeIngestorException extends Exception {
super(msg);
}
- public EdgeIngestorException(Throwable throwable){
+ public EdgeIngestorException(Throwable throwable) {
super(throwable);
}
}
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 f9b9b643..f3ab00e7 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
@@ -21,11 +21,11 @@
package org.onap.aai.edges.exceptions;
public class EdgeRuleNotFoundException extends Exception {
- public EdgeRuleNotFoundException(String msg) {
- super(msg);
- }
+ public EdgeRuleNotFoundException(String msg) {
+ super(msg);
+ }
- public EdgeRuleNotFoundException(Throwable throwable){
+ public EdgeRuleNotFoundException(Throwable throwable) {
super(throwable);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java
index 69a153da..03036cad 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java
@@ -17,16 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.nodes;
import com.google.common.base.CaseFormat;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
/**
* CaseFormatStore stores the converted strings from
* lower hyphen (example-object) to lower camel case (exampleObject)
@@ -40,15 +42,16 @@ public class CaseFormatStore {
private final Map<String, String> lowerCamelToLowerHyphen = new HashMap<>();
private final Map<String, String> upperCamelToLowerHyphen = new HashMap<>();
- CaseFormatStore(){}
+ CaseFormatStore() {
+ }
/**
* Parses the document and creates a lower camel case string
* upper camel string, lower hyphen and lower camel case
*
- * @param doc Takes an xml document and adds it to the hash maps as appropriate
+ * @param doc Takes an xml document and adds it to the hash maps as appropriate
*/
- void parse(Document doc){
+ void parse(Document doc) {
// Get the xml-root-element and add those nodes
// with the attribute name and it to the hashmaps
@@ -86,19 +89,19 @@ public class CaseFormatStore {
}
}
- public Optional<String> fromLowerHyphenToLowerCamel(String value){
+ public Optional<String> fromLowerHyphenToLowerCamel(String value) {
return Optional.ofNullable(lowerHyphenToLowerCamel.get(value));
}
- public Optional<String> fromLowerHyphenToUpperCamel(String value){
+ public Optional<String> fromLowerHyphenToUpperCamel(String value) {
return Optional.ofNullable(lowerHyphenToUpperCamel.get(value));
}
- public Optional<String> fromUpperCamelToLowerHyphen(String value){
+ public Optional<String> fromUpperCamelToLowerHyphen(String value) {
return Optional.ofNullable(upperCamelToLowerHyphen.get(value));
}
- public Optional<String> fromLowerCamelToLowerHyphen(String value){
+ public Optional<String> fromLowerCamelToLowerHyphen(String value) {
return Optional.ofNullable(lowerCamelToLowerHyphen.get(value));
}
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 2428a6dd..6016fcca 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
@@ -25,6 +25,20 @@ package org.onap.aai.nodes;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.common.base.CaseFormat;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.PostConstruct;
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+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;
@@ -40,24 +54,12 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import javax.annotation.PostConstruct;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
@Component
/*
- NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version
+ * NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version
*/
-@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
-@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class NodeIngestor {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(NodeIngestor.class);
@@ -70,14 +72,15 @@ public class NodeIngestor {
private Set<Translator> translators;
private CaseFormatStore caseFormatStore;
- //TODO : See if you can get rid of InputStream resets
+ // TODO : See if you can get rid of InputStream resets
/**
* Instantiates the NodeIngestor bean.
+ *
* @param translatorSet
*/
- @Autowired
+ @Autowired
public NodeIngestor(Set<Translator> translatorSet) {
this.translators = translatorSet;
this.caseFormatStore = new CaseFormatStore();
@@ -106,7 +109,7 @@ public class NodeIngestor {
this.localSchema = "true";
}
- Boolean retrieveLocalSchema = Boolean.parseBoolean(this.localSchema);
+ Boolean retrieveLocalSchema = Boolean.parseBoolean(this.localSchema);
/*
* Set this to default schemaVersion
*/
@@ -119,8 +122,8 @@ public class NodeIngestor {
List<InputStream> inputStreams = retrieveOXM(version, translator);
LOGGER.debug("Retrieved OXMs from SchemaService");
/*
- IOUtils.copy and copy the inputstream
- */
+ * IOUtils.copy and copy the inputstream
+ */
if (inputStreams.isEmpty()) {
continue;
}
@@ -151,14 +154,15 @@ public class NodeIngestor {
return DynamicJAXBContextFactory.createContextFromOXM(this.getClass().getClassLoader(), properties);
}
- private void setAllTypesAndProperties(SchemaVersion version, List<InputStream> inputStreams) throws ParserConfigurationException, IOException, SAXException {
+ private void setAllTypesAndProperties(SchemaVersion version, List<InputStream> inputStreams)
+ throws ParserConfigurationException, IOException, SAXException {
Set<String> types = new HashSet<>();
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
for (InputStream inputStream : inputStreams) {
- //TODO Change this
+ // TODO Change this
inputStream.reset();
final Document doc = docBuilder.parse(inputStream);
final NodeList list = doc.getElementsByTagName("java-type");
@@ -170,7 +174,7 @@ public class NodeIngestor {
typesPerVersion.put(version, types);
}
- private void getAllNodeTypes(NodeList list, Set<String> types){
+ private void getAllNodeTypes(NodeList list, Set<String> types) {
for (int i = 0; i < list.getLength(); i++) {
String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
@@ -178,7 +182,8 @@ public class NodeIngestor {
}
}
- private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version, boolean localSchema) throws ParserConfigurationException, SAXException, IOException {
+ private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version, boolean localSchema)
+ throws ParserConfigurationException, SAXException, IOException {
if (localSchema) {
return createCombinedSchema(inputStreams, version);
}
@@ -191,7 +196,8 @@ public class NodeIngestor {
return masterDocBuilder.parse(inputStream);
}
- private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version) throws ParserConfigurationException, SAXException, IOException {
+ private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version)
+ throws ParserConfigurationException, SAXException, IOException {
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
@@ -247,7 +253,6 @@ public class NodeIngestor {
return schemaPerVersion.get(v);
}
-
public SchemaVersion getVersionFromClassName(String classname) {
Matcher m = classNamePattern.matcher(classname);
if (m.find()) {
@@ -259,26 +264,24 @@ public class NodeIngestor {
}
private List<InputStream> retrieveOXM(SchemaVersion version, Translator translator) throws IOException {
- /*
- Call Schema MS to get versions using RestTemplate or Local
- */
+ /*
+ * Call Schema MS to get versions using RestTemplate or Local
+ */
return translator.getVersionNodeStream(version);
}
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>";
+ 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>";
return new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8));
}
- public CaseFormatStore getCaseFormatStore(){
+ public CaseFormatStore getCaseFormatStore() {
return caseFormatStore;
}
}
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
index adaf538e..ef1e0d24 100644
--- 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
@@ -25,7 +25,7 @@ public class NodeIngestorException extends Exception {
super(msg);
}
- public NodeIngestorException(Throwable throwable){
+ public NodeIngestorException(Throwable throwable) {
super(throwable);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
index 83687a76..cc88edef 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
@@ -17,55 +17,59 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import javax.annotation.PostConstruct;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
+@Component(value = "no-auth-service-rest-client")
+public class SchemaServiceNoAuthClient extends NoAuthRestClient {
-@Component(value="no-auth-service-rest-client")
-public class SchemaServiceNoAuthClient extends NoAuthRestClient{
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceNoAuthClient.class);
- private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceNoAuthClient.class);
-
- @Value("${schema.service.base.url}")
- private String baseUrl;
+ @Value("${schema.service.base.url}")
+ private String baseUrl;
@PostConstruct
- public void init () throws Exception {
+ public void init() throws Exception {
super.init();
}
- @Override
- public String getBaseUrl() {
- return baseUrl;
- }
+ @Override
+ public String getBaseUrl() {
+ return baseUrl;
+ }
@Override
- public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
- HttpHeaders httpHeaders = new HttpHeaders();
+ public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
+ HttpHeaders httpHeaders = new HttpHeaders();
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- String defaultContentType = headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ String defaultContentType =
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
- if(headers.isEmpty()){
+ if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
httpHeaders.setContentType(MediaType.parseMediaType(defaultContentType));
}
- httpHeaders.add("X-FromAppId", appName);
- httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
+ httpHeaders.add("X-FromAppId", appName);
+ httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
headers.forEach(httpHeaders::add);
- return httpHeaders;
- }
+ return httpHeaders;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
index a3e4de54..6b107285 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
@@ -17,25 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import javax.annotation.PostConstruct;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
-@Component(value="schema-service-one-way-rest-client")
-public class SchemaServiceOneWayClient extends OneWaySSLRestClient{
+@Component(value = "schema-service-one-way-rest-client")
+public class SchemaServiceOneWayClient extends OneWaySSLRestClient {
- private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceOneWayClient.class);
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceOneWayClient.class);
@Value("${schema.service.base.url}")
private String baseUrl;
@@ -62,22 +65,23 @@ public class SchemaServiceOneWayClient extends OneWaySSLRestClient{
}
@Override
- public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
- HttpHeaders httpHeaders = new HttpHeaders();
+ public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
+ HttpHeaders httpHeaders = new HttpHeaders();
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- String defaultContentType = headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ String defaultContentType =
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
- if(headers.isEmpty()){
+ if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
httpHeaders.setContentType(MediaType.parseMediaType(defaultContentType));
}
- httpHeaders.add("X-FromAppId", appName);
- httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
+ httpHeaders.add("X-FromAppId", appName);
+ httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
httpHeaders.add("X-TransactionId", appName);
- headers.forEach(httpHeaders::add);
- return httpHeaders;
- }
+ headers.forEach(httpHeaders::add);
+ return httpHeaders;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
index 300c5d83..56ddd744 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
@@ -19,20 +19,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
@Component(value = "schema-service-rest-client")
public class SchemaServiceRestClient extends TwoWaySSLRestClient {
private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceRestClient.class);
@@ -54,7 +56,7 @@ public class SchemaServiceRestClient extends TwoWaySSLRestClient {
@Override
public String getBaseUrl() {
- return baseUrl;
+ return baseUrl;
}
@Override
@@ -82,7 +84,8 @@ public class SchemaServiceRestClient extends TwoWaySSLRestClient {
HttpHeaders httpHeaders = new HttpHeaders();
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- String defaultContentType = headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ String defaultContentType =
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
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
index 4454ad27..8949891e 100644
--- 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
import java.io.File;
@@ -35,79 +36,67 @@ import java.util.stream.Stream;
*/
public class AAIConfigTranslator extends ConfigTranslator {
- private static final String FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+ private static final String FILESEP =
+ (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
public AAIConfigTranslator(SchemaLocationsBean bean, SchemaConfigVersions 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;
- }
+ 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 3ef76d75..1c49e1de 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
@@ -22,49 +22,50 @@ package org.onap.aai.setup;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.apache.commons.io.IOUtils;
-import org.onap.aai.edges.JsonIngestor;
-import org.springframework.beans.factory.annotation.Autowired;
+
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.onap.aai.edges.JsonIngestor;
+import org.springframework.beans.factory.annotation.Autowired;
+
/**
* Converts the contents of the schema config file
* (which lists which schema files to be loaded) to
* the format the Ingestors can work with.
*
*/
-public abstract class ConfigTranslator extends Translator{
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ConfigTranslator.class);
-
- protected SchemaLocationsBean bean;
+public abstract class ConfigTranslator extends Translator {
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ConfigTranslator.class);
+
+ protected SchemaLocationsBean bean;
-
- @Autowired
+ @Autowired
public ConfigTranslator(SchemaLocationsBean schemaLocationbean, SchemaConfigVersions schemaVersions) {
- super(schemaVersions);
- this.bean = schemaLocationbean;
-
- }
-
- /**
- * Translates the contents of the schema config file
- * into the input for the NodeIngestor
- *
- * @return Map of Version to the list of (string) filenames to be
- * ingested for that version
- */
- public abstract Map<SchemaVersion, List<String>> getNodeFiles();
+ super(schemaVersions);
+ this.bean = schemaLocationbean;
+
+ }
+
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the NodeIngestor
+ *
+ * @return Map of Version to the list of (string) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<SchemaVersion, List<String>> getNodeFiles();
public List<InputStream> getVersionNodeStream(SchemaVersion version) {
Map<SchemaVersion, List<String>> filesToIngest = getNodeFiles();
List<InputStream> streams = new ArrayList<>();
- if(!filesToIngest.containsKey(version)) {
+ if (!filesToIngest.containsKey(version)) {
return streams;
}
List<String> versionFiles = filesToIngest.get(version);
@@ -73,13 +74,13 @@ public abstract class ConfigTranslator extends Translator{
try {
InputStream stream = new FileInputStream(new File(name));
String value = IOUtils.toString(stream, Charset.defaultCharset());
- InputStream bis =(IOUtils.toInputStream(value, Charset.defaultCharset()));
+ InputStream bis = (IOUtils.toInputStream(value, Charset.defaultCharset()));
streams.add(bis);
} catch (FileNotFoundException e) {
- //TODO This may have to be cascaded
- LOGGER.warn("File Not Found"+e.getMessage());
+ // TODO This may have to be cascaded
+ LOGGER.warn("File Not Found" + e.getMessage());
} catch (IOException e) {
- LOGGER.warn("IOException while reading files"+e.getMessage());
+ LOGGER.warn("IOException while reading files" + e.getMessage());
}
}
return streams;
@@ -89,7 +90,7 @@ public abstract class ConfigTranslator extends Translator{
public List<String> getJsonPayload(SchemaVersion version) {
Map<SchemaVersion, List<String>> filesToIngest = getEdgeFiles();
List<String> jsonPayloads = new ArrayList<>();
- if(!filesToIngest.containsKey(version)) {
+ if (!filesToIngest.containsKey(version)) {
return jsonPayloads;
}
List<String> versionFiles = filesToIngest.get(version);
@@ -101,14 +102,14 @@ public abstract class ConfigTranslator extends Translator{
return jsonPayloads;
}
-
- /**
- * Translates the contents of the schema config file
- * into the input for the EdgeIngestor
- *
- * @return Map of Version to the List of (String) filenames to be
- * ingested for that version
- */
- public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
+
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the EdgeIngestor
+ *
+ * @return Map of Version to the List of (String) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java
index e23fea26..2d9d557b 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java
@@ -17,17 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-import java.util.stream.Collectors;
-
@Component("schemaConfigVersions")
@ConditionalOnExpression("'${schema.translator.list:config}'.contains('config') || '${schema.service.versions.override:false}'.equals('true')")
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
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 9e740a8c..13591766 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
@@ -20,120 +20,120 @@
package org.onap.aai.setup;
+import java.util.List;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
-import java.util.List;
-
@Configuration
-@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
-@PropertySource(value = "file:${schema.ingest.file}", 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, 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
- * schema-ingest.properties in case that second one doesn't work.
- *
- * 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("${schema.configuration.location}")
- private String schemaConfigLoc;
-
- @Value("${schema.nodes.location}")
- private String nodeDirectory;
-
- @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
- */
- public String getSchemaConfigLocation() {
- return schemaConfigLoc;
- }
-
- /**
- * Sets the name/location of the file with the list of schema files to ingest
- *
- * @param schemaConfigLoc - the file name/location
- */
- public void setSchemaConfigLocation(String schemaConfigLoc) {
- this.schemaConfigLoc = schemaConfigLoc;
- }
-
- /**
- * @return the location of the OXM files
- */
- public String getNodeDirectory() {
- return nodeDirectory;
- }
-
- /**
- * Sets the location of the OXM files
- *
- * @param nodeDirectory - the location of the OXM files
- */
- public void setNodeDirectory(String nodeDirectory) {
- this.nodeDirectory = nodeDirectory;
- }
-
- /**
- * @return the location of the edge rule json files
- */
- public String getEdgeDirectory() {
- return edgeDirectory;
- }
-
- /**
- * Sets the location of the edge rule json 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
- public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
- return new PropertySourcesPlaceholderConfigurer();
- }
+ /*
+ * Per Spring documentation, the last PropertySource that works will
+ * 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
+ * schema-ingest.properties in case that second one doesn't work.
+ *
+ * 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("${schema.configuration.location}")
+ private String schemaConfigLoc;
+
+ @Value("${schema.nodes.location}")
+ private String nodeDirectory;
+
+ @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
+ */
+ public String getSchemaConfigLocation() {
+ return schemaConfigLoc;
+ }
+
+ /**
+ * Sets the name/location of the file with the list of schema files to ingest
+ *
+ * @param schemaConfigLoc - the file name/location
+ */
+ public void setSchemaConfigLocation(String schemaConfigLoc) {
+ this.schemaConfigLoc = schemaConfigLoc;
+ }
+
+ /**
+ * @return the location of the OXM files
+ */
+ public String getNodeDirectory() {
+ return nodeDirectory;
+ }
+
+ /**
+ * Sets the location of the OXM files
+ *
+ * @param nodeDirectory - the location of the OXM files
+ */
+ public void setNodeDirectory(String nodeDirectory) {
+ this.nodeDirectory = nodeDirectory;
+ }
+
+ /**
+ * @return the location of the edge rule json files
+ */
+ public String getEdgeDirectory() {
+ return edgeDirectory;
+ }
+
+ /**
+ * Sets the location of the edge rule json 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
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
index 2d2411fb..8c29f96d 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
@@ -17,10 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.io.*;
+import java.util.*;
+
+import javax.ws.rs.HttpMethod;
+
import org.onap.aai.restclient.RestClient;
import org.onap.aai.restclient.RestClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,10 +38,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
-import javax.ws.rs.HttpMethod;
-import java.io.*;
-import java.util.*;
-
/**
* <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
@@ -42,68 +45,66 @@ import java.util.*;
*/
public class SchemaServiceTranslator extends Translator {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaServiceTranslator.class);
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaServiceTranslator.class);
- private static final String SchemaServiceClientType = "schema.service";
+ private static final String SchemaServiceClientType = "schema.service";
- @Value("${schema.service.nodes.endpoint}")
- private String nodeSchemaUri;
+ @Value("${schema.service.nodes.endpoint}")
+ private String nodeSchemaUri;
- @Value("${schema.service.edges.endpoint}")
- private String edgeSchemaUri;
+ @Value("${schema.service.edges.endpoint}")
+ private String edgeSchemaUri;
- @Autowired
- private RestClientFactory restClientFactory;
+ @Autowired
+ private RestClientFactory restClientFactory;
- public SchemaServiceTranslator(SchemaVersions schemaVersions) {
- super(schemaVersions);
- }
+ public SchemaServiceTranslator(SchemaVersions schemaVersions) {
+ super(schemaVersions);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
+ */
- @Override
- public List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException {
+ @Override
+ public List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException {
- List<InputStream> inputStreams = new ArrayList<>();
- String content = "";
- String uri = nodeSchemaUri + version.toString();
- Map<String, String> headersMap = new HashMap<>();
+ List<InputStream> inputStreams = new ArrayList<>();
+ String content = "";
+ String uri = nodeSchemaUri + version.toString();
+ Map<String, String> headersMap = new HashMap<>();
- headersMap.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML.toString());
+ headersMap.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML.toString());
headersMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML.toString());
- RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
- ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri,
- headersMap);
+ RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
+ ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri, headersMap);
verifySchemaServiceResponse(schemaResponse.getStatusCode());
LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode());
- inputStreams.add(schemaResponse.getBody().getInputStream());
- return inputStreams;
- }
+ inputStreams.add(schemaResponse.getBody().getInputStream());
+ return inputStreams;
+ }
@Override
- public List<String> getJsonPayload(SchemaVersion version) throws IOException {
- /*
- * Call Schema MS to get versions using RestTemplate
- */
- List<String> inputStreams = new ArrayList<>();
- String content = "";
- String uri = edgeSchemaUri + version.toString();
- Map<String, String> headersMap = new HashMap<>();
-
- RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
-
- ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, uri,
- headersMap);
+ public List<String> getJsonPayload(SchemaVersion version) throws IOException {
+ /*
+ * Call Schema MS to get versions using RestTemplate
+ */
+ List<String> inputStreams = new ArrayList<>();
+ String content = "";
+ String uri = edgeSchemaUri + version.toString();
+ Map<String, String> headersMap = new HashMap<>();
+
+ RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
+
+ ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, uri, headersMap);
verifySchemaServiceResponse(schemaResponse.getStatusCode());
LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode());
- inputStreams.add(schemaResponse.getBody());
- return inputStreams;
+ inputStreams.add(schemaResponse.getBody());
+ return inputStreams;
- }
+ }
private void verifySchemaServiceResponse(HttpStatus statusCode) throws IOException {
if (statusCode != HttpStatus.OK) {
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java
index 5518ccb2..f39042d4 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java
@@ -17,14 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-import java.util.stream.Collectors;
@Component("schemaServiceVersions")
@ConditionalOnExpression("'${schema.translator.list}'.contains('schema-service')")
@@ -48,7 +51,7 @@ public class SchemaServiceVersions extends SchemaVersions {
}
@PostConstruct
- public void initializeFromSchemaService() throws ExceptionInInitializerError{
+ public void initializeFromSchemaService() throws ExceptionInInitializerError {
versionsValue = versions.stream().map(SchemaVersion::new).collect(Collectors.toList());
edgeLabelVersionValue = new SchemaVersion(edgeVersion);
@@ -64,7 +67,8 @@ public class SchemaServiceVersions extends SchemaVersions {
/*
* TODO Change Method names
*/
- public void initializeFromSchemaConfig(SchemaConfigVersions schemaConfigVersion) throws ExceptionInInitializerError{
+ public void initializeFromSchemaConfig(SchemaConfigVersions schemaConfigVersion)
+ throws ExceptionInInitializerError {
versions = schemaConfigVersion.getApiVersions();
appRootVersion = schemaConfigVersion.getAppRootStartVersion();
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
index 8143b5e1..6214a6f8 100644
--- 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
@@ -17,62 +17,64 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.setup;
-import org.onap.aai.validation.AAISchemaValidationException;
+package org.onap.aai.setup;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.onap.aai.validation.AAISchemaValidationException;
+
public class SchemaVersion implements Comparable<SchemaVersion> {
public static final Pattern VERSION_PATTERN = Pattern.compile("v([1-9][0-9]*)");
private final Integer value;
- public SchemaVersion(String value){
+ public SchemaVersion(String value) {
Matcher matcher = VERSION_PATTERN.matcher(value);
- if(!matcher.find()){
- throw new AAISchemaValidationException("Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
+ if (!matcher.find()) {
+ throw new AAISchemaValidationException(
+ "Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
} else {
this.value = Integer.parseInt(matcher.group(1));
}
}
@Override
- public int hashCode(){
+ public int hashCode() {
return value.hashCode();
}
@Override
- public boolean equals(Object other){
+ public boolean equals(Object other) {
- if(this == other){
+ if (this == other) {
return true;
}
- if(other == null){
+ if (other == null) {
return false;
}
- if(!(other instanceof SchemaVersion)){
+ if (!(other instanceof SchemaVersion)) {
return false;
}
- SchemaVersion obj = (SchemaVersion)other;
+ SchemaVersion obj = (SchemaVersion) other;
return this.value.equals(obj.value);
}
@Override
- public String toString(){
+ public String toString() {
return String.valueOf("v" + value);
}
@Override
public int compareTo(SchemaVersion o) {
- if(o == null){
+ if (o == null) {
return -1;
}
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
index e7f599c6..0094a161 100644
--- 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
@@ -17,18 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
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 java.util.List;
-import java.util.stream.Collectors;
-
-
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class SchemaVersions {
@@ -42,9 +43,9 @@ public class SchemaVersions {
protected SchemaVersion namespaceChangeVersionValue;
protected void validate() {
- String errorMessage = "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";
+ String errorMessage = "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 (!versionsValue.contains(edgeLabelVersionValue)) {
throw new AAISchemaValidationException(errorMessage);
}
@@ -69,7 +70,7 @@ public class SchemaVersions {
throw new AAISchemaValidationException(errorMessage);
}
}
-
+
public List<SchemaVersion> getVersions() {
return versionsValue;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java
index dde7cad6..68678b83 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java
@@ -17,20 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
import org.onap.aai.restclient.RestClient;
import org.onap.aai.restclient.RestClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
-import javax.annotation.PostConstruct;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
public class SchemaVersionsBean {
@@ -51,43 +55,37 @@ public class SchemaVersionsBean {
@PostConstruct
public void initialize() {
- //Call SchemaService to get versions
+ // Call SchemaService to get versions
retrieveAllSchemaVersions();
}
- public void retrieveAllSchemaVersions() throws ExceptionInInitializerError{
- /*
- Call Schema MS to get versions using RestTemplate
- */
+ public void retrieveAllSchemaVersions() throws ExceptionInInitializerError {
+ /*
+ * Call Schema MS to get versions using RestTemplate
+ */
String content = "";
Map<String, String> headersMap = new HashMap<>();
- RestClient restClient = restClientFactory
- .getRestClient(SCHEMA_SERVICE);
+ RestClient restClient = restClientFactory.getRestClient(SCHEMA_SERVICE);
- ResponseEntity<String> schemaResponse = restClient.getGetRequest( content, versionsUri, headersMap);
- Gson gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
- .create();
+ ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, versionsUri, headersMap);
+ Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
schemaVersions = gson.fromJson(schemaResponse.getBody(), SchemaServiceVersions.class);
- if(!validateOverrides(schemaVersions)){
- throw new ExceptionInInitializerError("The versions requested is not supported by SchemaService");
- }
- if("true".equals(overrideSchemaService)){
- schemaVersions.initializeFromSchemaConfig(schemaConfigVersions);
- }
- else{
- schemaVersions.initializeFromSchemaService();
- }
+ if (!validateOverrides(schemaVersions)) {
+ throw new ExceptionInInitializerError("The versions requested is not supported by SchemaService");
+ }
+ if ("true".equals(overrideSchemaService)) {
+ schemaVersions.initializeFromSchemaConfig(schemaConfigVersions);
+ } else {
+ schemaVersions.initializeFromSchemaService();
+ }
}
- public boolean validateOverrides(SchemaServiceVersions schemaVersions1){
+ public boolean validateOverrides(SchemaServiceVersions schemaVersions1) {
boolean versionsAvailable = true;
- if("true".equals(overrideSchemaService)){
- versionsAvailable = schemaConfigVersions.getApiVersions().stream().
- allMatch(
- (s) -> schemaVersions1.getVersionsAll().contains(s)
- );
+ if ("true".equals(overrideSchemaService)) {
+ versionsAvailable = schemaConfigVersions.getApiVersions().stream()
+ .allMatch((s) -> schemaVersions1.getVersionsAll().contains(s));
}
return versionsAvailable;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
index 09062e1c..39efde54 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
@@ -20,10 +20,11 @@
package org.onap.aai.setup;
-import org.springframework.beans.factory.annotation.Autowired;
-
import java.io.*;
import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
/**
* Converts the contents of the schema config file
* (which lists which schema files to be loaded) to
@@ -32,36 +33,33 @@ import java.util.List;
*/
public abstract class Translator {
- protected SchemaVersions schemaVersions;
+ protected SchemaVersions schemaVersions;
- public Translator(SchemaVersions schemaVersions) {
- this.schemaVersions = schemaVersions;
- }
-
- /**
- * Translates the contents of the schema config file
- * into the input for the NodeIngestor
- *
- * @return Map of Version to the list of (string) filenames to be
- * ingested for that version
- */
+ public Translator(SchemaVersions schemaVersions) {
+ this.schemaVersions = schemaVersions;
+ }
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the NodeIngestor
+ *
+ * @return Map of Version to the list of (string) filenames to be
+ * ingested for that version
+ */
public abstract List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException;
- public abstract List<String>
- getJsonPayload(SchemaVersion version) throws IOException;
-
- /**
- * Translates the contents of the schema config file
- * into the input for the EdgeIngestor
- *
- * @return Map of Version to the List of (String) filenames to be
- * ingested for that version
- */
+ public abstract List<String> getJsonPayload(SchemaVersion version) throws IOException;
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the EdgeIngestor
+ *
+ * @return Map of Version to the List of (String) filenames to be
+ * ingested for that version
+ */
- public SchemaVersions getSchemaVersions(){
+ public SchemaVersions getSchemaVersions() {
return this.schemaVersions;
- }
+ }
}
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 3fd536b0..1506f135 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
@@ -24,7 +24,7 @@ package org.onap.aai.validation;
* Indicates that a fatal error in the A&AI schema has been found.
*/
public class AAISchemaValidationException extends IllegalStateException {
- public AAISchemaValidationException(String msg) {
- super(msg);
- }
+ public AAISchemaValidationException(String msg) {
+ super(msg);
+ }
}
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 768c18bd..3f0ee41f 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
@@ -21,6 +21,7 @@
/**
*
*/
+
package org.onap.aai.validation;
import java.util.ArrayList;
@@ -29,42 +30,48 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
/**
- * When an error is found, mark that it is NOT ok to
- * continue with installation/whatever other caller function,
+ * When an error is found, mark that it is NOT ok to
+ * continue with installation/whatever other caller function,
* and keep track of the message but
* keep validating so all issues are found in one run.
*/
public class CheckEverythingStrategy implements SchemaErrorStrategy {
- private boolean isOK = true;
- private List<String> errorMsgs = new ArrayList<>();
+ private boolean isOK = true;
+ private List<String> errorMsgs = new ArrayList<>();
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
- */
- @Override
- public boolean isOK() {
- return isOK;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
+ */
+ @Override
+ public boolean isOK() {
+ return isOK;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
- */
- @Override
- public String getErrorMsg() {
- if (errorMsgs.isEmpty()) {
- return "No errors found.";
- } else {
- return StringUtils.join(errorMsgs, "\n");
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
+ */
+ @Override
+ public String getErrorMsg() {
+ if (errorMsgs.isEmpty()) {
+ return "No errors found.";
+ } else {
+ return StringUtils.join(errorMsgs, "\n");
+ }
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
- */
- @Override
- public void notifyOnError(String errorMsg) {
- isOK = false;
- errorMsgs.add(errorMsg);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
+ */
+ @Override
+ public void notifyOnError(String errorMsg) {
+ isOK = false;
+ errorMsgs.add(errorMsg);
+ }
}
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 36176587..7308e377 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
@@ -21,6 +21,7 @@
/**
*
*/
+
package org.onap.aai.validation;
import java.util.List;
@@ -41,15 +42,17 @@ public class DefaultVersionValidationModule implements VersionValidationModule {
private ConfigTranslator config;
- @Autowired
- public DefaultVersionValidationModule(ConfigTranslator config) {
+ @Autowired
+ public DefaultVersionValidationModule(ConfigTranslator config) {
- this.config = config;
- }
+ this.config = config;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
+ */
@Override
public String validate() {
Map<SchemaVersion, List<String>> nodeConfig = config.getNodeFiles();
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 2c21e685..1352e6b7 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
@@ -21,6 +21,7 @@
/**
*
*/
+
package org.onap.aai.validation;
/**
@@ -29,33 +30,39 @@ package org.onap.aai.validation;
* process to abort.
*/
public class FailFastStrategy implements SchemaErrorStrategy {
- private boolean isOK = true;
- private String errorMsg = "No errors found.";
+ private boolean isOK = true;
+ private String errorMsg = "No errors found.";
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
- */
- @Override
- public boolean isOK() {
- return isOK;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
+ */
+ @Override
+ public boolean isOK() {
+ return isOK;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
- */
- @Override
- public String getErrorMsg() {
- return errorMsg;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
+ */
+ @Override
+ public String getErrorMsg() {
+ return errorMsg;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
- */
- @Override
- public void notifyOnError(String errorMsg) {
- isOK = false;
- this.errorMsg = errorMsg;
- throw new AAISchemaValidationException(errorMsg);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
+ */
+ @Override
+ public void notifyOnError(String errorMsg) {
+ isOK = false;
+ this.errorMsg = errorMsg;
+ throw new AAISchemaValidationException(errorMsg);
+ }
}
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 cefc29c2..f46416cb 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
@@ -24,36 +24,36 @@ package org.onap.aai.validation;
* Controls response to finding problems in the schema files.
*/
public interface SchemaErrorStrategy {
- /**
- * Gives if it is OK to proceed with whatever process
- * invoked the validation (probably the installation of
- * the A&AI instance).
- *
- * @return boolean
- */
- public boolean isOK();
-
- /**
- * Gets the error message(s) gathered in the course
- * of validation.
- *
- * @return String error message or messages concatenated together
- */
- public String getErrorMsg();
-
- /**
- * Invokes the ErrorStrategy to do whatever response to
- * an issue in the schema having been found.
- *
- * Options:
- * -Throw an exception if the whole process should be
- * immediately aborted
- * -Set OK status to false, store the message and allow the
- * validation process to continue and find any other issues
- * -Completely ignore that something is wrong
- * etc.
- *
- * @param String errorMsg - the error message from the validator module
- */
- public void notifyOnError(String errorMsg);
+ /**
+ * Gives if it is OK to proceed with whatever process
+ * invoked the validation (probably the installation of
+ * the A&AI instance).
+ *
+ * @return boolean
+ */
+ public boolean isOK();
+
+ /**
+ * Gets the error message(s) gathered in the course
+ * of validation.
+ *
+ * @return String error message or messages concatenated together
+ */
+ public String getErrorMsg();
+
+ /**
+ * Invokes the ErrorStrategy to do whatever response to
+ * an issue in the schema having been found.
+ *
+ * Options:
+ * -Throw an exception if the whole process should be
+ * immediately aborted
+ * -Set OK status to false, store the message and allow the
+ * validation process to continue and find any other issues
+ * -Completely ignore that something is wrong
+ * etc.
+ *
+ * @param String errorMsg - the error message from the validator module
+ */
+ public void notifyOnError(String errorMsg);
}
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 b87be79a..ec3523bf 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
@@ -20,19 +20,18 @@
package org.onap.aai.validation;
-
/**
* Defines the behavior for what versions are required/optional.
*
* Constructor must take ConfigTranslator via autowiring.
*/
public interface VersionValidationModule {
-
- /**
- * Validates that all required versions have schema
- * configured for them.
- *
- * @return empty string if none missing or else an appropriate error
- */
- public String validate();
+
+ /**
+ * Validates that all required versions have schema
+ * configured for them.
+ *
+ * @return empty string if none missing or else an appropriate error
+ */
+ public String validate();
}
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 612da353..375bec0f 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
@@ -29,25 +29,25 @@ import org.springframework.stereotype.Component;
*/
@Component
public class VersionValidator {
- private SchemaErrorStrategy strat;
- private VersionValidationModule verMod;
-
- @Autowired
- public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
- this.strat = strategy;
- this.verMod = verMod;
- }
-
- public boolean validate() {
- String result = verMod.validate();
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
-
- return strat.isOK();
- }
-
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ private SchemaErrorStrategy strat;
+ private VersionValidationModule verMod;
+
+ @Autowired
+ public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
+ this.strat = strategy;
+ this.verMod = verMod;
+ }
+
+ public boolean validate() {
+ String result = verMod.validate();
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+
+ return strat.isOK();
+ }
+
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}
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 d4ab7aeb..73337a49 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
@@ -21,60 +21,62 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
+
+import java.util.*;
+
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.EdgeRuleQuery.Builder;
import org.onap.aai.edges.enums.EdgeField;
import org.onap.aai.edges.enums.EdgeType;
-import java.util.*;
-
/**
* Validates that in the collection of cousin rules between a given node type pair,
- * there is exactly 1 set default=true.
+ * there is exactly 1 set default=true.
*/
public class CousinDefaultingValidationModule {
- /**
- * Validates that in the collection of cousin rules between a given node type pair,
- * there is exactly 1 set default=true.
- *
- * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
- * @param List<DocumentContext> ctxs - the ingested json schema to validate
- * @return empty string if ok, appropriate error message otherwise
- */
- public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
- String[] types = nodeTypePair.split("\\|");
- 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()));
- }
-
- if (rules.isEmpty()) {
- return ""; //bc irrelevant check
- }
-
- int defaultCount = 0;
- Set<String> defLabels = new HashSet<>();
- for (Map<String, String> rule : rules) {
- if ("true".equals(rule.get(EdgeField.DEFAULT.toString()))) {
- defaultCount++;
- defLabels.add(rule.get(EdgeField.LABEL.toString()));
- }
- }
-
- StringBuilder errorBase = new StringBuilder().append("Pair ").append(nodeTypePair).append(" must have exactly one cousin rule set as default. ");
- if (defaultCount == 1) {
- return "";
- } else if (defaultCount == 0){
- errorBase.append("None set.");
- return errorBase.toString();
- } else {
- errorBase.append("Multiple set, see labels: ");
- for (String label : defLabels) {
- errorBase.append(label).append(" ");
- }
- return errorBase.toString();
- }
- }
+ /**
+ * Validates that in the collection of cousin rules between a given node type pair,
+ * there is exactly 1 set default=true.
+ *
+ * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
+ * @param List<DocumentContext> ctxs - the ingested json schema to validate
+ * @return empty string if ok, appropriate error message otherwise
+ */
+ public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
+ String[] types = nodeTypePair.split("\\|");
+ 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()));
+ }
+
+ if (rules.isEmpty()) {
+ return ""; // bc irrelevant check
+ }
+
+ int defaultCount = 0;
+ Set<String> defLabels = new HashSet<>();
+ for (Map<String, String> rule : rules) {
+ if ("true".equals(rule.get(EdgeField.DEFAULT.toString()))) {
+ defaultCount++;
+ defLabels.add(rule.get(EdgeField.LABEL.toString()));
+ }
+ }
+
+ StringBuilder errorBase = new StringBuilder().append("Pair ").append(nodeTypePair)
+ .append(" must have exactly one cousin rule set as default. ");
+ if (defaultCount == 1) {
+ return "";
+ } else if (defaultCount == 0) {
+ errorBase.append("None set.");
+ return errorBase.toString();
+ } else {
+ errorBase.append("Multiple set, see labels: ");
+ for (String label : defLabels) {
+ errorBase.append(label).append(" ");
+ }
+ return errorBase.toString();
+ }
+ }
}
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 9a7288b0..1229cf49 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
@@ -21,14 +21,15 @@
/**
*
*/
-package org.onap.aai.validation.edges;
-import org.onap.aai.edges.enums.EdgeField;
+package org.onap.aai.validation.edges;
import java.util.EnumSet;
import java.util.Map;
import java.util.Map.Entry;
+import org.onap.aai.edges.enums.EdgeField;
+
/**
* Default core A&AI edge field validation
* All fields in EdgeField enum are required EXCEPT description
@@ -36,37 +37,41 @@ import java.util.Map.Entry;
*/
public class DefaultEdgeFieldsValidationModule implements EdgeFieldsValidationModule {
- /* (non-Javadoc)
- * @see org.onap.aai.edges.EdgeFieldsValidator#verifyFields(java.util.Map)
- */
- @Override
- public String verifyFields(Map<String, String> rule) {
- EnumSet<EdgeField> missingFields = EnumSet.complementOf(EnumSet.allOf(EdgeField.class));
-
- for (EdgeField f : EdgeField.values()) {
- if (!rule.containsKey(f.toString()) && (f != EdgeField.DESCRIPTION) && (f != EdgeField.PRIVATE)) { //description is optional
- missingFields.add(f);
- }
- }
-
- StringBuilder errorMsg = new StringBuilder();
- if (!missingFields.isEmpty()) {
- errorMsg.append("Rule ").append(ruleToString(rule)).append(" missing required fields: ");
- for (EdgeField mf : missingFields) {
- errorMsg.append(mf.toString()).append(" ");
- }
- }
-
- return errorMsg.toString();
- }
-
- private String ruleToString(Map<String, String> rule) {
- StringBuilder sb = new StringBuilder();
- for (Entry<String, String> fields : rule.entrySet()) {
- sb.append(fields.getKey()).append(":").append(fields.getValue()).append(" ");
- }
-
- return sb.toString();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.EdgeFieldsValidator#verifyFields(java.util.Map)
+ */
+ @Override
+ public String verifyFields(Map<String, String> rule) {
+ EnumSet<EdgeField> missingFields = EnumSet.complementOf(EnumSet.allOf(EdgeField.class));
+
+ for (EdgeField f : EdgeField.values()) {
+ if (!rule.containsKey(f.toString()) && (f != EdgeField.DESCRIPTION) && (f != EdgeField.PRIVATE)) { // description
+ // is
+ // optional
+ missingFields.add(f);
+ }
+ }
+
+ StringBuilder errorMsg = new StringBuilder();
+ if (!missingFields.isEmpty()) {
+ errorMsg.append("Rule ").append(ruleToString(rule)).append(" missing required fields: ");
+ for (EdgeField mf : missingFields) {
+ errorMsg.append(mf.toString()).append(" ");
+ }
+ }
+
+ return errorMsg.toString();
+ }
+
+ private String ruleToString(Map<String, String> rule) {
+ StringBuilder sb = new StringBuilder();
+ for (Entry<String, String> fields : rule.entrySet()) {
+ sb.append(fields.getKey()).append(":").append(fields.getValue()).append(" ");
+ }
+
+ return sb.toString();
+ }
}
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 10ac1892..3bfa8d80 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
@@ -27,28 +27,28 @@ import java.util.Map;
*
*/
public interface EdgeFieldsValidationModule {
-
- /**
- * Verifies the given rule has all required fields.
- * Implement to check for what you determine to be required.
- * You may also throw an error on unexpected fields if you wish,
- * whatever makes sense for your system.
- *
- * @param rule - Map<String, String> that will look something like this:
- * {
- * "from": "foo",
- * "to": "bar",
- * "label": "tosca.relationships.network.BindsTo",
- * "direction": "OUT",
- * "multiplicity": "ONE2ONE",
- * "contains-other-v": "NONE",
- * "delete-other-v": "NONE",
- * "prevent-delete": "NONE",
- * "default": "true",
- * "description":"An edge comment"
- * }
- * @return empty String if no errors found, or String with
- * the appropriate error message
- */
- public String verifyFields(Map<String, String> rule);
+
+ /**
+ * Verifies the given rule has all required fields.
+ * Implement to check for what you determine to be required.
+ * You may also throw an error on unexpected fields if you wish,
+ * whatever makes sense for your system.
+ *
+ * @param rule - Map<String, String> that will look something like this:
+ * {
+ * "from": "foo",
+ * "to": "bar",
+ * "label": "tosca.relationships.network.BindsTo",
+ * "direction": "OUT",
+ * "multiplicity": "ONE2ONE",
+ * "contains-other-v": "NONE",
+ * "delete-other-v": "NONE",
+ * "prevent-delete": "NONE",
+ * "default": "true",
+ * "description":"An edge comment"
+ * }
+ * @return empty String if no errors found, or String with
+ * the appropriate error message
+ */
+ public String verifyFields(Map<String, String> rule);
}
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 38dcbb7e..4eedaa07 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
@@ -21,37 +21,37 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
+
+import java.util.*;
+
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.SchemaVersion;
import org.onap.aai.validation.SchemaErrorStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.*;
-
/**
* Runs all validations against the ingested schema
*/
@Component
public class EdgeRuleValidator {
- private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
- private final SchemaErrorStrategy strat;
- protected final EdgeFieldsValidationModule fieldValidator;
- protected final UniqueLabelValidationModule labelValidator;
- protected final SingleContainmentValidationModule containsValidator;
- protected final CousinDefaultingValidationModule defaultsValidator;
- protected final NodeTypesValidationModule typeValidator;
+ private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
+ private final SchemaErrorStrategy strat;
+ protected final EdgeFieldsValidationModule fieldValidator;
+ protected final UniqueLabelValidationModule labelValidator;
+ protected final SingleContainmentValidationModule containsValidator;
+ protected final CousinDefaultingValidationModule defaultsValidator;
+ protected final NodeTypesValidationModule typeValidator;
@Autowired
public EdgeRuleValidator(ConfigTranslator config, SchemaErrorStrategy strat,
- EdgeFieldsValidationModule fieldValidator, UniqueLabelValidationModule labelValidator,
- SingleContainmentValidationModule containsValidator, CousinDefaultingValidationModule defaultsValidator,
- NodeTypesValidationModule typeValidator) {
- //TODO - Need to change this to use files/schemaservice
+ EdgeFieldsValidationModule fieldValidator, UniqueLabelValidationModule labelValidator,
+ SingleContainmentValidationModule containsValidator, CousinDefaultingValidationModule defaultsValidator,
+ NodeTypesValidationModule typeValidator) {
+ // TODO - Need to change this to use files/schemaservice
this.versionJsonFilesMap = new JsonIngestor().ingest(config.getEdgeFiles());
this.strat = strat;
this.fieldValidator = fieldValidator;
@@ -61,49 +61,50 @@ public class EdgeRuleValidator {
this.typeValidator = typeValidator;
}
- public boolean validate() {
-
- 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<>();
- TypeAlphabetizer alpher = new TypeAlphabetizer();
-
- for (Map<String, String> rule : rules) {
- handleResult(fieldValidator.verifyFields(rule));
- nodeTypePairs.add(alpher.buildAlphabetizedKey(rule.get(EdgeField.FROM.toString()), rule.get(EdgeField.TO.toString())));
- }
-
- for (String nodeTypePair : nodeTypePairs) {
- handleResult(labelValidator.validate(nodeTypePair, ctxs));
- handleResult(containsValidator.validate(nodeTypePair, ctxs));
- handleResult(defaultsValidator.validate(nodeTypePair, ctxs));
- }
-
- handleResult(typeValidator.validate(nodeTypePairs, v));
- }
-
- return strat.isOK();
- }
-
- private List<Map<String, String>> collectRules(List<DocumentContext> ctxs) {
- List<Map<String, String>> rules = new ArrayList<>();
-
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.*"));
- }
-
- return rules;
- }
-
- private void handleResult(String result) {
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
- }
-
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ public boolean validate() {
+
+ 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<>();
+ TypeAlphabetizer alpher = new TypeAlphabetizer();
+
+ for (Map<String, String> rule : rules) {
+ handleResult(fieldValidator.verifyFields(rule));
+ nodeTypePairs.add(alpher.buildAlphabetizedKey(rule.get(EdgeField.FROM.toString()),
+ rule.get(EdgeField.TO.toString())));
+ }
+
+ for (String nodeTypePair : nodeTypePairs) {
+ handleResult(labelValidator.validate(nodeTypePair, ctxs));
+ handleResult(containsValidator.validate(nodeTypePair, ctxs));
+ handleResult(defaultsValidator.validate(nodeTypePair, ctxs));
+ }
+
+ handleResult(typeValidator.validate(nodeTypePairs, v));
+ }
+
+ return strat.isOK();
+ }
+
+ private List<Map<String, String>> collectRules(List<DocumentContext> ctxs) {
+ List<Map<String, String>> rules = new ArrayList<>();
+
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.*"));
+ }
+
+ return rules;
+ }
+
+ private void handleResult(String result) {
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+ }
+
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}
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 e8c45063..0de66249 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
@@ -20,16 +20,15 @@
package org.onap.aai.validation.edges;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* Validates that the node types appearing in the edge rules are valid
* against the ingested OXM.
@@ -38,52 +37,52 @@ import java.util.Set;
*/
@Component
public class NodeTypesValidationModule {
- private NodeIngestor ni;
-
- @Autowired
- public NodeTypesValidationModule(NodeIngestor ni) {
- this.ni = ni;
- }
-
- /**
- * Validate that every node type in the given set is defined in
- * the OXM for the given version
- *
- * @param nodeTypePairs - all the node types in
- * the edge rules for the given 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, SchemaVersion v) {
- //setup
- Set<String> nodeTypes = new HashSet<>();
- for (String pair : nodeTypePairs) {
- String[] types = pair.split("\\|");
-
- for (String type : types) {
- if (!"".equals(type)) {
- nodeTypes.add(type);
- }
- }
- }
-
- //validation
- Set<String> badTypes = new HashSet<>();
- for (String type : nodeTypes) {
- if (!ni.hasNodeType(type, v)) {
- badTypes.add(type);
- }
- }
-
- if (badTypes.isEmpty()) {
- return "";
- } else {
- StringBuilder errorBase = new StringBuilder().append("Invalid node type(s) found: ");
- for (String bt : badTypes) {
- errorBase.append(bt).append(" ");
- }
- return errorBase.toString();
- }
- }
+ private NodeIngestor ni;
+
+ @Autowired
+ public NodeTypesValidationModule(NodeIngestor ni) {
+ this.ni = ni;
+ }
+
+ /**
+ * Validate that every node type in the given set is defined in
+ * the OXM for the given version
+ *
+ * @param nodeTypePairs - all the node types in
+ * the edge rules for the given 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, SchemaVersion v) {
+ // setup
+ Set<String> nodeTypes = new HashSet<>();
+ for (String pair : nodeTypePairs) {
+ String[] types = pair.split("\\|");
+
+ for (String type : types) {
+ if (!"".equals(type)) {
+ nodeTypes.add(type);
+ }
+ }
+ }
+
+ // validation
+ Set<String> badTypes = new HashSet<>();
+ for (String type : nodeTypes) {
+ if (!ni.hasNodeType(type, v)) {
+ badTypes.add(type);
+ }
+ }
+
+ if (badTypes.isEmpty()) {
+ return "";
+ } else {
+ StringBuilder errorBase = new StringBuilder().append("Invalid node type(s) found: ");
+ for (String bt : badTypes) {
+ errorBase.append(bt).append(" ");
+ }
+ return errorBase.toString();
+ }
+ }
}
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 ad2cffeb..5f6a9646 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
@@ -21,40 +21,41 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
-import org.onap.aai.edges.EdgeRuleQuery;
-import org.onap.aai.edges.enums.EdgeType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.onap.aai.edges.EdgeRuleQuery;
+import org.onap.aai.edges.enums.EdgeType;
+
/**
* Validates that the given node type pair has at most one containment relationship
* in their edge rules.
*
*/
public class SingleContainmentValidationModule {
-
- /**
- * Validates that the given node type pair has at most one containment relationship
- * in their edge rules.
- *
- * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
- * @param List<DocumentContext> ctxs - the ingested json to validate
- * @return empty string if passes, else appropriate error message
- */
- public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
- String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new EdgeRuleQuery.Builder(types[0], types[1]).edgeType(EdgeType.TREE).build();
- List<Map<String, String>> rules = new ArrayList<>();
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
- }
-
- if (rules.isEmpty() || rules.size() == 1) {
- return "";
- } else { //had more than one containment relationship for the pair
- return "Pair " + nodeTypePair + " has multiple containment rules. Only one allowed.";
- }
- }
+
+ /**
+ * Validates that the given node type pair has at most one containment relationship
+ * in their edge rules.
+ *
+ * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
+ * @param List<DocumentContext> ctxs - the ingested json to validate
+ * @return empty string if passes, else appropriate error message
+ */
+ public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
+ String[] types = nodeTypePair.split("\\|");
+ EdgeRuleQuery lookup = new EdgeRuleQuery.Builder(types[0], types[1]).edgeType(EdgeType.TREE).build();
+ List<Map<String, String>> rules = new ArrayList<>();
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
+ }
+
+ if (rules.isEmpty() || rules.size() == 1) {
+ return "";
+ } else { // had more than one containment relationship for the pair
+ return "Pair " + nodeTypePair + " has multiple containment rules. Only one allowed.";
+ }
+ }
}
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 35d74667..82dc1694 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
@@ -21,46 +21,47 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
+
+import java.util.*;
+
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.EdgeRuleQuery.Builder;
import org.onap.aai.edges.enums.EdgeField;
-import java.util.*;
-
/**
* Applies label validation rules
*
*/
public class UniqueLabelValidationModule {
-
- /**
- * Validates that the given pair of node types have no duplicate labels in
- * their edge rules
- *
- * @param String nodeTypePair - of the form "typeA|typeB"
- * @param List<DocumentContext> ctxs - the edge rule json to pull rules from
- * (ie all files for one version)
- * @return empty string if no errors, else string error message
- */
- public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
- String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new Builder(types[0], types[1]).build();
-
- List<Map<String, String>> rules = new ArrayList<>();
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
- }
-
- Set<String> labelsSeen = new HashSet<>();
- for (Map<String, String> rule : rules) {
- String label = rule.get(EdgeField.LABEL.toString());
- if (labelsSeen.contains(label)) {
- return "Pair " + nodeTypePair + " has multiple rules using the same label: " + label +
- ". Every rule between the same node type pair must have a unique label.";
- } else {
- labelsSeen.add(label);
- }
- }
- return "";
- }
+
+ /**
+ * Validates that the given pair of node types have no duplicate labels in
+ * their edge rules
+ *
+ * @param String nodeTypePair - of the form "typeA|typeB"
+ * @param List<DocumentContext> ctxs - the edge rule json to pull rules from
+ * (ie all files for one version)
+ * @return empty string if no errors, else string error message
+ */
+ public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
+ String[] types = nodeTypePair.split("\\|");
+ EdgeRuleQuery lookup = new Builder(types[0], types[1]).build();
+
+ List<Map<String, String>> rules = new ArrayList<>();
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
+ }
+
+ Set<String> labelsSeen = new HashSet<>();
+ for (Map<String, String> rule : rules) {
+ String label = rule.get(EdgeField.LABEL.toString());
+ if (labelsSeen.contains(label)) {
+ return "Pair " + nodeTypePair + " has multiple rules using the same label: " + label
+ + ". Every rule between the same node type pair must have a unique label.";
+ } else {
+ labelsSeen.add(label);
+ }
+ }
+ return "";
+ }
}
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 bbb3388f..024525b9 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
@@ -20,6 +20,9 @@
package org.onap.aai.validation.nodes;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -36,9 +39,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
/**
* Default duplicate rules for A&AI -
* node types may never have a duplicate definition
@@ -49,56 +49,59 @@ import com.google.common.collect.Multimap;
*/
public class DefaultDuplicateNodeDefinitionValidationModule implements DuplicateNodeDefinitionValidationModule {
- /* (non-Javadoc)
- * @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
- */
- @Override
- public String findDuplicates(List<String> files, SchemaVersion v) {
- try {
- final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-
- Multimap<String, String> types = ArrayListMultimap.create();
- boolean foundDups = false;
- 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();
- if (types.containsKey(type)) {
- foundDups = true;
- }
- types.put(type, file);
- }
- }
-
- if (foundDups) {
- return buildErrorMsg(types, v);
- } else {
- return "";
- }
- } catch (ParserConfigurationException | SAXException | IOException e) {
- // TODO something useful with this information
- return e.getMessage();
- }
- }
-
- 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);
- if (files.size() == 1) {
- continue; //only record the duplicated ones
- }
- errorMsg.append(nodeType).append(" has definitions in ");
- for (String file : files) {
- errorMsg.append(file).append(" ");
- }
- }
- return errorMsg.toString();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
+ */
+ @Override
+ public String findDuplicates(List<String> files, SchemaVersion v) {
+ try {
+ final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+ Multimap<String, String> types = ArrayListMultimap.create();
+ boolean foundDups = false;
+ 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();
+ if (types.containsKey(type)) {
+ foundDups = true;
+ }
+ types.put(type, file);
+ }
+ }
+
+ if (foundDups) {
+ return buildErrorMsg(types, v);
+ } else {
+ return "";
+ }
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ // TODO something useful with this information
+ return e.getMessage();
+ }
+ }
+
+ 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);
+ if (files.size() == 1) {
+ continue; // only record the duplicated ones
+ }
+ errorMsg.append(nodeType).append(" has definitions in ");
+ for (String file : files) {
+ errorMsg.append(file).append(" ");
+ }
+ }
+ return errorMsg.toString();
+ }
}
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 5484adda..4fbf4198 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
@@ -35,13 +35,13 @@ import org.onap.aai.setup.SchemaVersion;
* etc.
*/
public interface DuplicateNodeDefinitionValidationModule {
- /**
- * Finds any duplicates according to the defined rules
- *
- * @param files - the OXM files to use with full directory
- * @return empty String if none found, else a String
- * with appropriate information about what node types
- * were found
- */
- String findDuplicates(List<String> files, SchemaVersion v);
+ /**
+ * Finds any duplicates according to the defined rules
+ *
+ * @param files - the OXM files to use with full directory
+ * @return empty String if none found, else a String
+ * with appropriate information about what node types
+ * were found
+ */
+ 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 38b3a70c..ac9ecbdd 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
@@ -33,28 +33,29 @@ import org.springframework.stereotype.Component;
public class NodeValidator {
private ConfigTranslator translator;
- private SchemaErrorStrategy strat;
- private DuplicateNodeDefinitionValidationModule dupChecker;
+ private SchemaErrorStrategy strat;
+ private DuplicateNodeDefinitionValidationModule dupChecker;
- @Autowired
- public NodeValidator( ConfigTranslator translator, SchemaErrorStrategy strategy, DuplicateNodeDefinitionValidationModule dupChecker) {
+ @Autowired
+ public NodeValidator(ConfigTranslator translator, SchemaErrorStrategy strategy,
+ DuplicateNodeDefinitionValidationModule dupChecker) {
this.translator = translator;
- this.strat = strategy;
- this.dupChecker = dupChecker;
- }
-
- public boolean validate() {
-
- for(Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
- String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
- }
- return strat.isOK();
- }
-
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ this.strat = strategy;
+ this.dupChecker = dupChecker;
+ }
+
+ public boolean validate() {
+
+ for (Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
+ String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+ }
+ return strat.isOK();
+ }
+
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}