use of org.apache.hop.core.IProgressMonitor in project hop by apache.
the class HopImport method run.
@Override
public void run() {
try {
log = new LogChannel("HopImport");
if (listPluginTypes != null && listPluginTypes) {
printPluginTypes();
return;
}
if (!validateOptions()) {
cmd.usage(System.err);
return;
}
hopImport = loadImportPlugin();
if (hopImport == null) {
return;
}
log.logDetailed("Start of Hop Import");
// Set the options...
//
hopImport.setValidateInputFolder(inputFolderName);
hopImport.setValidateOutputFolder(outputFolderName);
hopImport.setKettlePropertiesFilename(kettlePropertiesFilename);
hopImport.setJdbcPropertiesFilename(jdbcPropertiesFilename);
hopImport.setSharedXmlFilename(sharedXmlFilename);
if (skippingExistingTargetFiles != null) {
log.logBasic("Import is " + (skippingExistingTargetFiles ? "" : "not ") + "skipping existing target files");
hopImport.setSkippingExistingTargetFiles(skippingExistingTargetFiles);
}
if (skippingHiddenFilesAndFolders != null) {
log.logBasic("Import is " + (skippingHiddenFilesAndFolders ? "" : "not ") + "skipping hidden files and folders");
hopImport.setSkippingHiddenFilesAndFolders(skippingHiddenFilesAndFolders);
}
if (skippingFolders != null) {
log.logBasic("Import is " + (skippingFolders ? "" : "not ") + "skipping sub-folders");
hopImport.setSkippingFolders(skippingFolders);
}
hopImport.setTargetConfigFilename(targetConfigFilename);
// Allow plugins to modify the elements loaded so far, before a pipeline or workflow is even
// loaded
//
ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopImportStart.id, this);
// Handle the options of the configuration plugins
//
Map<String, Object> mixins = cmd.getMixins();
for (String key : mixins.keySet()) {
Object mixin = mixins.get(key);
if (mixin instanceof IConfigOptions) {
IConfigOptions configOptions = (IConfigOptions) mixin;
configOptions.handleOption(log, this, variables);
}
}
// Text version of a progress monitor...
//
IProgressMonitor monitor = new LogProgressMonitor(log);
// Run the import...
//
hopImport.runImport(monitor);
// Print the report...
//
log.logBasic(Const.CR);
log.logBasic(hopImport.getImportReport());
ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopImportEnd.id, this);
} catch (Exception e) {
throw new ExecutionException(cmd, "There was an error during import", e);
}
}
use of org.apache.hop.core.IProgressMonitor in project hop by apache.
the class GetPreviewTableProgressDialog method open.
public List<Object[]> open() {
IRunnableWithProgress op = monitor -> {
db = new Database(HopGui.getInstance().getLoggingObject(), variables, dbMeta);
try {
db.connect();
if (limit > 0) {
db.setQueryLimit(limit);
}
rows = db.getFirstRows(tableName, limit, new ProgressMonitorAdapter(monitor));
rowMeta = db.getReturnRowMeta();
} catch (HopException e) {
throw new InvocationTargetException(e, "Couldn't find any rows because of an error :" + e.toString());
} finally {
db.disconnect();
}
};
try {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
// Run something in the background to cancel active database queries, forecably if needed!
Runnable run = () -> {
IProgressMonitor monitor = pmd.getProgressMonitor();
while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// Ignore
}
}
if (monitor.isCanceled()) {
try {
db.cancelQuery();
} catch (Exception e) {
// Ignore
}
}
};
// Start the cancel tracker in the background!
new Thread(run).start();
pmd.run(true, op);
} catch (InvocationTargetException e) {
showErrorDialog(e);
return null;
} catch (InterruptedException e) {
showErrorDialog(e);
return null;
}
return rows;
}
use of org.apache.hop.core.IProgressMonitor in project hop by apache.
the class GetQueryFieldsProgressDialog method open.
public IRowMeta open() {
IRunnableWithProgress op = monitor -> {
db = new Database(HopGui.getInstance().getLoggingObject(), variables, databaseMeta);
try {
db.connect();
result = db.getQueryFields(sql, false);
if (monitor.isCanceled()) {
throw new InvocationTargetException(new Exception("This operation was cancelled!"));
}
} catch (Exception e) {
throw new InvocationTargetException(e, "Problem encountered determining query fields: " + e.toString());
} finally {
db.disconnect();
}
};
try {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
// Run something in the background to cancel active database queries, forecably if needed!
Runnable run = () -> {
IProgressMonitor monitor = pmd.getProgressMonitor();
while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
// Ignore
}
}
if (monitor.isCanceled()) {
try {
db.cancelQuery();
} catch (Exception e) {
// Ignore
}
}
};
// Dump the cancel looker in the background!
new Thread(run).start();
pmd.run(true, op);
} catch (InvocationTargetException e) {
showErrorDialog(e);
return null;
} catch (InterruptedException e) {
showErrorDialog(e);
return null;
}
return result;
}
use of org.apache.hop.core.IProgressMonitor in project hop by apache.
the class GetTableSizeProgressDialog method open.
public Long open() {
IRunnableWithProgress op = monitor -> {
db = new Database(HopGui.getInstance().getLoggingObject(), variables, databaseMeta);
try {
db.connect();
String sql = databaseMeta.getIDatabase().getSelectCountStatement(tableName);
RowMetaAndData row = db.getOneRow(sql);
size = row.getRowMeta().getInteger(row.getData(), 0);
if (monitor.isCanceled()) {
throw new InvocationTargetException(new Exception("This operation was cancelled!"));
}
} catch (HopException e) {
throw new InvocationTargetException(e, "Couldn't get a result because of an error :" + e.toString());
} finally {
db.disconnect();
monitor.done();
}
};
try {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
// Run something in the background to cancel active database queries, forcibly if needed!
Runnable run = () -> {
IProgressMonitor monitor = pmd.getProgressMonitor();
while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// Ignore
}
}
if (monitor.isCanceled()) {
try {
db.cancelQuery();
} catch (Exception e) {
// Ignore
}
}
};
// Start the cancel tracker in the background!
new Thread(run).start();
pmd.run(true, op);
} catch (InvocationTargetException e) {
showErrorDialog(e);
return null;
} catch (InterruptedException e) {
showErrorDialog(e);
return null;
}
return size;
}
use of org.apache.hop.core.IProgressMonitor in project hop by apache.
the class PipelinePreviewProgressDialog method open.
/**
* Opens the progress dialog
*
* @param showErrorDialogs dictates whether error dialogs should be shown when errors occur - can
* be set to "false" to let the caller control error dialogs instead.
* @return a {@link PipelineMeta}
*/
public PipelineMeta open(final boolean showErrorDialogs) {
final HopGui hopGui = HopGui.getInstance();
IRunnableWithProgress op = monitor -> doPreview(hopGui, monitor, showErrorDialogs);
try {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
// Run something in the background to cancel active database queries, force this if needed!
Runnable run = () -> {
IProgressMonitor monitor = pmd.getProgressMonitor();
while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// Ignore
}
}
if (monitor.isCanceled()) {
try {
pipeline.stopAll();
} catch (Exception e) {
/* Ignore */
}
}
};
// Start the cancel tracker in the background!
new Thread(run).start();
pmd.run(true, op);
} catch (InvocationTargetException | InterruptedException e) {
if (showErrorDialogs) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.ErrorLoadingPipeline.DialogTitle"), BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.ErrorLoadingPipeline.DialogMessage"), e);
}
pipelineMeta = null;
}
return pipelineMeta;
}
Aggregations