use of org.pentaho.di.repository.ExportFeedback in project pentaho-kettle by pentaho.
the class RepositoryExportProgressDialog method open.
public boolean open() {
boolean retval = true;
final List<ExportFeedback> list = new ArrayList<ExportFeedback>();
IRepositoryExporter tmpExporter = null;
try {
tmpExporter = rep.getExporter();
} catch (KettleException e) {
log.logError(RepositoryExportProgressDialog.class.toString(), "Error creating repository: " + e.toString());
log.logError(Const.getStackTracker(e));
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExportDialog.ErrorExport.Title"), BaseMessages.getString(PKG, "RepositoryExportDialog.ErrorExport.Message"), e);
return false;
}
final IRepositoryExporter exporter = tmpExporter;
// this hack is only to support dog-nail build process for <...>
// and keep base interfaces without changes - getExporter should
// directly return IRepositoryExporterFeedback.
final boolean isFeedback = (exporter instanceof IRepositoryExporterFeedback) ? true : false;
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
exporter.setImportRulesToValidate(importRules);
ProgressMonitorAdapter pMonitor = new ProgressMonitorAdapter(monitor);
if (isFeedback) {
IRepositoryExporterFeedback fExporter = IRepositoryExporterFeedback.class.cast(exporter);
List<ExportFeedback> ret = fExporter.exportAllObjectsWithFeedback(pMonitor, filename, dir, "all");
list.addAll(ret);
} else {
exporter.exportAllObjects(pMonitor, filename, dir, "all");
}
} catch (KettleException e) {
throw new InvocationTargetException(e, BaseMessages.getString(PKG, "RepositoryExportDialog.Error.CreateUpdate", Const.getStackTracker(e)));
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, true, op);
if (!pmd.getProgressMonitor().isCanceled() && isFeedback) {
// show some results here.
IRepositoryExporterFeedback fExporter = IRepositoryExporterFeedback.class.cast(exporter);
showExportResultStatus(list, fExporter.isRulesViolation());
}
} catch (InvocationTargetException e) {
log.logError(RepositoryExportProgressDialog.class.toString(), "Error creating repository: " + e.toString());
log.logError(Const.getStackTracker(e));
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExportDialog.ErrorExport.Title"), BaseMessages.getString(PKG, "RepositoryExportDialog.ErrorExport.Message"), e);
retval = false;
} catch (InterruptedException e) {
log.logError(RepositoryExportProgressDialog.class.toString(), "Error creating repository: " + e.toString());
log.logError(Const.getStackTracker(e));
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExportDialog.ErrorExport.Title"), BaseMessages.getString(PKG, "RepositoryExportDialog.ErrorExport.Message"), e);
retval = false;
}
return retval;
}
Aggregations