
com.github.nicosensei.textbatch.job.ResultFileJobProgress Maven / Gradle / Ivy
/**
*
*/
package com.github.nicosensei.textbatch.job;
import java.io.IOException;
import com.github.nicosensei.textbatch.Tool;
import com.github.nicosensei.textbatch.utils.CommonUtils;
/**
* @author ngiraud
*
*/
public abstract class ResultFileJobProgress extends BasicJobProgress {
private ResultLogger logger;
/**
* @param linesToProcess
* @throws JobProgressException
*/
protected ResultFileJobProgress(
int linesToProcess,
String logId,
String logPattern)
throws JobProgressException {
super(linesToProcess);
logger = new ResultLogger(
logId,
getResultsFilePath(logId),
logPattern);
}
public synchronized void logResult(String resultMessage) {
logger.logResult(resultMessage);
}
public void copyResultsTo(String outputFile) throws JobProgressException {
try {
CommonUtils.copyFile(getResultFilePath(), outputFile);
} catch (final IOException ioe) {
throw JobProgressException.copyFailed(ioe);
}
Tool.getInstance().logInfo("Copied result file to " + outputFile);
}
protected String getResultFilePath() {
return logger.getResultFilePath();
}
/**
* By default return the given logId parameter.
* Override if another behavior is desired.
* @param logId the log ID
* @return the result file base name
*/
protected String getResultsFilePath(String logId) {
return logId;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy