Replace all tab characters in java files with two spaces to remove linter warning
[aai/schema-service.git] / aai-schema-service / src / main / java / org / onap / aai / schemaservice / config / SchemaLocationsBean.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.onap.aai.schemaservice.config;
21
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;
27
28 import java.util.List;
29
30 @Configuration
31 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
32 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
33 public class SchemaLocationsBean {
34   /*
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.
41    *
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.
45    */
46
47   @Value("${schema.configuration.location}")
48   private String schemaConfigLoc;
49
50   @Value("${schema.nodes.location}")
51   private String nodeDirectory;
52
53   @Value("${schema.edges.location}")
54   private String edgeDirectory;
55
56   @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
57   private List<String> nodesInclusionPattern;
58
59   @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
60   private List<String> nodesExclusionPattern;
61
62   @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
63   private List<String> edgesInclusionPattern;
64
65   @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
66   private List<String> edgesExclusionPattern;
67
68   /**
69    * @return the file name/location with the list of schema files to be ingested
70    */
71   public String getSchemaConfigLocation() {
72     return schemaConfigLoc;
73   }
74
75   /**
76    * Sets the name/location of the file with the list of schema files to ingest
77    *
78    * @param schemaConfigLoc - the file name/location
79    */
80   public void setSchemaConfigLocation(String schemaConfigLoc) {
81     this.schemaConfigLoc = schemaConfigLoc;
82   }
83
84   /**
85    * @return the location of the OXM files
86    */
87   public String getNodeDirectory() {
88     return nodeDirectory;
89   }
90
91   /**
92    * Sets the location of the OXM files
93    *
94    * @param nodeDirectory - the location of the OXM files
95    */
96   public void setNodeDirectory(String nodeDirectory) {
97     this.nodeDirectory = nodeDirectory;
98   }
99
100   /**
101    * @return the location of the edge rule json files
102    */
103   public String getEdgeDirectory() {
104     return edgeDirectory;
105   }
106
107   /**
108    * Sets the location of the edge rule json files
109    *
110    * @param edgeDirectory - the location of the edge rule files
111    */
112   public void setEdgeDirectory(String edgeDirectory) {
113     this.edgeDirectory = edgeDirectory;
114   }
115
116   public List<String> getNodesExclusionPattern(){
117     return this.nodesExclusionPattern;
118   }
119
120   public List<String> getNodesInclusionPattern(){
121     return this.nodesInclusionPattern;
122   }
123
124   public List<String> getEdgesExclusionPattern(){
125     return this.edgesExclusionPattern;
126   }
127
128   public List<String> getEdgesInclusionPattern(){
129     return this.edgesInclusionPattern;
130   }
131
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
134   @Bean
135   public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
136     return new PropertySourcesPlaceholderConfigurer();
137   }
138 }