use of org.apache.hop.ui.pipeline.dialog.PipelineExecutionConfigurationDialog in project hop by apache.
the class HopGuiPipelineRunDelegate method executePipeline.
public PipelineExecutionConfiguration executePipeline(final ILogChannel log, final PipelineMeta pipelineMeta, final boolean preview, final boolean debug, LogLevel logLevel) throws HopException {
if (pipelineMeta == null) {
return null;
}
// See if we need to ask for debugging information...
//
PipelineDebugMeta pipelineDebugMeta = null;
PipelineExecutionConfiguration executionConfiguration = null;
if (preview) {
executionConfiguration = getPipelinePreviewExecutionConfiguration();
} else if (debug) {
executionConfiguration = getPipelineDebugExecutionConfiguration();
} else {
executionConfiguration = getPipelineExecutionConfiguration();
}
// Set MetaStore and safe mode information in both the exec config and the metadata
//
pipelineMeta.setMetadataProvider(hopGui.getMetadataProvider());
if (debug) {
// See if we have debugging information stored somewhere?
//
pipelineDebugMeta = pipelineDebugMetaMap.get(pipelineMeta);
if (pipelineDebugMeta == null) {
pipelineDebugMeta = new PipelineDebugMeta(pipelineMeta);
pipelineDebugMetaMap.put(pipelineMeta, pipelineDebugMeta);
}
// Set the default number of rows to retrieve on all selected transforms...
//
List<TransformMeta> selectedTransforms = pipelineMeta.getSelectedTransforms();
if (selectedTransforms != null && selectedTransforms.size() > 0) {
pipelineDebugMeta.getTransformDebugMetaMap().clear();
for (TransformMeta transformMeta : pipelineMeta.getSelectedTransforms()) {
TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
transformDebugMeta.setRowCount(PropsUi.getInstance().getDefaultPreviewSize());
transformDebugMeta.setPausingOnBreakPoint(true);
transformDebugMeta.setReadingFirstRows(false);
pipelineDebugMeta.getTransformDebugMetaMap().put(transformMeta, transformDebugMeta);
}
}
} else if (preview) {
// See if we have preview information stored somewhere?
//
pipelineDebugMeta = pipelinePreviewMetaMap.get(pipelineMeta);
if (pipelineDebugMeta == null) {
pipelineDebugMeta = new PipelineDebugMeta(pipelineMeta);
pipelinePreviewMetaMap.put(pipelineMeta, pipelineDebugMeta);
}
// Set the default number of preview rows on all selected transforms...
//
List<TransformMeta> selectedTransforms = pipelineMeta.getSelectedTransforms();
if (selectedTransforms != null && selectedTransforms.size() > 0) {
pipelineDebugMeta.getTransformDebugMetaMap().clear();
for (TransformMeta transformMeta : pipelineMeta.getSelectedTransforms()) {
TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
transformDebugMeta.setRowCount(PropsUi.getInstance().getDefaultPreviewSize());
transformDebugMeta.setPausingOnBreakPoint(false);
transformDebugMeta.setReadingFirstRows(true);
pipelineDebugMeta.getTransformDebugMetaMap().put(transformMeta, transformDebugMeta);
}
}
}
int debugAnswer = PipelineDebugDialog.DEBUG_CONFIG;
if (debug || preview) {
PipelineDebugDialog pipelineDebugDialog = new PipelineDebugDialog(hopGui.getShell(), pipelineGraph.getVariables(), pipelineDebugMeta);
debugAnswer = pipelineDebugDialog.open();
if (debugAnswer == PipelineDebugDialog.DEBUG_CANCEL) {
//
return null;
}
}
Map<String, String> variableMap = new HashMap<>();
// the default
variableMap.putAll(executionConfiguration.getVariablesMap());
executionConfiguration.setVariablesMap(variableMap);
executionConfiguration.getUsedVariables(pipelineGraph.getVariables(), pipelineMeta);
executionConfiguration.setLogLevel(logLevel);
boolean execConfigAnswer = true;
if (debugAnswer == PipelineDebugDialog.DEBUG_CONFIG && pipelineMeta.isShowDialog()) {
PipelineExecutionConfigurationDialog dialog = new PipelineExecutionConfigurationDialog(hopGui.getShell(), executionConfiguration, pipelineMeta);
execConfigAnswer = dialog.open();
}
if (execConfigAnswer) {
pipelineGraph.pipelineGridDelegate.addPipelineGrid();
pipelineGraph.pipelineLogDelegate.addPipelineLog();
pipelineGraph.extraViewTabFolder.setSelection(0);
// Set the run options
pipelineMeta.setClearingLog(executionConfiguration.isClearingLog());
ExtensionPointHandler.callExtensionPoint(log, pipelineGraph.getVariables(), HopExtensionPoint.HopGuiPipelineMetaExecutionStart.id, pipelineMeta);
ExtensionPointHandler.callExtensionPoint(log, pipelineGraph.getVariables(), HopExtensionPoint.HopGuiPipelineExecutionConfiguration.id, executionConfiguration);
// distinction
if (debug || preview) {
if (pipelineDebugMeta.getNrOfUsedTransforms() == 0) {
MessageBox box = new MessageBox(hopGui.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
box.setText(BaseMessages.getString(PKG, "HopGui.Dialog.Warning.NoPreviewOrDebugTransforms.Title"));
box.setMessage(BaseMessages.getString(PKG, "HopGui.Dialog.Warning.NoPreviewOrDebugTransforms.Message"));
int answer = box.open();
if (answer != SWT.YES) {
return null;
}
}
pipelineGraph.debug(executionConfiguration, pipelineDebugMeta);
} else {
pipelineGraph.start(executionConfiguration);
}
}
return executionConfiguration;
}
Aggregations