2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright © 2018 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 package org.onap.aai.config;
24 import org.onap.aai.edges.EdgeIngestor;
25 import org.onap.aai.nodes.NodeIngestor;
26 import org.onap.aai.setup.AAIConfigTranslator;
27 import org.onap.aai.setup.ConfigTranslator;
28 import org.onap.aai.setup.SchemaLocationsBean;
29 import org.onap.aai.setup.SchemaConfigVersions;
30 import org.onap.aai.serialization.db.EdgeSerializer;
31 import org.onap.aai.validation.CheckEverythingStrategy;
32 import org.onap.aai.validation.SchemaErrorStrategy;
33 import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule;
34 import org.onap.aai.validation.nodes.DuplicateNodeDefinitionValidationModule;
35 import org.onap.aai.validation.nodes.NodeValidator;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
38 import org.springframework.context.annotation.*;
39 @Import({NodesConfiguration.class, EdgesConfiguration.class})
41 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
42 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
43 public class SchemaConfiguration {
45 //TODO : Inject this directly into nodeIngestor
46 @Autowired(required = false)
47 NodesConfiguration nodesConfiguration;
49 @Autowired(required = false)
50 EdgesConfiguration edgesConfiguration;
53 public EdgeIngestor edgeIngestor(){
54 return edgesConfiguration.edgeIngestor();
58 public EdgeSerializer edgeSerializer(EdgeIngestor edgeIngestor){
59 return new EdgeSerializer(edgeIngestor);
62 @Bean(name = "nodeIngestor")
63 public NodeIngestor nodeIngestor() {
64 return nodesConfiguration.nodeIngestor();
68 @Bean(name = "configTranslator")
69 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
70 public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaConfigVersions schemaVersions) {
71 return new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
75 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
76 public SchemaErrorStrategy schemaErrorStrategy(){
77 return new CheckEverythingStrategy();
81 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
82 public DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule(){
83 return new DefaultDuplicateNodeDefinitionValidationModule();
87 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
88 public NodeValidator nodeValidator(
89 ConfigTranslator configTranslator,
90 SchemaErrorStrategy schemaErrorStrategy,
91 DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule
93 return new NodeValidator(configTranslator, schemaErrorStrategy, duplicateNodeDefinitionValidationModule);