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  public abstract class SingleDBACommandMojo extends AbstractDBACommandMojo {
30  
31  	public abstract String getCommand();
32  
33  	@Override
34  	protected void configureTransactions() throws MojoExecutionException {
35  		Properties properties = getContextProperties();
36  		SQLGenerator generator = new SQLGenerator(properties, url, DatabaseCommand.valueOf(getCommand().toUpperCase()));
37  		try {
38  			generator.setEncoding(getEncoding());
39  			String sql = generator.getSQL();
40  			Transaction t = new Transaction();
41  			t.addText(sql);
42  			t.setDescription(getTransactionDescription(DatabaseCommand.valueOf(getCommand().toUpperCase())));
43  			transactions.add(t);
44  		} catch (IOException e) {
45  			throw new MojoExecutionException("Error configuring transactions", e);
46  		}
47  	}
48  }