Search in sources :

Example 1 with IRepositoryExporterFeedback

use of org.pentaho.di.repository.IRepositoryExporterFeedback 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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ExportFeedback(org.pentaho.di.repository.ExportFeedback) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IRepositoryExporterFeedback(org.pentaho.di.repository.IRepositoryExporterFeedback) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) IRepositoryExporter(org.pentaho.di.repository.IRepositoryExporter)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ProgressMonitorAdapter (org.pentaho.di.core.ProgressMonitorAdapter)1 KettleException (org.pentaho.di.core.exception.KettleException)1 ExportFeedback (org.pentaho.di.repository.ExportFeedback)1 IRepositoryExporter (org.pentaho.di.repository.IRepositoryExporter)1 IRepositoryExporterFeedback (org.pentaho.di.repository.IRepositoryExporterFeedback)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1