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=========================================================
23 package org.onap.aai.config;
25 import org.onap.aai.edges.EdgeIngestor;
26 import org.onap.aai.nodes.NodeIngestor;
27 import org.onap.aai.serialization.db.EdgeSerializer;
28 import org.onap.aai.setup.AAIConfigTranslator;
29 import org.onap.aai.setup.ConfigTranslator;
30 import org.onap.aai.setup.SchemaConfigVersions;
31 import org.onap.aai.setup.SchemaLocationsBean;
32 import org.onap.aai.validation.CheckEverythingStrategy;
33 import org.onap.aai.validation.SchemaErrorStrategy;
34 import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule;
35 import org.onap.aai.validation.nodes.DuplicateNodeDefinitionValidationModule;
36 import org.onap.aai.validation.nodes.NodeValidator;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
39 import org.springframework.context.annotation.*;
41 @Import({NodesConfiguration.class, EdgesConfiguration.class})
43 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
44 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
45 public class SchemaConfiguration {
47 // TODO : Inject this directly into nodeIngestor
48 @Autowired(required = false)
49 NodesConfiguration nodesConfiguration;
51 @Autowired(required = false)
52 EdgesConfiguration edgesConfiguration;
55 public EdgeIngestor edgeIngestor() {
56 return edgesConfiguration.edgeIngestor();
60 public EdgeSerializer edgeSerializer(EdgeIngestor edgeIngestor) {
61 return new EdgeSerializer(edgeIngestor);
64 @Bean(name = "nodeIngestor")
65 public NodeIngestor nodeIngestor() {
66 return nodesConfiguration.nodeIngestor();
69 @Bean(name = "configTranslator")
70 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
71 public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean,
72 SchemaConfigVersions schemaVersions) {
73 return new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
77 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
78 public SchemaErrorStrategy schemaErrorStrategy() {
79 return new CheckEverythingStrategy();
83 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
84 public DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule() {
85 return new DefaultDuplicateNodeDefinitionValidationModule();
89 @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true)
90 public NodeValidator nodeValidator(ConfigTranslator configTranslator, SchemaErrorStrategy schemaErrorStrategy,
91 DuplicateNodeDefinitionValidationModule duplicateNodeDefinitionValidationModule) {
92 return new NodeValidator(configTranslator, schemaErrorStrategy, duplicateNodeDefinitionValidationModule);