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.serialization.db.EdgeSerializer;
28 import org.onap.aai.setup.ConfigTranslator;
29 import org.onap.aai.setup.SchemaLocationsBean;
30 import org.onap.aai.setup.SchemaVersions;
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 @Autowired(required = false)
46 NodesConfiguration nodesConfiguration;
48 @Autowired(required = false)
49 EdgesConfiguration edgesConfiguration;
52 public EdgeIngestor edgeIngestor(){
53 return edgesConfiguration.edgeIngestor();
57 public EdgeSerializer edgeSerializer(EdgeIngestor edgeIngestor){
58 return new EdgeSerializer(edgeIngestor);
61 @Bean(name = "nodeIngestor")
62 public NodeIngestor nodeIngestor() {
63 return nodesConfiguration.nodeIngestor();
67 @Bean(name = "configTranslator")
68 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
69 public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions) {
70 return new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
74 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
75 public SchemaErrorStrategy schemaErrorStrategy(){
76 return new CheckEverythingStrategy();
80 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
81 public DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule(){
82 return new DefaultDuplicateNodeDefinitionValidationModule();
86 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
87 public NodeValidator nodeValidator(
88 ConfigTranslator configTranslator,
89 SchemaErrorStrategy schemaErrorStrategy,
90 DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule
92 return new NodeValidator(configTranslator, schemaErrorStrategy, duplicateNodeDefinitionValidationModule);