org.kuali.core.db.torque.DumpTask Maven / Gradle / Ivy
package org.kuali.core.db.torque;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.tools.ant.Task;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DumpTask extends Task {
private static final Logger logger = LoggerFactory.getLogger(DumpTask.class);
Utils utils = new Utils();
boolean antCompatibilityMode;
DataSource dataSource;
protected void showConfiguration() {
logger.info("Schema: " + schema);
logger.info("Artifact Id: " + artifactId);
logger.info("Database Vendor: " + getTargetDatabase());
if (getEncoding() == null) {
logger.info("Encoding: " + System.getProperty("file.encoding"));
} else {
logger.info("Encoding: " + getEncoding());
}
}
protected void doFilter(Collection elements, List includes, List excludes, String label) {
int all = elements.size();
StringFilter filterer = new StringFilter(includes, excludes);
filterer.filter(elements.iterator());
int remaining = elements.size();
int diff = all - remaining;
Object[] args = { StringUtils.rightPad(label, 12, " "), lpad(all), lpad(diff), lpad(remaining) };
logger.info("{} - {}, filtered out - {}, remaining - {}", args);
}
// Left pad numbers with 4 digits or less
protected String lpad(int smallNumber) {
return StringUtils.leftPad(smallNumber + "", 4, " ");
}
/**
* This is the maven concept of an artifactId
*/
String artifactId;
/**
* The encoding to use
*/
String encoding;
List tableIncludes;
List tableExcludes;
List viewIncludes;
List viewExcludes;
List sequenceIncludes;
List sequenceExcludes;
/**
* This is the "autogenerated by" comment in the XML
*/
String comment;
/**
* JDBC URL.
*/
String url;
/**
* JDBC driver.
*/
String driver;
/**
* Additional properties for the JDBC driver
*/
Properties driverProperties;
/**
* JDBC user name.
*/
String username;
/**
* JDBC password.
*/
String password;
/**
* DB schema to use.
*/
String schema;
/**
* The type of database eg oracle, mysql etc
*/
String targetDatabase;
public String getEncoding() {
return encoding;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getTargetDatabase() {
return targetDatabase;
}
public void setTargetDatabase(String targetDatabase) {
this.targetDatabase = targetDatabase;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public boolean isAntCompatibilityMode() {
return antCompatibilityMode;
}
public void setAntCompatibilityMode(boolean antCompatibilityMode) {
this.antCompatibilityMode = antCompatibilityMode;
}
public Properties getDriverProperties() {
return driverProperties;
}
public void setDriverProperties(Properties driverProperties) {
this.driverProperties = driverProperties;
}
public List getTableIncludes() {
return tableIncludes;
}
public void setTableIncludes(List tableIncludes) {
this.tableIncludes = tableIncludes;
}
public List getTableExcludes() {
return tableExcludes;
}
public void setTableExcludes(List tableExcludes) {
this.tableExcludes = tableExcludes;
}
public List getViewIncludes() {
return viewIncludes;
}
public void setViewIncludes(List viewIncludes) {
this.viewIncludes = viewIncludes;
}
public List getViewExcludes() {
return viewExcludes;
}
public void setViewExcludes(List viewExcludes) {
this.viewExcludes = viewExcludes;
}
public List getSequenceIncludes() {
return sequenceIncludes;
}
public void setSequenceIncludes(List sequenceIncludes) {
this.sequenceIncludes = sequenceIncludes;
}
public List getSequenceExcludes() {
return sequenceExcludes;
}
public void setSequenceExcludes(List sequenceExcludes) {
this.sequenceExcludes = sequenceExcludes;
}
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
}