2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.schemaservice.config;
22 import org.springframework.beans.factory.annotation.Value;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.context.annotation.Configuration;
25 import org.springframework.context.annotation.PropertySource;
26 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
28 import java.util.List;
31 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
32 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
33 public class SchemaLocationsBean {
35 * Per Spring documentation, the last PropertySource that works will
36 * be applied. Here, schema.ingest.file will be an environment variable
37 * set on install that tells Spring where to look for the schema
38 * ingest properties file (and the actual filename), but the former
39 * PropertySource gives the default of looking on the classpath for
40 * schema-ingest.properties in case that second one doesn't work.
42 * The schema-ingest.properties file (or its equivalent if you choose
43 * to name it otherwise) must contain the entries the below @Value
44 * annotations are looking for.
47 @Value("${schema.configuration.location}")
48 private String schemaConfigLoc;
50 @Value("${schema.nodes.location}")
51 private String nodeDirectory;
53 @Value("${schema.edges.location}")
54 private String edgeDirectory;
56 @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
57 private List<String> nodesInclusionPattern;
59 @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
60 private List<String> nodesExclusionPattern;
62 @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
63 private List<String> edgesInclusionPattern;
65 @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
66 private List<String> edgesExclusionPattern;
69 * @return the file name/location with the list of schema files to be ingested
71 public String getSchemaConfigLocation() {
72 return schemaConfigLoc;
76 * Sets the name/location of the file with the list of schema files to ingest
78 * @param schemaConfigLoc - the file name/location
80 public void setSchemaConfigLocation(String schemaConfigLoc) {
81 this.schemaConfigLoc = schemaConfigLoc;
85 * @return the location of the OXM files
87 public String getNodeDirectory() {
92 * Sets the location of the OXM files
94 * @param nodeDirectory - the location of the OXM files
96 public void setNodeDirectory(String nodeDirectory) {
97 this.nodeDirectory = nodeDirectory;
101 * @return the location of the edge rule json files
103 public String getEdgeDirectory() {
104 return edgeDirectory;
108 * Sets the location of the edge rule json files
110 * @param edgeDirectory - the location of the edge rule files
112 public void setEdgeDirectory(String edgeDirectory) {
113 this.edgeDirectory = edgeDirectory;
116 public List<String> getNodesExclusionPattern(){
117 return this.nodesExclusionPattern;
120 public List<String> getNodesInclusionPattern(){
121 return this.nodesInclusionPattern;
124 public List<String> getEdgesExclusionPattern(){
125 return this.edgesExclusionPattern;
128 public List<String> getEdgesInclusionPattern(){
129 return this.edgesInclusionPattern;
132 //this allows the code to actually read the value from the config file
133 //without this those strings get set to literally "${edgeDir}" etc
135 public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
136 return new PropertySourcesPlaceholderConfigurer();