use of org.pentaho.di.trans.step.StepErrorMeta in project pentaho-kettle by pentaho.
the class TransGraph method addHop.
protected void addHop(StreamInterface stream) {
switch(stream.getStreamType()) {
case ERROR:
addErrorHop();
candidate.setErrorHop(true);
spoon.newHop(transMeta, candidate);
break;
case INPUT:
spoon.newHop(transMeta, candidate);
break;
case OUTPUT:
StepErrorMeta stepErrorMeta = candidate.getFromStep().getStepErrorMeta();
if (stepErrorMeta != null && stepErrorMeta.getTargetStep() != null) {
if (stepErrorMeta.getTargetStep().equals(candidate.getToStep())) {
candidate.getFromStep().setStepErrorMeta(null);
}
}
spoon.newHop(transMeta, candidate);
break;
case INFO:
stream.setStepMeta(candidate.getFromStep());
candidate.getToStep().getStepMetaInterface().handleStreamSelection(stream);
spoon.newHop(transMeta, candidate);
break;
case TARGET:
// We connect a target of the source step to an output step...
//
stream.setStepMeta(candidate.getToStep());
candidate.getFromStep().getStepMetaInterface().handleStreamSelection(stream);
spoon.newHop(transMeta, candidate);
break;
default:
break;
}
clearSettings();
}
use of org.pentaho.di.trans.step.StepErrorMeta in project pentaho-kettle by pentaho.
the class TransGraphTest method testInitializeXulMenu.
@SuppressWarnings("unchecked")
@Test
public void testInitializeXulMenu() throws KettleException {
StepMeta stepMeta = mock(StepMeta.class);
TransGraph transGraph = mock(TransGraph.class);
TransMeta transMeta = mock(TransMeta.class);
Document document = mock(Document.class);
XulMenuitem xulItem = mock(XulMenuitem.class);
XulMenu xulMenu = mock(XulMenu.class);
StepErrorMeta stepErrorMeta = mock(StepErrorMeta.class);
Spoon spoon = mock(Spoon.class);
List<StepMeta> selection = Arrays.asList(new StepMeta(), stepMeta, new StepMeta());
doCallRealMethod().when(transGraph).setTransMeta(any(TransMeta.class));
doCallRealMethod().when(transGraph).setSpoon(any(Spoon.class));
transGraph.setTransMeta(transMeta);
transGraph.setSpoon(spoon);
when(stepMeta.getStepErrorMeta()).thenReturn(stepErrorMeta);
when(stepMeta.isDrawn()).thenReturn(true);
when(document.getElementById(any(String.class))).thenReturn(xulItem);
when(document.getElementById(TransGraph.TRANS_GRAPH_ENTRY_AGAIN)).thenReturn(xulMenu);
when(document.getElementById(TransGraph.TRANS_GRAPH_ENTRY_SNIFF)).thenReturn(xulMenu);
doCallRealMethod().when(transGraph).initializeXulMenu(any(Document.class), any(List.class), any(StepMeta.class));
transGraph.initializeXulMenu(document, selection, stepMeta);
verify(transMeta).isAnySelectedStepUsedInTransHops();
}
use of org.pentaho.di.trans.step.StepErrorMeta in project pentaho-kettle by pentaho.
the class Spoon method delHop.
public void delHop(TransMeta transMeta, TransHopMeta transHopMeta) {
int index = transMeta.indexOfTransHop(transHopMeta);
addUndoDelete(transMeta, new Object[] { (TransHopMeta) transHopMeta.clone() }, new int[] { index });
transMeta.removeTransHop(index);
StepMeta fromStepMeta = transHopMeta.getFromStep();
StepMeta beforeFrom = (StepMeta) fromStepMeta.clone();
int indexFrom = transMeta.indexOfStep(fromStepMeta);
StepMeta toStepMeta = transHopMeta.getToStep();
StepMeta beforeTo = (StepMeta) toStepMeta.clone();
int indexTo = transMeta.indexOfStep(toStepMeta);
boolean stepFromNeedAddUndoChange = fromStepMeta.getStepMetaInterface().cleanAfterHopFromRemove(transHopMeta.getToStep());
boolean stepToNeedAddUndoChange = toStepMeta.getStepMetaInterface().cleanAfterHopToRemove(fromStepMeta);
//
if (transHopMeta.getFromStep().isDoingErrorHandling()) {
StepErrorMeta stepErrorMeta = fromStepMeta.getStepErrorMeta();
//
if (stepErrorMeta.getTargetStep() != null && stepErrorMeta.getTargetStep().equals(transHopMeta.getToStep())) {
// Only if the target step is where the error handling is going to...
//
stepErrorMeta.setEnabled(false);
stepFromNeedAddUndoChange = true;
}
}
if (stepFromNeedAddUndoChange) {
addUndoChange(transMeta, new Object[] { beforeFrom }, new Object[] { fromStepMeta }, new int[] { indexFrom });
}
if (stepToNeedAddUndoChange) {
addUndoChange(transMeta, new Object[] { beforeTo }, new Object[] { toStepMeta }, new int[] { indexTo });
}
refreshTree();
refreshGraph();
}
use of org.pentaho.di.trans.step.StepErrorMeta in project data-access by pentaho.
the class TableInputTransformGenerator method createInputStep.
protected StepMeta createInputStep(TransMeta transMeta) {
TableInputMeta inputMeta = new TableInputMeta();
inputMeta.setDatabaseMeta(sourceDatabaseMeta);
inputMeta.setExecuteEachInputRow(false);
inputMeta.setRowLimit(Integer.toString(rowLimit));
inputMeta.setSQL(sql);
inputMeta.setVariableReplacementActive(false);
inputMeta.setLazyConversionActive(false);
// inputMeta.setTargetSteps(null);
StepMeta inputStepMeta = new StepMeta(TABLE_INPUT, TABLE_INPUT, inputMeta);
inputStepMeta.setStepErrorMeta(new StepErrorMeta(transMeta, inputStepMeta));
transMeta.addStep(inputStepMeta);
final FileTransformStats stats = getTransformStats();
StepErrorMeta inputErrorMeta = new StepErrorMeta(transMeta, inputStepMeta) {
public void addErrorRowData(Object[] row, int startIndex, long nrErrors, String errorDescriptions, String fieldNames, String errorCodes) {
StringBuffer sb = new StringBuffer();
sb.append("Rejected Row: ");
for (Object rowData : row) {
sb.append(rowData);
sb.append(", ");
}
sb.append("\r\n");
stats.getErrors().add(sb.toString() + errorDescriptions);
super.addErrorRowData(row, startIndex, nrErrors, errorDescriptions, fieldNames, errorCodes);
}
};
StepMeta outputDummyStepMeta = addDummyStep(transMeta, "InputErrorDummy");
inputErrorMeta.setTargetStep(outputDummyStepMeta);
inputErrorMeta.setEnabled(true);
inputStepMeta.setStepErrorMeta(inputErrorMeta);
return inputStepMeta;
}
use of org.pentaho.di.trans.step.StepErrorMeta in project data-access by pentaho.
the class CsvTransformGenerator method createInputStep.
protected StepMeta createInputStep(TransMeta transMeta) {
CsvInputMeta csvInputMeta = new CsvInputMeta();
CsvFileInfo fileInfo = getModelInfo().getFileInfo();
String fileName = fileInfo.getTmpFilename();
String path;
if (fileName.endsWith(".tmp")) {
// $NON-NLS-1$
path = PentahoSystem.getApplicationContext().getSolutionPath(TMP_FILE_PATH);
} else {
String relativePath = PentahoSystem.getSystemSetting("file-upload-defaults/relative-path", // $NON-NLS-1$
String.valueOf(DEFAULT_RELATIVE_UPLOAD_FILE_PATH));
path = PentahoSystem.getApplicationContext().getSolutionPath(relativePath);
}
File file = new File(path + fileInfo.getTmpFilename());
String filename = file.getAbsolutePath();
ColumnInfo[] columns = getModelInfo().getColumns();
TextFileInputField[] inputFields = new TextFileInputField[columns.length];
int idx = 0;
for (ColumnInfo column : columns) {
TextFileInputField field = new TextFileInputField();
field.setCurrencySymbol(fileInfo.getCurrencySymbol());
field.setDecimalSymbol(fileInfo.getCurrencySymbol());
field.setFormat(column.getFormat());
field.setGroupSymbol(fileInfo.getGroupSymbol());
field.setIfNullValue(fileInfo.getIfNull());
field.setIgnored(column.isIgnore());
field.setLength(column.getLength());
field.setName(column.getId());
field.setNullString(fileInfo.getNullStr());
// field.setPosition(position);
field.setPrecision(column.getPrecision());
field.setRepeated(false);
field.setSamples(null);
field.setTrimType(ValueMeta.TRIM_TYPE_BOTH);
field.setType(convertDataType(column));
inputFields[idx] = field;
idx++;
}
csvInputMeta.setAddResultFile(false);
// $NON-NLS-1$
csvInputMeta.setBufferSize("5000");
csvInputMeta.setDelimiter(fileInfo.getDelimiter());
csvInputMeta.setEnclosure(fileInfo.getEnclosure());
csvInputMeta.setEncoding(fileInfo.getEncoding());
csvInputMeta.setFilename(filename);
csvInputMeta.setFilenameField(null);
// TODO strip off more than one row if present...
csvInputMeta.setHeaderPresent(fileInfo.getHeaderRows() > 0);
// inputMeta.get.setID(1);
csvInputMeta.setIncludingFilename(false);
csvInputMeta.setInputFields(inputFields);
csvInputMeta.setLazyConversionActive(true);
// $NON-NLS-1$
csvInputMeta.setRowNumField("");
csvInputMeta.setRunningInParallel(false);
// inputMeta.setTargetSteps(null);
StepMeta csvInputStepMeta = new StepMeta(CSV_INPUT, CSV_INPUT, csvInputMeta);
csvInputStepMeta.setStepErrorMeta(new StepErrorMeta(transMeta, csvInputStepMeta));
transMeta.addStep(csvInputStepMeta);
csvErrorRowCount = 0;
final FileTransformStats stats = getTransformStats();
StepErrorMeta csvInputErrorMeta = new StepErrorMeta(transMeta, csvInputStepMeta) {
public void addErrorRowData(Object[] row, int startIndex, long nrErrors, String errorDescriptions, String fieldNames, String errorCodes) {
if (csvErrorRowCount < maxErrorRows) {
StringBuffer sb = new StringBuffer();
sb.append("Rejected Row: ");
for (Object rowData : row) {
sb.append(rowData);
sb.append(", ");
}
sb.append("\r\n");
stats.getErrors().add(sb.toString() + errorDescriptions);
}
csvErrorRowCount++;
stats.setErrorCount(csvErrorRowCount);
super.addErrorRowData(row, startIndex, nrErrors, errorDescriptions, fieldNames, errorCodes);
}
};
StepMeta outputDummyStepMeta = addDummyStep(transMeta, "CSVInputErrorDummy");
csvInputErrorMeta.setTargetStep(outputDummyStepMeta);
csvInputErrorMeta.setEnabled(true);
csvInputStepMeta.setStepErrorMeta(csvInputErrorMeta);
return csvInputStepMeta;
}
Aggregations