1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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 }