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.Configuration;
27 import org.springframework.context.annotation.Import;
28 import org.springframework.core.env.Environment;
29
30
31
32
33 @Configuration
34 @Import({ JdbcCommonConfig.class, JdbcDataSourceConfig.class, SqlDbaBeforeConfig.class, SqlDbaAfterConfig.class })
35 public abstract class AbstractSqlController {
36
37 @Autowired
38 Environment env;
39
40 @Autowired
41 JdbcDataSourceConfig dataSourceConfig;
42
43 @Autowired
44 SqlDbaBeforeConfig dbaBeforeConfig;
45
46 @Autowired
47 SqlDbaAfterConfig dbaAfterConfig;
48
49 @Autowired
50 JdbcCommonConfig commonConfig;
51
52 protected Executable getSqlExecutable() {
53 List<Executable> executables = new ArrayList<Executable>();
54 executables.add(dataSourceConfig.jdbcShowConfigExecutable());
55 executables.add(dbaBeforeConfig.getDbaPhaseExecutable());
56 List<SqlExecutionContext> contexts = SqlConfigUtils.getSqlExecutionContexts(env);
57
58 for (SqlExecutionContext context : contexts) {
59 SqlConfigContext scc = new SqlConfigContext(env, context, commonConfig, dataSourceConfig);
60 Executable executable = SqlConfigUtils.getJdbcExecutable(scc);
61 executables.add(executable);
62 }
63 executables.add(dbaAfterConfig.getDbaPhaseExecutable());
64
65 ExecutablesExecutable exec = new ExecutablesExecutable();
66 exec.setSkip(SpringUtils.getBoolean(env, "jdbc.reset.skip", false));
67 exec.setTimed(SpringUtils.getBoolean(env, "jdbc.reset.timed", true));
68 exec.setExecutables(executables);
69 return exec;
70 }
71
72 }