2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-18 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=========================================================
21 package org.onap.aai.setup;
23 import org.springframework.beans.factory.annotation.Value;
24 import org.springframework.context.annotation.Bean;
25 import org.springframework.context.annotation.Configuration;
26 import org.springframework.context.annotation.PropertySource;
27 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
29 import java.util.List;
32 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
33 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
34 public class SchemaLocationsBean {
36 * Per Spring documentation, the last PropertySource that works will
37 * be applied. Here, schema.ingest.file will be an environment variable
38 * set on install that tells Spring where to look for the schema
39 * ingest properties file (and the actual filename), but the former
40 * PropertySource gives the default of looking on the classpath for
41 * schema-ingest.properties in case that second one doesn't work.
43 * The schema-ingest.properties file (or its equivalent if you choose
44 * to name it otherwise) must contain the entries the below @Value
45 * annotations are looking for.
48 @Value("${schema.configuration.location}")
49 private String schemaConfigLoc;
51 @Value("${schema.nodes.location}")
52 private String nodeDirectory;
54 @Value("${schema.edges.location}")
55 private String edgeDirectory;
57 @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
58 private List<String> nodesInclusionPattern;
60 @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
61 private List<String> nodesExclusionPattern;
63 @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
64 private List<String> edgesInclusionPattern;
66 @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
67 private List<String> edgesExclusionPattern;
70 * @return the file name/location with the list of schema files to be ingested
72 public String getSchemaConfigLocation() {
73 return schemaConfigLoc;
77 * Sets the name/location of the file with the list of schema files to ingest
79 * @param schemaConfigLoc - the file name/location
81 public void setSchemaConfigLocation(String schemaConfigLoc) {
82 this.schemaConfigLoc = schemaConfigLoc;
86 * @return the location of the OXM files
88 public String getNodeDirectory() {
93 * Sets the location of the OXM files
95 * @param nodeDirectory - the location of the OXM files
97 public void setNodeDirectory(String nodeDirectory) {
98 this.nodeDirectory = nodeDirectory;
102 * @return the location of the edge rule json files
104 public String getEdgeDirectory() {
105 return edgeDirectory;
109 * Sets the location of the edge rule json files
111 * @param edgeDirectory - the location of the edge rule files
113 public void setEdgeDirectory(String edgeDirectory) {
114 this.edgeDirectory = edgeDirectory;
117 public List<String> getNodesExclusionPattern(){
118 return this.nodesExclusionPattern;
121 public List<String> getNodesInclusionPattern(){
122 return this.nodesInclusionPattern;
125 public List<String> getEdgesExclusionPattern(){
126 return this.edgesExclusionPattern;
129 public List<String> getEdgesInclusionPattern(){
130 return this.edgesInclusionPattern;
133 //this allows the code to actually read the value from the config file
134 //without this those strings get set to literally "${edgeDir}" etc
136 public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
137 return new PropertySourcesPlaceholderConfigurer();