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