diff options
author | Kajur, Harish (vk250x) <vk250x@att.com> | 2018-12-13 09:02:53 -0500 |
---|---|---|
committer | Kajur, Harish (vk250x) <vk250x@att.com> | 2018-12-17 01:49:35 -0500 |
commit | e47092116ce15474412506a967f009a28ee396eb (patch) | |
tree | f5561b061dde1b876d19b549db4895817e3b117b /aai-core/src/main/java | |
parent | e42c7cf9d25b5a5ec3e3bf2cbb5e04441ec45359 (diff) |
Update aai-core use new schema ingest library
Issue-ID: AAI-2003
Change-Id: I9234b6b594e559b58e445a97b78a4658190e6527
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-core/src/main/java')
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/config/IntrospectionConfig.java | 12 | ||||
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/config/SchemaConfiguration.java | 46 |
2 files changed, 45 insertions, 13 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/config/IntrospectionConfig.java b/aai-core/src/main/java/org/onap/aai/config/IntrospectionConfig.java index e737f08d..ab74d798 100644 --- a/aai-core/src/main/java/org/onap/aai/config/IntrospectionConfig.java +++ b/aai-core/src/main/java/org/onap/aai/config/IntrospectionConfig.java @@ -21,7 +21,6 @@ */ package org.onap.aai.config; -import org.onap.aai.schema.enums.ObjectMetadata; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; import org.springframework.beans.factory.annotation.Autowired; @@ -30,18 +29,19 @@ import org.springframework.context.annotation.Configuration; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; import org.onap.aai.introspection.LoaderFactory; import org.onap.aai.introspection.MoxyLoader; -import org.onap.aai.nodes.NodeIngestor; - +import org.springframework.context.annotation.Import; +@Import({NodesConfiguration.class, EdgesConfiguration.class}) @Configuration + public class IntrospectionConfig { private Map<SchemaVersion, MoxyLoader> moxyInstanceMap = new ConcurrentHashMap<>(); + @Autowired - NodeIngestor nodeIngestor; + NodesConfiguration nodesConfiguration; @Bean public LoaderFactory loaderFactory(SchemaVersions schemaVersions) { @@ -52,7 +52,7 @@ public class IntrospectionConfig { public Map<SchemaVersion, MoxyLoader> moxyLoaderInstance(SchemaVersions schemaVersions) { for(SchemaVersion version : schemaVersions.getVersions()){ if (!moxyInstanceMap.containsKey(version)) { - moxyInstanceMap.put(version, new MoxyLoader(version, nodeIngestor)); + moxyInstanceMap.put(version, new MoxyLoader(version, nodesConfiguration.nodeIngestor())); } } return moxyInstanceMap; diff --git a/aai-core/src/main/java/org/onap/aai/config/SchemaConfiguration.java b/aai-core/src/main/java/org/onap/aai/config/SchemaConfiguration.java index b00ecfb7..88de78e7 100644 --- a/aai-core/src/main/java/org/onap/aai/config/SchemaConfiguration.java +++ b/aai-core/src/main/java/org/onap/aai/config/SchemaConfiguration.java @@ -30,33 +30,65 @@ import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersions; import org.onap.aai.validation.CheckEverythingStrategy; import org.onap.aai.validation.SchemaErrorStrategy; +import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule; +import org.onap.aai.validation.nodes.DuplicateNodeDefinitionValidationModule; +import org.onap.aai.validation.nodes.NodeValidator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.*; - +@Import({NodesConfiguration.class, EdgesConfiguration.class}) @Configuration +@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true) +@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) public class SchemaConfiguration { + @Autowired(required = false) + NodesConfiguration nodesConfiguration; + + @Autowired(required = false) + EdgesConfiguration edgesConfiguration; + @Bean - public EdgeIngestor edgeIngestor(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions){ - return new EdgeIngestor(configTranslator(schemaLocationsBean, schemaVersions), schemaVersions); + public EdgeIngestor edgeIngestor(){ + return edgesConfiguration.edgeIngestor(); } @Bean public EdgeSerializer edgeSerializer(EdgeIngestor edgeIngestor){ return new EdgeSerializer(edgeIngestor); } - + @Bean(name = "nodeIngestor") - public NodeIngestor nodeIngestor(ConfigTranslator configTranslator) { - return new NodeIngestor(configTranslator); + public NodeIngestor nodeIngestor() { + return nodesConfiguration.nodeIngestor(); } + @Bean(name = "configTranslator") + @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true) public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions) { return new AAIConfigTranslator(schemaLocationsBean, schemaVersions); } @Bean + @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true) public SchemaErrorStrategy schemaErrorStrategy(){ return new CheckEverythingStrategy(); - } + } + + @Bean + @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true) + public DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule(){ + return new DefaultDuplicateNodeDefinitionValidationModule(); + } + + @Bean + @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true) + public NodeValidator nodeValidator( + ConfigTranslator configTranslator, + SchemaErrorStrategy schemaErrorStrategy, + DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule + ){ + return new NodeValidator(configTranslator, schemaErrorStrategy, duplicateNodeDefinitionValidationModule); + } } |