1 package org.apache.torque.mojo;
2
3 import java.io.IOException;
4 import java.util.Properties;
5
6 import org.apache.maven.plugin.MojoExecutionException;
7 import org.kuali.db.DatabaseCommand;
8 import org.kuali.db.SQLGenerator;
9 import org.kuali.db.Transaction;
10
11
12
13
14
15
16
17 public class ResetMojo extends AbstractDBACommandMojo {
18
19 protected Transaction getTransaction(Properties properties, DatabaseCommand command) throws IOException {
20 SQLGenerator generator = new SQLGenerator(properties, url, command);
21 generator.setEncoding(getEncoding());
22 String sql = generator.getSQL();
23 Transaction t = new Transaction();
24 t.setDescription(getTransactionDescription(command));
25 t.addText(sql);
26 return t;
27 }
28
29 @Override
30 protected void configureTransactions() throws MojoExecutionException {
31 Properties properties = getContextProperties();
32 try {
33 transactions.add(getTransaction(properties, DatabaseCommand.DROP));
34 transactions.add(getTransaction(properties, DatabaseCommand.CREATE));
35 } catch (IOException e) {
36 throw new MojoExecutionException("Error generating SQL", e);
37 }
38 }
39 }