Update to use Schema Service
[aai/gizmo.git] / src / main / java / org / onap / crud / SchemaIngestConfiguration.java
index ee050dd..ca76dbd 100644 (file)
@@ -26,37 +26,44 @@ import org.onap.aai.setup.AAIConfigTranslator;
 import org.onap.aai.setup.ConfigTranslator;
 import org.onap.aai.setup.SchemaLocationsBean;
 import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.Translator;
+import org.onap.schema.EdgePropsConfiguration;
+import org.onap.schema.EdgeRulesLoader;
+import org.onap.schema.OxmModelLoader;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
 import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 
 @Configuration
+@ComponentScan(basePackages = {"org.onap.aai.config", "org.onap.aai.setup"})
 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${edgeprops.ingest.file}", ignoreResourceNotFound = true)
 public class SchemaIngestConfiguration {
 
-    @Bean
-    public SchemaVersions schemaVersions() {
-        return new SchemaVersions();
-    }
+    @Autowired
+    private Translator translator;
 
     @Bean
-    public SchemaLocationsBean schemaLocationsBean() {
-        return new SchemaLocationsBean();
+    public OxmModelLoader oxmModelLoader(NodeIngestor nodeIngestor) {
+        return new OxmModelLoader(translator, nodeIngestor );
     }
 
     @Bean
-    public ConfigTranslator configTranslator() {
-        return new AAIConfigTranslator(schemaLocationsBean(), schemaVersions());
+    public EdgeRulesLoader edgeRulesLoader(EdgeIngestor edgeIngestor) {
+        return new EdgeRulesLoader(translator, edgeIngestor, edgePropsConfiguration() );
     }
 
     @Bean
-    public NodeIngestor nodeIngestor() {
-        return new NodeIngestor(configTranslator());
+    public EdgePropsConfiguration edgePropsConfiguration() {
+        return new EdgePropsConfiguration();
     }
 
     @Bean
-    public EdgeIngestor edgeIngestor() {
-        return new EdgeIngestor(configTranslator(), schemaVersions());
+    @ConditionalOnExpression("'${schema.translator.list}'.contains('config')")
+    public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions) {
+        return new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
     }
-
 }
\ No newline at end of file