View Javadoc

1   package org.apache.torque.mojo;
2   
3   import java.io.File;
4   import java.io.IOException;
5   
6   import org.apache.commons.io.FileUtils;
7   import org.apache.maven.plugin.MojoExecutionException;
8   import org.kuali.core.db.torque.KualiTorqueDataDumpTask;
9   
10  /**
11   * Reads the content of tables from a database and exports the data in a database agnostic format to XML files.
12   * 
13   * @goal exportdata
14   * @phase generate-sources
15   */
16  public class ExportDataMojo extends ExportMojo {
17  
18  	/**
19  	 * The format to use for dates/timestamps
20  	 * 
21  	 * @parameter expression="${dateFormat}" default-value="yyyyMMddHHmmss z"
22  	 * @required
23  	 */
24  	private String dateFormat;
25  
26  	/**
27  	 * The directory where data XML files will be written
28  	 * 
29  	 * @parameter expression="${dataXMLDir}" default-value="${basedir}/src/main/impex"
30  	 * @required
31  	 */
32  	private File dataXMLDir;
33  
34  	/**
35  	 * Configure the Ant task
36  	 */
37  	protected void configureTask() throws MojoExecutionException {
38  		KualiTorqueDataDumpTask task = new KualiTorqueDataDumpTask();
39  		setAntTask(task);
40  		super.configureTask();
41  		makeOutputDir();
42  	}
43  
44  	protected void makeOutputDir() throws MojoExecutionException {
45  		if (getDataXMLDir().exists()) {
46  			return;
47  		}
48  		try {
49  			FileUtils.forceMkdir(getDataXMLDir());
50  		} catch (IOException e) {
51  			throw new MojoExecutionException("Error creating output directory", e);
52  		}
53  	}
54  
55  	public File getDataXMLDir() {
56  		return dataXMLDir;
57  	}
58  
59  	public void setDataXMLDir(File outputDir) {
60  		this.dataXMLDir = outputDir;
61  	}
62  
63  	public String getDateFormat() {
64  		return dateFormat;
65  	}
66  
67  	public void setDateFormat(String dateFormat) {
68  		this.dateFormat = dateFormat;
69  	}
70  }