Search in sources :

Example 91 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class TableView method setFilter.

// Filtering...
public void setFilter() {
    if (condition == null) {
        condition = new Condition();
    }
    RowMetaInterface f = getRowWithoutValues();
    EnterConditionDialog ecd = new EnterConditionDialog(parent.getShell(), SWT.NONE, f, condition);
    Condition cond = ecd.open();
    if (cond != null) {
        ArrayList<Integer> tokeep = new ArrayList<Integer>();
        // Apply the condition to the TableView...
        int nr = table.getItemCount();
        for (int i = nr - 1; i >= 0; i--) {
            RowMetaAndData r = getRow(i);
            boolean keep = cond.evaluate(r.getRowMeta(), r.getData());
            if (keep) {
                tokeep.add(Integer.valueOf(i));
            }
        }
        int[] sels = new int[tokeep.size()];
        for (int i = 0; i < sels.length; i++) {
            sels[i] = (tokeep.get(i)).intValue();
        }
        table.setSelection(sels);
    }
}
Also used : Condition(org.pentaho.di.core.Condition) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) EnterConditionDialog(org.pentaho.di.ui.core.dialog.EnterConditionDialog) Point(org.eclipse.swt.graphics.Point)

Example 92 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class TableView method getRow.

public RowMetaAndData getRow(int nr) {
    TableItem ti = table.getItem(nr);
    RowMetaInterface rowMeta = getRowWithoutValues();
    Object[] rowData = new Object[rowMeta.size()];
    rowData[0] = new Long(nr);
    for (int i = 1; i < rowMeta.size(); i++) {
        rowData[i] = ti.getText(i);
    }
    return new RowMetaAndData(rowMeta, rowData);
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) TableItem(org.eclipse.swt.widgets.TableItem) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Point(org.eclipse.swt.graphics.Point)

Example 93 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class StepLogTable method getLogRecord.

/**
 * This method calculates all the values that are required
 *
 * @param id
 *          the id to use or -1 if no id is needed
 * @param status
 *          the log status to use
 */
public RowMetaAndData getLogRecord(LogStatus status, Object subject, Object parent) {
    if (subject == null || subject instanceof StepMetaDataCombi) {
        StepMetaDataCombi combi = (StepMetaDataCombi) subject;
        RowMetaAndData row = new RowMetaAndData();
        for (LogTableField field : fields) {
            if (field.isEnabled()) {
                Object value = null;
                if (subject != null) {
                    switch(ID.valueOf(field.getId())) {
                        case ID_BATCH:
                            value = new Long(combi.step.getTrans().getBatchId());
                            break;
                        case CHANNEL_ID:
                            value = combi.step.getLogChannel().getLogChannelId();
                            break;
                        case LOG_DATE:
                            value = new Date();
                            break;
                        case TRANSNAME:
                            value = combi.step.getTrans().getName();
                            break;
                        case STEPNAME:
                            value = combi.stepname;
                            break;
                        case STEP_COPY:
                            value = new Long(combi.copy);
                            break;
                        case LINES_READ:
                            value = new Long(combi.step.getLinesRead());
                            break;
                        case LINES_WRITTEN:
                            value = new Long(combi.step.getLinesWritten());
                            break;
                        case LINES_UPDATED:
                            value = new Long(combi.step.getLinesUpdated());
                            break;
                        case LINES_INPUT:
                            value = new Long(combi.step.getLinesInput());
                            break;
                        case LINES_OUTPUT:
                            value = new Long(combi.step.getLinesOutput());
                            break;
                        case LINES_REJECTED:
                            value = new Long(combi.step.getLinesRejected());
                            break;
                        case ERRORS:
                            value = new Long(combi.step.getErrors());
                            break;
                        case LOG_FIELD:
                            value = getLogBuffer(combi.step, combi.step.getLogChannel().getLogChannelId(), status, null);
                            break;
                        default:
                            break;
                    }
                }
                row.addValue(field.getFieldName(), field.getDataType(), value);
                row.getRowMeta().getValueMeta(row.size() - 1).setLength(field.getLength());
            }
        }
        return row;
    } else {
        return null;
    }
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) Date(java.util.Date)

Example 94 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class TransLogTable method getLogRecord.

/**
 * This method calculates all the values that are required
 *
 * @param id
 *          the id to use or -1 if no id is needed
 * @param status
 *          the log status to use
 * @param subject
 *          the subject to query, in this case a Trans object
 */
public RowMetaAndData getLogRecord(LogStatus status, Object subject, Object parent) {
    if (subject == null || subject instanceof Trans) {
        Trans trans = (Trans) subject;
        Result result = null;
        if (trans != null) {
            result = trans.getResult();
        }
        RowMetaAndData row = new RowMetaAndData();
        for (LogTableField field : fields) {
            if (field.isEnabled()) {
                Object value = null;
                if (trans != null) {
                    switch(ID.valueOf(field.getId())) {
                        case ID_BATCH:
                            value = new Long(trans.getBatchId());
                            break;
                        case CHANNEL_ID:
                            value = trans.getLogChannelId();
                            break;
                        case TRANSNAME:
                            value = trans.getName();
                            break;
                        case STATUS:
                            value = status.getStatus();
                            break;
                        case LINES_READ:
                            value = new Long(result.getNrLinesRead());
                            break;
                        case LINES_WRITTEN:
                            value = new Long(result.getNrLinesWritten());
                            break;
                        case LINES_INPUT:
                            value = new Long(result.getNrLinesInput());
                            break;
                        case LINES_OUTPUT:
                            value = new Long(result.getNrLinesOutput());
                            break;
                        case LINES_UPDATED:
                            value = new Long(result.getNrLinesUpdated());
                            break;
                        case LINES_REJECTED:
                            value = new Long(result.getNrLinesRejected());
                            break;
                        case ERRORS:
                            value = new Long(result.getNrErrors());
                            break;
                        case STARTDATE:
                            value = trans.getStartDate();
                            break;
                        case LOGDATE:
                            value = trans.getLogDate();
                            break;
                        case ENDDATE:
                            value = trans.getEndDate();
                            break;
                        case DEPDATE:
                            value = trans.getDepDate();
                            break;
                        case REPLAYDATE:
                            value = trans.getCurrentDate();
                            break;
                        case LOG_FIELD:
                            value = getLogBuffer(trans, trans.getLogChannelId(), status, logSizeLimit);
                            break;
                        case EXECUTING_SERVER:
                            value = trans.getExecutingServer();
                            break;
                        case EXECUTING_USER:
                            value = trans.getExecutingUser();
                            break;
                        case CLIENT:
                            value = KettleClientEnvironment.getInstance().getClient() != null ? KettleClientEnvironment.getInstance().getClient().toString() : "unknown";
                            break;
                        default:
                            break;
                    }
                }
                row.addValue(field.getFieldName(), field.getDataType(), value);
                row.getRowMeta().getValueMeta(row.size() - 1).setLength(field.getLength());
            }
        }
        return row;
    } else {
        return null;
    }
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) Trans(org.pentaho.di.trans.Trans) Result(org.pentaho.di.core.Result)

Example 95 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class DatabaseConnectionPoolParameterTest method testGetRowList.

@Test
public void testGetRowList() {
    List<RowMetaAndData> result = DatabaseConnectionPoolParameter.getRowList(BaseDatabaseMeta.poolingParameters, "myTitleParameter", "myTitleDefaultValue", "myTitleDescription");
    assertNotNull(result);
    for (RowMetaAndData rmd : result) {
        assertEquals(3, rmd.getRowMeta().size());
        assertEquals("myTitleParameter", rmd.getRowMeta().getValueMeta(0).getName());
        assertEquals(ValueMetaInterface.TYPE_STRING, rmd.getRowMeta().getValueMeta(0).getType());
        assertEquals("myTitleDefaultValue", rmd.getRowMeta().getValueMeta(1).getName());
        assertEquals(ValueMetaInterface.TYPE_STRING, rmd.getRowMeta().getValueMeta(1).getType());
        assertEquals("myTitleDescription", rmd.getRowMeta().getValueMeta(2).getName());
        assertEquals(ValueMetaInterface.TYPE_STRING, rmd.getRowMeta().getValueMeta(2).getType());
    }
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) Test(org.junit.Test)

Aggregations

RowMetaAndData (org.pentaho.di.core.RowMetaAndData)563 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)225 ArrayList (java.util.ArrayList)172 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)145 TransMeta (org.pentaho.di.trans.TransMeta)116 Test (org.junit.Test)108 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)94 KettleException (org.pentaho.di.core.exception.KettleException)89 StepMeta (org.pentaho.di.trans.step.StepMeta)80 LongObjectId (org.pentaho.di.repository.LongObjectId)75 StepInterface (org.pentaho.di.trans.step.StepInterface)75 RowStepCollector (org.pentaho.di.trans.RowStepCollector)73 Trans (org.pentaho.di.trans.Trans)73 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)71 TransHopMeta (org.pentaho.di.trans.TransHopMeta)71 KettleValueException (org.pentaho.di.core.exception.KettleValueException)58 RowProducer (org.pentaho.di.trans.RowProducer)56 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)54 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)53 RowMeta (org.pentaho.di.core.row.RowMeta)51