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 | 0 | public class ResetMojo extends AbstractDBACommandMojo { |
18 | |
|
19 | |
protected Transaction getTransaction(Properties properties, DatabaseCommand command) throws IOException { |
20 | 0 | SQLGenerator generator = new SQLGenerator(properties, url, command); |
21 | 0 | generator.setEncoding(getEncoding()); |
22 | 0 | String sql = generator.getSQL(); |
23 | 0 | Transaction t = new Transaction(); |
24 | 0 | t.setDescription(getTransactionDescription(command)); |
25 | 0 | t.addText(sql); |
26 | 0 | return t; |
27 | |
} |
28 | |
|
29 | |
@Override |
30 | |
protected void configureTransactions() throws MojoExecutionException { |
31 | 0 | Properties properties = getContextProperties(); |
32 | |
try { |
33 | 0 | transactions.add(getTransaction(properties, DatabaseCommand.DROP)); |
34 | 0 | transactions.add(getTransaction(properties, DatabaseCommand.CREATE)); |
35 | 0 | } catch (IOException e) { |
36 | 0 | throw new MojoExecutionException("Error generating SQL", e); |
37 | 0 | } |
38 | 0 | } |
39 | |
} |