use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class SwitchCaseMeta method getStepIOMeta.
/**
* Returns the Input/Output metadata for this step.
*/
public StepIOMetaInterface getStepIOMeta() {
if (ioMeta == null) {
ioMeta = new StepIOMeta(true, false, false, false, false, true);
//
for (SwitchCaseTarget target : caseTargets) {
StreamInterface stream = new Stream(StreamType.TARGET, target.caseTargetStep, BaseMessages.getString(PKG, "SwitchCaseMeta.TargetStream.CaseTarget.Description", Const.NVL(target.caseValue, "")), StreamIcon.TARGET, target);
ioMeta.addStream(stream);
}
//
if (getDefaultTargetStep() != null) {
ioMeta.addStream(new Stream(StreamType.TARGET, getDefaultTargetStep(), BaseMessages.getString(PKG, "SwitchCaseMeta.TargetStream.Default.Description"), StreamIcon.TARGET, null));
}
}
return ioMeta;
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class TransGraph method splitHop.
private void splitHop(TransHopMeta hi) {
int id = 0;
if (!spoon.props.getAutoSplit()) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.SplitHop.Title"), null, BaseMessages.getString(PKG, "TransGraph.Dialog.SplitHop.Message") + Const.CR + hi.toString(), MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 0, BaseMessages.getString(PKG, "TransGraph.Dialog.Option.SplitHop.DoNotAskAgain"), spoon.props.getAutoSplit());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
id = md.open();
spoon.props.setAutoSplit(md.getToggleState());
}
if ((id & 0xFF) == 0) {
// Means: "Yes" button clicked!
// Only split A-->--B by putting C in between IF...
// C-->--A or B-->--C don't exists...
// A ==> hi.getFromStep()
// B ==> hi.getToStep();
// C ==> selected_step
//
boolean caExists = transMeta.findTransHop(selectedStep, hi.getFromStep()) != null;
boolean bcExists = transMeta.findTransHop(hi.getToStep(), selectedStep) != null;
if (!caExists && !bcExists) {
StepMeta fromStep = hi.getFromStep();
StepMeta toStep = hi.getToStep();
// In case step A targets B then we now need to target C
//
StepIOMetaInterface fromIo = fromStep.getStepMetaInterface().getStepIOMeta();
for (StreamInterface stream : fromIo.getTargetStreams()) {
if (stream.getStepMeta() != null && stream.getStepMeta().equals(toStep)) {
// This target stream was directed to B, now we need to direct it to C
stream.setStepMeta(selectedStep);
fromStep.getStepMetaInterface().handleStreamSelection(stream);
}
}
// In case step B sources from A then we now need to source from C
//
StepIOMetaInterface toIo = toStep.getStepMetaInterface().getStepIOMeta();
for (StreamInterface stream : toIo.getInfoStreams()) {
if (stream.getStepMeta() != null && stream.getStepMeta().equals(fromStep)) {
// This info stream was reading from B, now we need to direct it to C
stream.setStepMeta(selectedStep);
toStep.getStepMetaInterface().handleStreamSelection(stream);
}
}
// In case there is error handling on A, we want to make it point to C now
//
StepErrorMeta errorMeta = fromStep.getStepErrorMeta();
if (fromStep.isDoingErrorHandling() && toStep.equals(errorMeta.getTargetStep())) {
errorMeta.setTargetStep(selectedStep);
}
TransHopMeta newhop1 = new TransHopMeta(hi.getFromStep(), selectedStep);
if (transMeta.findTransHop(newhop1) == null) {
transMeta.addTransHop(newhop1);
spoon.addUndoNew(transMeta, new TransHopMeta[] { newhop1 }, new int[] { transMeta.indexOfTransHop(newhop1) }, true);
}
TransHopMeta newhop2 = new TransHopMeta(selectedStep, hi.getToStep());
if (transMeta.findTransHop(newhop2) == null) {
transMeta.addTransHop(newhop2);
spoon.addUndoNew(transMeta, new TransHopMeta[] { newhop2 }, new int[] { transMeta.indexOfTransHop(newhop2) }, true);
}
int idx = transMeta.indexOfTransHop(hi);
spoon.addUndoDelete(transMeta, new TransHopMeta[] { hi }, new int[] { idx }, true);
transMeta.removeTransHop(idx);
spoon.refreshTree();
}
// else: Silently discard this hop-split attempt.
}
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class TransGraph method setToolTip.
private AreaOwner setToolTip(int x, int y, int screenX, int screenY) {
AreaOwner subject = null;
if (!spoon.getProperties().showToolTips()) {
return subject;
}
canvas.setToolTipText(null);
String newTip = null;
Image tipImage = null;
final TransHopMeta hi = findHop(x, y);
// check the area owner list...
//
StringBuilder tip = new StringBuilder();
AreaOwner areaOwner = getVisibleAreaOwner(x, y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case REMOTE_INPUT_STEP:
StepMeta step = (StepMeta) areaOwner.getParent();
tip.append("Remote input steps:").append(Const.CR).append("-----------------------").append(Const.CR);
for (RemoteStep remoteStep : step.getRemoteInputSteps()) {
tip.append(remoteStep.toString()).append(Const.CR);
}
break;
case REMOTE_OUTPUT_STEP:
step = (StepMeta) areaOwner.getParent();
tip.append("Remote output steps:").append(Const.CR).append("-----------------------").append(Const.CR);
for (RemoteStep remoteStep : step.getRemoteOutputSteps()) {
tip.append(remoteStep.toString()).append(Const.CR);
}
break;
case STEP_PARTITIONING:
step = (StepMeta) areaOwner.getParent();
tip.append("Step partitioning:").append(Const.CR).append("-----------------------").append(Const.CR);
tip.append(step.getStepPartitioningMeta().toString()).append(Const.CR);
if (step.getTargetStepPartitioningMeta() != null) {
tip.append(Const.CR).append(Const.CR).append("TARGET: " + step.getTargetStepPartitioningMeta().toString()).append(Const.CR);
}
break;
case STEP_ERROR_ICON:
String log = (String) areaOwner.getParent();
tip.append(log);
tipImage = GUIResource.getInstance().getImageStepError();
break;
case STEP_ERROR_RED_ICON:
String redLog = (String) areaOwner.getParent();
tip.append(redLog);
tipImage = GUIResource.getInstance().getImageRedStepError();
break;
case HOP_COPY_ICON:
step = (StepMeta) areaOwner.getParent();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.HopTypeCopy", step.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageCopyHop();
break;
case ROW_DISTRIBUTION_ICON:
step = (StepMeta) areaOwner.getParent();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.RowDistribution", step.getName(), step.getRowDistribution() == null ? "" : step.getRowDistribution().getDescription()));
tip.append(Const.CR);
tipImage = GUIResource.getInstance().getImageBalance();
break;
case HOP_INFO_ICON:
StepMeta from = (StepMeta) areaOwner.getParent();
StepMeta to = (StepMeta) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.HopTypeInfo", to.getName(), from.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageInfoHop();
break;
case HOP_ERROR_ICON:
from = (StepMeta) areaOwner.getParent();
to = (StepMeta) areaOwner.getOwner();
areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.HopTypeError", from.getName(), to.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageErrorHop();
break;
case HOP_INFO_STEP_COPIES_ERROR:
from = (StepMeta) areaOwner.getParent();
to = (StepMeta) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.InfoStepCopies", from.getName(), to.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageStepError();
break;
case STEP_INPUT_HOP_ICON:
// StepMeta subjectStep = (StepMeta) (areaOwner.getParent());
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopInput();
break;
case STEP_OUTPUT_HOP_ICON:
// subjectStep = (StepMeta) (areaOwner.getParent());
tip.append(BaseMessages.getString(PKG, "TransGraph.StepOutputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_INFO_HOP_ICON:
// subjectStep = (StepMeta) (areaOwner.getParent());
// StreamInterface stream = (StreamInterface) areaOwner.getOwner();
StepIOMetaInterface ioMeta = (StepIOMetaInterface) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInfoConnector.Tooltip") + Const.CR + ioMeta.toString());
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_TARGET_HOP_ICON:
StreamInterface stream = (StreamInterface) areaOwner.getOwner();
tip.append(stream.getDescription());
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_ERROR_HOP_ICON:
StepMeta stepMeta = (StepMeta) areaOwner.getParent();
if (stepMeta.supportsErrorHandling()) {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepSupportsErrorHandling.Tooltip"));
} else {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepDoesNotSupportsErrorHandling.Tooltip"));
}
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_EDIT_ICON:
stepMeta = (StepMeta) (areaOwner.getParent());
tip.append(BaseMessages.getString(PKG, "TransGraph.EditStep.Tooltip"));
tipImage = GUIResource.getInstance().getImageEdit();
break;
case STEP_INJECT_ICON:
stepMeta = (StepMeta) (areaOwner.getParent());
Object injection = areaOwner.getOwner();
if (injection != null) {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInjectionSupported.Tooltip"));
} else {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInjectionNotSupported.Tooltip"));
}
tipImage = GUIResource.getInstance().getImageInject();
break;
case STEP_MENU_ICON:
tip.append(BaseMessages.getString(PKG, "TransGraph.ShowMenu.Tooltip"));
tipImage = GUIResource.getInstance().getImageContextMenu();
break;
default:
break;
}
}
if (hi != null) {
// We clicked on a HOP!
// Set the tooltip for the hop:
tip.append(Const.CR).append(BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo")).append(newTip = hi.toString()).append(Const.CR);
}
if (tip.length() == 0) {
newTip = null;
} else {
newTip = tip.toString();
}
if (newTip == null) {
toolTip.hide();
if (hi != null) {
// We clicked on a HOP!
// Set the tooltip for the hop:
newTip = BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo") + Const.CR + BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.SourceStep") + " " + hi.getFromStep().getName() + Const.CR + BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.TargetStep") + " " + hi.getToStep().getName() + Const.CR + BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Status") + " " + (hi.isEnabled() ? BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Enable") : BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Disable"));
toolTip.setText(newTip);
if (hi.isEnabled()) {
toolTip.setImage(GUIResource.getInstance().getImageHop());
} else {
toolTip.setImage(GUIResource.getInstance().getImageDisabledHop());
}
toolTip.show(new org.eclipse.swt.graphics.Point(screenX, screenY));
} else {
newTip = null;
}
} else if (!newTip.equalsIgnoreCase(getToolTipText())) {
Image tooltipImage = null;
if (tipImage != null) {
tooltipImage = tipImage;
} else {
tooltipImage = GUIResource.getInstance().getImageSpoonLow();
}
showTooltip(newTip, tooltipImage, screenX, screenY);
}
if (areaOwner != null && areaOwner.getExtensionAreaType() != null) {
try {
TransPainterFlyoutTooltipExtension extension = new TransPainterFlyoutTooltipExtension(areaOwner, this, new Point(screenX, screenY));
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterFlyoutTooltip.id, extension);
} catch (Exception e) {
LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter step", e);
}
}
return subject;
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGenerator method generateIifStep.
/**
* This method generates a 4 steps for every IIF clause... TODO: replace with one step...
*
* @param iifField
* @param lastStep
* @param transMeta
* @return steps
*/
private StepMeta generateIifStep(SQLField iifField, TransMeta transMeta, StepMeta lastStep) {
IifFunction iif = iifField.getIif();
// The Filter condition...
//
FilterRowsMeta filterMeta = new FilterRowsMeta();
filterMeta.setCondition(iifField.getIif().getSqlCondition().getCondition());
StepMeta filterStep = new StepMeta(iifField.getExpression(), filterMeta);
filterStep.setLocation(xLocation, 50);
xLocation += 100;
filterStep.setDraw(true);
lastStep = addToTrans(filterStep, transMeta, lastStep);
// The True and false steps...
//
StepMetaInterface trueMetaInterface;
ValueMetaInterface valueMeta = iif.getTrueValue().getValueMeta();
if (iif.isTrueField()) {
CalculatorMeta trueMeta = new CalculatorMeta();
trueMetaInterface = trueMeta;
trueMeta.allocate(1);
CalculatorMetaFunction function = new CalculatorMetaFunction();
function.setFieldName(Const.NVL(iifField.getAlias(), iifField.getField()));
function.setCalcType(CalculatorMetaFunction.CALC_COPY_OF_FIELD);
function.setValueType(valueMeta.getType());
function.setValueLength(valueMeta.getLength());
function.setValuePrecision(valueMeta.getPrecision());
function.setFieldA(iif.getTrueValueString());
function.setConversionMask(valueMeta.getConversionMask());
// CHECKSTYLE:Indentation:OFF
trueMeta.getCalculation()[0] = function;
} else {
ConstantMeta trueMeta = new ConstantMeta();
trueMetaInterface = trueMeta;
trueMeta.allocate(1);
// CHECKSTYLE:Indentation:OFF
trueMeta.getFieldName()[0] = Const.NVL(iifField.getAlias(), iifField.getField());
trueMeta.getFieldType()[0] = iif.getTrueValue().getValueMeta().getTypeDesc();
trueMeta.getValue()[0] = iif.getTrueValue().toString();
trueMeta.getFieldFormat()[0] = valueMeta.getConversionMask();
}
StepMeta trueStep = new StepMeta("TRUE: " + iifField.getExpression(), trueMetaInterface);
trueStep.setLocation(xLocation, 50);
trueStep.setDraw(true);
lastStep = addToTrans(trueStep, transMeta, filterStep);
StepMetaInterface falseMetaInterface;
valueMeta = iif.getFalseValue().getValueMeta();
if (iif.isFalseField()) {
CalculatorMeta falseMeta = new CalculatorMeta();
falseMetaInterface = falseMeta;
falseMeta.allocate(1);
CalculatorMetaFunction function = new CalculatorMetaFunction();
function.setFieldName(Const.NVL(iifField.getAlias(), iifField.getField()));
function.setCalcType(CalculatorMetaFunction.CALC_COPY_OF_FIELD);
function.setValueType(valueMeta.getType());
function.setValueLength(valueMeta.getLength());
function.setValuePrecision(valueMeta.getPrecision());
function.setFieldA(iif.getFalseValueString());
function.setConversionMask(valueMeta.getConversionMask());
falseMeta.getCalculation()[0] = function;
} else {
ConstantMeta falseMeta = new ConstantMeta();
falseMetaInterface = falseMeta;
falseMeta.allocate(1);
falseMeta.getFieldName()[0] = Const.NVL(iifField.getAlias(), iifField.getField());
falseMeta.getFieldType()[0] = iif.getFalseValue().getValueMeta().getTypeDesc();
falseMeta.getFieldFormat()[0] = valueMeta.getConversionMask();
falseMeta.getValue()[0] = iif.getFalseValue().toString();
}
StepMeta falseStep = new StepMeta("FALSE: " + iifField.getExpression(), falseMetaInterface);
falseStep.setLocation(xLocation, 150);
xLocation += 100;
falseStep.setDraw(true);
lastStep = addToTrans(falseStep, transMeta, filterStep);
// specify true/false targets
List<StreamInterface> targetStreams = filterMeta.getStepIOMeta().getTargetStreams();
targetStreams.get(0).setSubject(trueStep.getName());
targetStreams.get(1).setSubject(falseStep.getName());
filterMeta.searchInfoAndTargetSteps(transMeta.getSteps());
DummyTransMeta dummyMeta = new DummyTransMeta();
StepMeta dummyStep = new StepMeta("Collect: " + iifField.getExpression(), dummyMeta);
dummyStep.setLocation(xLocation, 50);
xLocation += 100;
dummyStep.setDraw(true);
lastStep = addToTrans(dummyStep, transMeta, trueStep);
transMeta.addTransHop(new TransHopMeta(falseStep, dummyStep));
return lastStep;
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-metaverse by pentaho.
the class MergeJoinStepAnalyzerTest method testGetInputFields.
@Test
public void testGetInputFields() throws Exception {
doNothing().when(analyzer).validateState(null, mergeJoinMeta);
when(mergeJoinMeta.getStepIOMeta()).thenReturn(ioMetaInterface);
List<StreamInterface> infoStreams = mock(List.class);
when(ioMetaInterface.getInfoStreams()).thenReturn(infoStreams);
StreamInterface leftStream = mock(StreamInterface.class);
StreamInterface rightStream = mock(StreamInterface.class);
when(infoStreams.get(0)).thenReturn(leftStream);
when(infoStreams.get(1)).thenReturn(rightStream);
StepMeta leftStepMeta = mock(StepMeta.class);
StepMeta rightStepMeta = mock(StepMeta.class);
when(leftStream.getStepMeta()).thenReturn(leftStepMeta);
when(rightStream.getStepMeta()).thenReturn(rightStepMeta);
RowMetaInterface leftRmi = mock(RowMetaInterface.class);
RowMetaInterface rightRmi = mock(RowMetaInterface.class);
when(parentTransMeta.getStepFields(eq(leftStepMeta), any(ProgressMonitorListener.class))).thenReturn(leftRmi);
when(parentTransMeta.getStepFields(eq(rightStepMeta), any(ProgressMonitorListener.class))).thenReturn(rightRmi);
when(leftStepMeta.getName()).thenReturn("left");
when(rightStepMeta.getName()).thenReturn("right");
Map<String, RowMetaInterface> inputFields = analyzer.getInputFields(mergeJoinMeta);
assertNotNull(inputFields);
assertEquals(2, inputFields.size());
assertTrue(inputFields.containsKey("left"));
assertTrue(inputFields.containsKey("right"));
assertEquals(leftRmi, inputFields.get("left"));
assertEquals(rightRmi, inputFields.get("right"));
}
Aggregations