use of org.pentaho.di.trans.step.StepIOMetaInterface in project pentaho-kettle by pentaho.
the class MultiMergeJoinDialog method getMeta.
/**
* Get the meta data
*
* @param meta
*/
private void getMeta(MultiMergeJoinMeta meta) {
StepIOMetaInterface stepIOMeta = meta.getStepIOMeta();
List<StreamInterface> infoStreams = stepIOMeta.getInfoStreams();
StreamInterface stream;
String streamDescription;
ArrayList<String> inputStepNameList = new ArrayList<String>();
ArrayList<String> keyList = new ArrayList<String>();
CCombo wInputStep;
String inputStepName;
for (int i = 0; i < wInputStepArray.length; i++) {
wInputStep = wInputStepArray[i];
inputStepName = wInputStep.getText();
if (Utils.isEmpty(inputStepName)) {
continue;
}
inputStepNameList.add(inputStepName);
keyList.add(keyValTextBox[i].getText());
if (infoStreams.size() < inputStepNameList.size()) {
streamDescription = BaseMessages.getString(PKG, "MultiMergeJoin.InfoStream.Description");
stream = new Stream(StreamType.INFO, null, streamDescription, StreamIcon.INFO, null);
stepIOMeta.addStream(stream);
}
}
int inputStepCount = inputStepNameList.size();
meta.allocateInputSteps(inputStepCount);
meta.allocateKeys(inputStepCount);
String[] inputSteps = meta.getInputSteps();
String[] keyFields = meta.getKeyFields();
infoStreams = stepIOMeta.getInfoStreams();
for (int i = 0; i < inputStepCount; i++) {
inputStepName = inputStepNameList.get(i);
inputSteps[i] = inputStepName;
stream = infoStreams.get(i);
stream.setStepMeta(transMeta.findStep(inputStepName));
keyFields[i] = keyList.get(i);
}
meta.setJoinType(joinTypeCombo.getText());
}
use of org.pentaho.di.trans.step.StepIOMetaInterface in project pentaho-kettle by pentaho.
the class TransGraph method mouseMove.
@Override
public void mouseMove(MouseEvent e) {
boolean shift = (e.stateMask & SWT.SHIFT) != 0;
noInputStep = null;
// disable the tooltip
//
toolTip.hide();
Point real = screen2real(e.x, e.y);
// Remember the last position of the mouse for paste with keyboard
//
lastMove = real;
if (iconoffset == null) {
iconoffset = new Point(0, 0);
}
Point icon = new Point(real.x - iconoffset.x, real.y - iconoffset.y);
if (noteoffset == null) {
noteoffset = new Point(0, 0);
}
Point note = new Point(real.x - noteoffset.x, real.y - noteoffset.y);
// Moved over an area?
//
AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case STEP_ICON:
StepMeta stepMeta = (StepMeta) areaOwner.getOwner();
resetDelayTimer(stepMeta);
break;
case // Give the timer a bit more time
MINI_ICONS_BALLOON:
stepMeta = (StepMeta) areaOwner.getParent();
resetDelayTimer(stepMeta);
break;
default:
break;
}
}
try {
TransGraphExtension ext = new TransGraphExtension(this, e, real);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseMoved.id, ext);
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling TransGraphMouseMoved extension point", ex);
}
//
if (selectedStep != null && !selectedStep.isSelected()) {
transMeta.unselectAll();
selectedStep.setSelected(true);
selectedSteps = new ArrayList<>();
selectedSteps.add(selectedStep);
previous_step_locations = new Point[] { selectedStep.getLocation() };
redraw();
} else if (selectedNote != null && !selectedNote.isSelected()) {
transMeta.unselectAll();
selectedNote.setSelected(true);
selectedNotes = new ArrayList<>();
selectedNotes.add(selectedNote);
previous_note_locations = new Point[] { selectedNote.getLocation() };
redraw();
} else if (selectionRegion != null && startHopStep == null) {
// Did we select a region...?
//
selectionRegion.width = real.x - selectionRegion.x;
selectionRegion.height = real.y - selectionRegion.y;
redraw();
} else if (selectedStep != null && lastButton == 1 && !shift && startHopStep == null) {
//
// One or more icons are selected and moved around...
//
// new : new position of the ICON (not the mouse pointer) dx : difference with previous position
//
int dx = icon.x - selectedStep.getLocation().x;
int dy = icon.y - selectedStep.getLocation().y;
// See if we have a hop-split candidate
//
TransHopMeta hi = findHop(icon.x + iconsize / 2, icon.y + iconsize / 2, selectedStep);
if (hi != null) {
//
if (!hi.getFromStep().equals(selectedStep) && !hi.getToStep().equals(selectedStep)) {
split_hop = true;
last_hop_split = hi;
hi.split = true;
}
} else {
if (last_hop_split != null) {
last_hop_split.split = false;
last_hop_split = null;
split_hop = false;
}
}
selectedNotes = transMeta.getSelectedNotes();
selectedSteps = transMeta.getSelectedSteps();
// Adjust location of selected steps...
if (selectedSteps != null) {
for (int i = 0; i < selectedSteps.size(); i++) {
StepMeta stepMeta = selectedSteps.get(i);
PropsUI.setLocation(stepMeta, stepMeta.getLocation().x + dx, stepMeta.getLocation().y + dy);
stopStepMouseOverDelayTimer(stepMeta);
}
}
// Adjust location of selected hops...
if (selectedNotes != null) {
for (int i = 0; i < selectedNotes.size(); i++) {
NotePadMeta ni = selectedNotes.get(i);
PropsUI.setLocation(ni, ni.getLocation().x + dx, ni.getLocation().y + dy);
}
}
redraw();
} else if ((startHopStep != null && endHopStep == null) || (endHopStep != null && startHopStep == null)) {
// Are we creating a new hop with the middle button or pressing SHIFT?
//
StepMeta stepMeta = transMeta.getStep(real.x, real.y, iconsize);
endHopLocation = new Point(real.x, real.y);
if (stepMeta != null && ((startHopStep != null && !startHopStep.equals(stepMeta)) || (endHopStep != null && !endHopStep.equals(stepMeta)))) {
StepIOMetaInterface ioMeta = stepMeta.getStepMetaInterface().getStepIOMeta();
if (candidate == null) {
//
if (startHopStep != null) {
if (ioMeta.isInputAcceptor()) {
candidate = new TransHopMeta(startHopStep, stepMeta);
endHopLocation = null;
} else {
noInputStep = stepMeta;
toolTip.setImage(null);
toolTip.setText("This step does not accept any input from other steps");
toolTip.show(new org.eclipse.swt.graphics.Point(real.x, real.y));
}
} else if (endHopStep != null) {
if (ioMeta.isOutputProducer()) {
candidate = new TransHopMeta(stepMeta, endHopStep);
endHopLocation = null;
} else {
noInputStep = stepMeta;
toolTip.setImage(null);
toolTip.setText("This step doesn't pass any output to other steps. (except perhaps for targetted output)");
toolTip.show(new org.eclipse.swt.graphics.Point(real.x, real.y));
}
}
}
} else {
if (candidate != null) {
candidate = null;
redraw();
}
}
redraw();
}
//
if (selectedNote != null) {
if (lastButton == 1 && !shift) {
/*
* One or more notes are selected and moved around...
*
* new : new position of the note (not the mouse pointer) dx : difference with previous position
*/
int dx = note.x - selectedNote.getLocation().x;
int dy = note.y - selectedNote.getLocation().y;
selectedNotes = transMeta.getSelectedNotes();
selectedSteps = transMeta.getSelectedSteps();
// Adjust location of selected steps...
if (selectedSteps != null) {
for (int i = 0; i < selectedSteps.size(); i++) {
StepMeta stepMeta = selectedSteps.get(i);
PropsUI.setLocation(stepMeta, stepMeta.getLocation().x + dx, stepMeta.getLocation().y + dy);
}
}
// Adjust location of selected hops...
if (selectedNotes != null) {
for (int i = 0; i < selectedNotes.size(); i++) {
NotePadMeta ni = selectedNotes.get(i);
PropsUI.setLocation(ni, ni.getLocation().x + dx, ni.getLocation().y + dy);
}
}
redraw();
}
}
}
use of org.pentaho.di.trans.step.StepIOMetaInterface in project pentaho-kettle by pentaho.
the class TransMeta method realClone.
/**
* Perform a real clone of the transformation meta-data object, including cloning all lists and copying all values. If
* the doClear parameter is true, the clone will be cleared of ALL values before the copy. If false, only the copied
* fields will be cleared.
*
* @param doClear
* Whether to clear all of the clone's data before copying from the source object
* @return a real clone of the calling object
*/
public Object realClone(boolean doClear) {
try {
TransMeta transMeta = (TransMeta) super.clone();
if (doClear) {
transMeta.clear();
} else {
// Clear out the things we're replacing below
transMeta.databases = new ArrayList<>();
transMeta.steps = new ArrayList<>();
transMeta.hops = new ArrayList<>();
transMeta.notes = new ArrayList<>();
transMeta.dependencies = new ArrayList<>();
transMeta.partitionSchemas = new ArrayList<>();
transMeta.slaveServers = new ArrayList<>();
transMeta.clusterSchemas = new ArrayList<>();
transMeta.namedParams = new NamedParamsDefault();
transMeta.stepChangeListeners = new ArrayList<>();
}
for (DatabaseMeta db : databases) {
transMeta.addDatabase((DatabaseMeta) db.clone());
}
for (StepMeta step : steps) {
transMeta.addStep((StepMeta) step.clone());
}
// PDI-15799: Step references are original yet. Set them to the clones.
for (StepMeta step : transMeta.getSteps()) {
final StepMetaInterface stepMetaInterface = step.getStepMetaInterface();
if (stepMetaInterface != null) {
final StepIOMetaInterface stepIOMeta = stepMetaInterface.getStepIOMeta();
if (stepIOMeta != null) {
for (StreamInterface stream : stepIOMeta.getInfoStreams()) {
String streamStepName = stream.getStepname();
if (streamStepName != null) {
StepMeta streamStepMeta = transMeta.findStep(streamStepName);
stream.setStepMeta(streamStepMeta);
}
}
}
}
}
for (TransHopMeta hop : hops) {
transMeta.addTransHop((TransHopMeta) hop.clone());
}
for (NotePadMeta note : notes) {
transMeta.addNote((NotePadMeta) note.clone());
}
for (TransDependency dep : dependencies) {
transMeta.addDependency((TransDependency) dep.clone());
}
for (SlaveServer slave : slaveServers) {
transMeta.getSlaveServers().add((SlaveServer) slave.clone());
}
for (ClusterSchema schema : clusterSchemas) {
transMeta.getClusterSchemas().add(schema.clone());
}
for (PartitionSchema schema : partitionSchemas) {
transMeta.getPartitionSchemas().add((PartitionSchema) schema.clone());
}
for (String key : listParameters()) {
transMeta.addParameterDefinition(key, getParameterDefault(key), getParameterDescription(key));
}
return transMeta;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of org.pentaho.di.trans.step.StepIOMetaInterface in project pentaho-kettle by pentaho.
the class TransPainter method drawLine.
private void drawLine(StepMeta fs, StepMeta ts, TransHopMeta hi, boolean is_candidate) {
int[] line = getLine(fs, ts);
EColor col;
ELineStyle linestyle = ELineStyle.SOLID;
int activeLinewidth = linewidth;
EImage arrow;
if (is_candidate) {
col = EColor.BLUE;
arrow = EImage.ARROW_CANDIDATE;
} else {
if (hi.isEnabled()) {
if (fs.isSendingErrorRowsToStep(ts)) {
col = EColor.RED;
linestyle = ELineStyle.DASH;
activeLinewidth = linewidth + 1;
arrow = EImage.ARROW_ERROR;
} else {
col = EColor.HOP_DEFAULT;
arrow = EImage.ARROW_DEFAULT;
}
} else {
col = EColor.GRAY;
arrow = EImage.ARROW_DISABLED;
}
}
if (hi.split) {
activeLinewidth = linewidth + 2;
}
// Check to see if the source step is an info step for the target step.
//
StepIOMetaInterface ioMeta = ts.getStepMetaInterface().getStepIOMeta();
List<StreamInterface> infoStreams = ioMeta.getInfoStreams();
if (!infoStreams.isEmpty()) {
//
for (StreamInterface stream : infoStreams) {
if (fs.getName().equalsIgnoreCase(stream.getStepname())) {
//
if (fs.getCopies() > 1) {
// This is not a desirable situation, it will always end in error.
// As such, it's better not to give feedback on it.
// We do this by drawing an error icon over the hop...
//
col = EColor.RED;
arrow = EImage.ARROW_ERROR;
}
}
}
}
gc.setForeground(col);
gc.setLineStyle(linestyle);
gc.setLineWidth(activeLinewidth);
drawArrow(arrow, line, hi, fs, ts);
if (hi.split) {
gc.setLineWidth(linewidth);
}
gc.setForeground(EColor.BLACK);
gc.setBackground(EColor.BACKGROUND);
gc.setLineStyle(ELineStyle.SOLID);
}
use of org.pentaho.di.trans.step.StepIOMetaInterface in project pentaho-kettle by pentaho.
the class MultiMergeJoin method processFirstRow.
private boolean processFirstRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
meta = (MultiMergeJoinMeta) smi;
data = (MultiMergeJoinData) sdi;
TransMeta transMeta = getTransMeta();
TransHopMeta transHopMeta;
StepIOMetaInterface stepIOMeta = meta.getStepIOMeta();
List<StreamInterface> infoStreams = stepIOMeta.getInfoStreams();
StreamInterface stream;
StepMeta toStepMeta = meta.getParentStepMeta();
StepMeta fromStepMeta;
ArrayList<String> inputStepNameList = new ArrayList<String>();
String[] inputStepNames = meta.getInputSteps();
String inputStepName;
for (int i = 0; i < infoStreams.size(); i++) {
inputStepName = inputStepNames[i];
stream = infoStreams.get(i);
fromStepMeta = stream.getStepMeta();
if (fromStepMeta == null) {
// should not arrive here, shoud typically have been caught by init.
throw new KettleException(BaseMessages.getString(PKG, "MultiMergeJoin.Log.UnableToFindReferenceStream", inputStepName));
}
// check the hop
transHopMeta = transMeta.findTransHop(fromStepMeta, toStepMeta, true);
// there is no hop: this is unexpected.
if (transHopMeta == null) {
// should not arrive here, shoud typically have been caught by init.
throw new KettleException(BaseMessages.getString(PKG, "MultiMergeJoin.Log.UnableToFindReferenceStream", inputStepName));
} else if (transHopMeta.isEnabled()) {
inputStepNameList.add(inputStepName);
} else {
logDetailed(BaseMessages.getString(PKG, "MultiMergeJoin.Log.IgnoringStep", inputStepName));
}
}
int streamSize = inputStepNameList.size();
if (streamSize == 0) {
return false;
}
String keyField;
String[] keyFields;
data.rowSets = new RowSet[streamSize];
RowSet rowSet;
Object[] row;
data.rows = new Object[streamSize][];
data.metas = new RowMetaInterface[streamSize];
data.rowLengths = new int[streamSize];
MultiMergeJoinData.QueueComparator comparator = new MultiMergeJoinData.QueueComparator(data);
data.queue = new PriorityQueue<MultiMergeJoinData.QueueEntry>(streamSize, comparator);
data.results = new ArrayList<List<Object[]>>(streamSize);
MultiMergeJoinData.QueueEntry queueEntry;
data.queueEntries = new MultiMergeJoinData.QueueEntry[streamSize];
data.drainIndices = new int[streamSize];
data.keyNrs = new int[streamSize][];
data.dummy = new Object[streamSize][];
RowMetaInterface rowMeta;
data.outputRowMeta = new RowMeta();
for (int i = 0, j = 0; i < inputStepNames.length; i++) {
inputStepName = inputStepNames[i];
if (!inputStepNameList.contains(inputStepName)) {
// ignore step with disabled hop.
continue;
}
queueEntry = new MultiMergeJoinData.QueueEntry();
queueEntry.index = j;
data.queueEntries[j] = queueEntry;
data.results.add(new ArrayList<Object[]>());
rowSet = findInputRowSet(inputStepName);
if (rowSet == null) {
throw new KettleException(BaseMessages.getString(PKG, "MultiMergeJoin.Exception.UnableToFindSpecifiedStep", inputStepName));
}
data.rowSets[j] = rowSet;
row = getRowFrom(rowSet);
data.rows[j] = row;
if (row == null) {
rowMeta = getTransMeta().getStepFields(inputStepName);
data.metas[j] = rowMeta;
} else {
queueEntry.row = row;
rowMeta = rowSet.getRowMeta();
keyField = meta.getKeyFields()[i];
String[] keyFieldParts = keyField.split(",");
String keyFieldPart;
data.keyNrs[j] = new int[keyFieldParts.length];
for (int k = 0; k < keyFieldParts.length; k++) {
keyFieldPart = keyFieldParts[k];
data.keyNrs[j][k] = rowMeta.indexOfValue(keyFieldPart);
if (data.keyNrs[j][k] < 0) {
String message = BaseMessages.getString(PKG, "MultiMergeJoin.Exception.UnableToFindFieldInReferenceStream", keyFieldPart, inputStepName);
logError(message);
throw new KettleStepException(message);
}
}
data.metas[j] = rowMeta;
data.queue.add(data.queueEntries[j]);
}
data.outputRowMeta.mergeRowMeta(rowMeta.clone());
data.rowLengths[j] = rowMeta.size();
data.dummy[j] = RowDataUtil.allocateRowData(rowMeta.size());
j++;
}
return true;
}
Aggregations