View Javadoc

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   * Runs a command that performs a single operation on a database (create,drop etc)
13   */
14  public abstract class SingleDBACommandMojo extends AbstractDBACommandMojo {
15  
16  	public abstract String getCommand();
17  
18  	@Override
19  	protected void configureTransactions() throws MojoExecutionException {
20  		Properties properties = getContextProperties();
21  		SQLGenerator generator = new SQLGenerator(properties, url, DatabaseCommand.valueOf(getCommand().toUpperCase()));
22  		try {
23  			generator.setEncoding(getEncoding());
24  			String sql = generator.getSQL();
25  			Transaction t = new Transaction();
26  			t.addText(sql);
27  			t.setDescription(getTransactionDescription(DatabaseCommand.valueOf(getCommand().toUpperCase())));
28  			transactions.add(t);
29  		} catch (IOException e) {
30  			throw new MojoExecutionException("Error configuring transactions", e);
31  		}
32  	}
33  }