View Javadoc

1   /**
2    * Copyright 2010-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.jdbc.spring;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.common.jdbc.context.SqlExecutionContext;
22  import org.kuali.common.util.execute.Executable;
23  import org.kuali.common.util.execute.ExecutablesExecutable;
24  import org.kuali.common.util.spring.SpringUtils;
25  import org.springframework.beans.factory.annotation.Autowired;
26  import org.springframework.context.annotation.Bean;
27  import org.springframework.context.annotation.Configuration;
28  import org.springframework.context.annotation.Import;
29  import org.springframework.core.env.Environment;
30  
31  /**
32   * @deprecated
33   */
34  @Deprecated
35  @Configuration
36  @Import({ JdbcCommonConfig.class, JdbcDataSourceConfig.class, SqlDbaBeforeConfig.class, SqlDbaAfterConfig.class })
37  public class BaseSqlControllerConfig {
38  
39  	@Autowired
40  	Environment env;
41  
42  	@Autowired
43  	JdbcDataSourceConfig dataSourceConfig;
44  
45  	@Autowired
46  	SqlDbaBeforeConfig dbaBeforeConfig;
47  
48  	@Autowired
49  	SqlDbaAfterConfig dbaAfterConfig;
50  
51  	@Autowired
52  	JdbcCommonConfig commonConfig;
53  
54  	@Bean
55  	public Executable sqlExecutable() {
56  		return getSqlExecutable();
57  	}
58  
59  	protected Executable getSqlExecutable() {
60  		List<Executable> executables = new ArrayList<Executable>();
61  		executables.add(dataSourceConfig.jdbcShowDbaConfigExecutable());
62  		executables.add(dbaBeforeConfig.getDbaPhaseExecutable());
63  		List<SqlExecutionContext> contexts = SqlConfigUtils.getSqlExecutionContexts(env);
64  
65  		for (SqlExecutionContext context : contexts) {
66  			SqlConfigContext scc = new SqlConfigContext(env, context, commonConfig, dataSourceConfig);
67  			Executable executable = SqlConfigUtils.getJdbcExecutable(scc);
68  			executables.add(executable);
69  		}
70  		executables.add(dbaAfterConfig.getDbaPhaseExecutable());
71  
72  		ExecutablesExecutable exec = new ExecutablesExecutable();
73  		exec.setSkip(SpringUtils.getBoolean(env, "jdbc.reset.skip", false));
74  		exec.setTimed(SpringUtils.getBoolean(env, "jdbc.reset.timed", true));
75  		exec.setExecutables(executables);
76  		return exec;
77  	}
78  
79  }