View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.maven.spring;
17  
18  import java.util.Properties;
19  
20  import org.apache.maven.project.MavenProject;
21  import org.kuali.common.util.MavenConstants;
22  import org.kuali.common.util.execute.Executable;
23  import org.kuali.common.util.execute.SetSourceDbSchemaNameExecutable;
24  import org.kuali.common.util.spring.SpringUtils;
25  import org.springframework.beans.factory.annotation.Autowired;
26  import org.springframework.beans.factory.annotation.Qualifier;
27  import org.springframework.context.annotation.Bean;
28  import org.springframework.context.annotation.Configuration;
29  import org.springframework.core.env.Environment;
30  
31  @Configuration
32  public class SetSourceDbSchemaNameConfig {
33  
34  	@Autowired
35  	Environment env;
36  
37  	@Autowired
38  	@Qualifier(MavenConstants.MAVEN_PROJECT_BEAN_NAME)
39  	MavenProject mavenProject;
40  
41  	@Bean(initMethod = "execute")
42  	public Executable setSourceDbSchemaNameExecutable() {
43  		boolean skip = SpringUtils.getBoolean(env, "jdbc.source.db.setSchemaName.skip", false);
44  		String baseSourceDbSchemaName = SpringUtils.getProperty(env, "jdbc.source.db.base");
45  		Properties mavenProperties = mavenProject.getProperties();
46  		String version = mavenProject.getVersion();
47  
48  		SetSourceDbSchemaNameExecutable executable = new SetSourceDbSchemaNameExecutable();
49  		executable.setBaseSourceDbSchemaName(baseSourceDbSchemaName);
50  		executable.setMavenProperties(mavenProperties);
51  		executable.setSkip(skip);
52  		executable.setVersion(version);
53  		return executable;
54  	}
55  
56  }