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.util.execute.Executable;
22  import org.kuali.common.util.execute.ExecutablesExecutable;
23  import org.kuali.common.util.spring.SpringUtils;
24  import org.springframework.beans.factory.annotation.Autowired;
25  import org.springframework.context.annotation.Configuration;
26  import org.springframework.context.annotation.Import;
27  import org.springframework.core.env.Environment;
28  
29  /**
30   * Default database reset controller class. It displays the JDBC configuration, then executes a series of SQL statements in order [dba->schema->data->constraints->other].
31   */
32  @Configuration
33  @Import({ JdbcCommonConfig.class, JdbcDataSourceConfig.class, ResetDbaConfig.class, ResetSchemaConfig.class, ResetConstraintsConfig.class, ResetOtherConfig.class })
34  public abstract class AbstractResetController {
35  
36  	@Autowired
37  	Environment env;
38  
39  	@Autowired
40  	JdbcDataSourceConfig dataSourceConfig;
41  
42  	@Autowired
43  	ResetDbaConfig dbaConfig;
44  
45  	@Autowired
46  	ResetSchemaConfig schemaConfig;
47  
48  	@Autowired
49  	ResetDataConfig dataConfig;
50  
51  	@Autowired
52  	ResetConstraintsConfig constraintsConfig;
53  
54  	@Autowired
55  	ResetOtherConfig otherConfig;
56  
57  	protected Executable getResetExecutable() {
58  		List<Executable> executables = new ArrayList<Executable>();
59  		executables.add(dataSourceConfig.jdbcShowConfigExecutable());
60  		executables.add(dbaConfig.jdbcDbaExecutable());
61  		executables.add(schemaConfig.jdbcSchemaExecutable());
62  		executables.add(dataConfig.jdbcDataConcurrentExecutable());
63  		executables.add(dataConfig.jdbcDataSequentialExecutable());
64  		executables.add(constraintsConfig.jdbcConstraintsConcurrentExecutable());
65  		executables.add(constraintsConfig.jdbcConstraintsSequentialExecutable());
66  		executables.add(otherConfig.jdbcOtherConcurrentExecutable());
67  		executables.add(otherConfig.jdbcOtherSequentialExecutable());
68  
69  		ExecutablesExecutable exec = new ExecutablesExecutable();
70  		exec.setSkip(SpringUtils.getBoolean(env, "jdbc.reset.skip", false));
71  		exec.setTimed(SpringUtils.getBoolean(env, "jdbc.reset.timed", true));
72  		exec.setExecutables(executables);
73  		return exec;
74  	}
75  
76  }