01: package liquibase.ant;
02:
03: import liquibase.Liquibase;
04: import liquibase.util.StringUtils;
05: import org.apache.tools.ant.BuildException;
06:
07: import java.util.List;
08:
09: public class DropAllTask extends BaseLiquibaseTask {
10:
11: private String schemas;
12:
13: public String getSchemas() {
14: return schemas;
15: }
16:
17: public void setSchemas(String schemas) {
18: this .schemas = schemas;
19: }
20:
21: public void execute() throws BuildException {
22:
23: Liquibase liquibase = null;
24: try {
25: liquibase = createLiquibase();
26:
27: if (StringUtils.trimToNull(schemas) != null) {
28: List<String> schemas = StringUtils.splitAndTrim(
29: this .schemas, ",");
30: liquibase.dropAll(schemas.toArray(new String[schemas
31: .size()]));
32: } else {
33: liquibase.dropAll();
34: }
35:
36: } catch (Exception e) {
37: throw new BuildException(e);
38: } finally {
39: closeDatabase(liquibase);
40: }
41: }
42: }
|