001 package org.apache.torque.mojo; 002 003 import java.io.IOException; 004 import java.util.Properties; 005 006 import org.apache.maven.plugin.MojoExecutionException; 007 import org.kuali.db.jdbc.DatabaseCommand; 008 import org.kuali.db.jdbc.SQLGenerator; 009 import org.kuali.db.jdbc.Transaction; 010 011 /** 012 * Runs a command that performs a single operation on a database (create,drop etc) 013 */ 014 public abstract class SingleDBACommandMojo extends AbstractDBACommandMojo { 015 016 public abstract String getCommand(); 017 018 @Override 019 protected void configureTransactions() throws MojoExecutionException { 020 Properties properties = getContextProperties(); 021 SQLGenerator generator = new SQLGenerator(properties, url, DatabaseCommand.valueOf(getCommand().toUpperCase())); 022 try { 023 generator.setEncoding(getEncoding()); 024 String sql = generator.getSQL(); 025 Transaction t = new Transaction(); 026 t.addText(sql); 027 t.setDescription(getTransactionDescription(DatabaseCommand.valueOf(getCommand().toUpperCase()))); 028 transactions.add(t); 029 } catch (IOException e) { 030 throw new MojoExecutionException("Error configuring transactions", e); 031 } 032 } 033 }