All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.torque.mojo.ExportDataMojo Maven / Gradle / Ivy

package org.apache.torque.mojo;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.kuali.core.db.torque.KualiTorqueDataDumpTask;

/**
 * Reads the content of tables from a database and exports the data in a database agnostic format to XML files.
 * 
 * @goal exportdata
 * @phase generate-sources
 */
public class ExportDataMojo extends ExportMojo {

    /**
     * The format to use for dates/timestamps
     * 
     * @parameter expression="${dateFormat}" default-value="yyyyMMddHHmmss z"
     * @required
     */
    private String dateFormat;

    /**
     * The directory where data XML files will be written
     * 
     * @parameter expression="${dataXMLDir}" default-value="${basedir}/src/main/impex"
     * @required
     */
    private File dataXMLDir;

    /**
     * Configure the Ant task
     */
    @Override
    protected void configureTask() throws MojoExecutionException {
        KualiTorqueDataDumpTask task = new KualiTorqueDataDumpTask();
        task.setBuildDirectory(new File(getProject().getBuild().getDirectory()));
        setAntTask(task);
        super.configureTask();
        makeOutputDir();
    }

    protected void makeOutputDir() throws MojoExecutionException {
        if (getDataXMLDir().exists()) {
            return;
        }
        try {
            FileUtils.forceMkdir(getDataXMLDir());
        } catch (IOException e) {
            throw new MojoExecutionException("Error creating output directory", e);
        }
    }

    public File getDataXMLDir() {
        return dataXMLDir;
    }

    public void setDataXMLDir(File outputDir) {
        this.dataXMLDir = outputDir;
    }

    public String getDateFormat() {
        return dateFormat;
    }

    public void setDateFormat(String dateFormat) {
        this.dateFormat = dateFormat;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy