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 * Does a DROP->CREATE of a database and the corresponding default user. See also <code>impex:create</code> and 013 * <code>impex:drop</code> 014 * 015 * @goal reset 016 */ 017 public class ResetMojo extends AbstractDBACommandMojo { 018 019 protected Transaction getTransaction(Properties properties, DatabaseCommand command) throws IOException { 020 SQLGenerator generator = new SQLGenerator(properties, url, command); 021 generator.setEncoding(getEncoding()); 022 String sql = generator.getSQL(); 023 Transaction t = new Transaction(); 024 t.setDescription(getTransactionDescription(command)); 025 t.addText(sql); 026 return t; 027 } 028 029 @Override 030 protected void configureTransactions() throws MojoExecutionException { 031 Properties properties = getContextProperties(); 032 try { 033 transactions.add(getTransaction(properties, DatabaseCommand.DROP)); 034 transactions.add(getTransaction(properties, DatabaseCommand.CREATE)); 035 } catch (IOException e) { 036 throw new MojoExecutionException("Error generating SQL", e); 037 } 038 } 039 }