Search in sources :

Example 11 with StepErrorMeta

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();
}
Also used : StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta)

Example 12 with StepErrorMeta

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();
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) TransMeta(org.pentaho.di.trans.TransMeta) StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) List(java.util.List) Document(org.pentaho.ui.xul.dom.Document) StepMeta(org.pentaho.di.trans.step.StepMeta) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Test(org.junit.Test)

Example 13 with StepErrorMeta

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();
}
Also used : StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 14 with StepErrorMeta

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;
}
Also used : StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta) FileTransformStats(org.pentaho.platform.dataaccess.datasource.wizard.sources.csv.FileTransformStats)

Example 15 with StepErrorMeta

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;
}
Also used : CsvInputMeta(org.pentaho.di.trans.steps.csvinput.CsvInputMeta) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) ColumnInfo(org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo) StepMeta(org.pentaho.di.trans.step.StepMeta) CsvFileInfo(org.pentaho.platform.dataaccess.datasource.wizard.models.CsvFileInfo) File(java.io.File) FileTransformStats(org.pentaho.platform.dataaccess.datasource.wizard.sources.csv.FileTransformStats)

Aggregations

StepErrorMeta (org.pentaho.di.trans.step.StepErrorMeta)27 StepMeta (org.pentaho.di.trans.step.StepMeta)22 TransHopMeta (org.pentaho.di.trans.TransHopMeta)10 Test (org.junit.Test)8 Point (org.pentaho.di.core.gui.Point)8 TransMeta (org.pentaho.di.trans.TransMeta)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)7 NotePadMeta (org.pentaho.di.core.NotePadMeta)6 KettleException (org.pentaho.di.core.exception.KettleException)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)5 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)5 StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)4 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 StepInterface (org.pentaho.di.trans.step.StepInterface)3 ArrayList (java.util.ArrayList)2 Matchers.anyString (org.mockito.Matchers.anyString)2