Search in sources :

Example 61 with ValueMetaInterface

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

the class GPLoadMeta method analyseImpact.

public void analyseImpact(List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository, IMetaStore metaStore) throws KettleStepException {
    if (prev != null) {
        // Insert dateMask fields : read/write
        for (int i = 0; i < fieldTable.length; i++) {
            ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
            DatabaseImpact ii = new DatabaseImpact(DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(), databaseMeta.getDatabaseName(), transMeta.environmentSubstitute(tableName), fieldTable[i], fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta());
            impact.add(ii);
        }
    }
}
Also used : DatabaseImpact(org.pentaho.di.trans.DatabaseImpact) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 62 with ValueMetaInterface

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

the class GetPreviousRowFieldMeta method getFields.

@Override
public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // Add new field?
    for (int i = 0; i < fieldOutStream.length; i++) {
        if (!Utils.isEmpty(fieldOutStream[i])) {
            int index = inputRowMeta.indexOfValue(fieldInStream[i]);
            if (index >= 0) {
                ValueMetaInterface in = inputRowMeta.getValueMeta(index);
                try {
                    ValueMetaInterface v = ValueMetaFactory.createValueMeta(space.environmentSubstitute(fieldOutStream[i]), in.getType());
                    v.setName(space.environmentSubstitute(fieldOutStream[i]));
                    v.setLength(in.getLength());
                    v.setPrecision(in.getPrecision());
                    v.setConversionMask(in.getConversionMask());
                    v.setOrigin(name);
                    inputRowMeta.addValueMeta(v);
                } catch (Exception e) {
                    throw new KettleStepException(e);
                }
            }
        }
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 63 with ValueMetaInterface

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

the class GetPreviousRowFieldDialog method get.

private void get() {
    try {
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            TableItemInsertListener listener = new TableItemInsertListener() {

                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 64 with ValueMetaInterface

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

the class RowMetaAndData method addValue.

public void addValue(String valueName, int valueType, Object valueData) {
    ValueMetaInterface v;
    try {
        v = ValueMetaFactory.createValueMeta(valueName, valueType);
    } catch (KettlePluginException e) {
        v = new ValueMetaNone(valueName);
    }
    addValue(v, valueData);
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 65 with ValueMetaInterface

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

the class RowMetaAndData method isEmptyValue.

public boolean isEmptyValue(String valueName) throws KettleValueException {
    int idx = rowMeta.indexOfValue(valueName);
    if (idx < 0) {
        throw new KettleValueException("Unknown column '" + valueName + "'");
    }
    ValueMetaInterface metaType = rowMeta.getValueMeta(idx);
    // find by source value type
    switch(metaType.getType()) {
        case ValueMetaInterface.TYPE_STRING:
            return rowMeta.getString(data, idx) == null;
        case ValueMetaInterface.TYPE_BOOLEAN:
            return rowMeta.getBoolean(data, idx) == null;
        case ValueMetaInterface.TYPE_INTEGER:
            return rowMeta.getInteger(data, idx) == null;
        case ValueMetaInterface.TYPE_NUMBER:
            return rowMeta.getNumber(data, idx) == null;
        case ValueMetaInterface.TYPE_BIGNUMBER:
            return rowMeta.getBigNumber(data, idx) == null;
        case ValueMetaInterface.TYPE_BINARY:
            return rowMeta.getBinary(data, idx) == null;
        case ValueMetaInterface.TYPE_DATE:
        case ValueMetaInterface.TYPE_TIMESTAMP:
            return rowMeta.getDate(data, idx) == null;
        case ValueMetaInterface.TYPE_INET:
            return rowMeta.getString(data, idx) == null;
    }
    throw new KettleValueException("Unknown source type: " + metaType.getTypeDesc());
}
Also used : KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)908 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)345 KettleException (org.pentaho.di.core.exception.KettleException)269 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)243 RowMeta (org.pentaho.di.core.row.RowMeta)232 Test (org.junit.Test)212 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)146 KettleStepException (org.pentaho.di.core.exception.KettleStepException)120 ArrayList (java.util.ArrayList)111 TableItem (org.eclipse.swt.widgets.TableItem)78 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)76 KettleValueException (org.pentaho.di.core.exception.KettleValueException)58 FileObject (org.apache.commons.vfs2.FileObject)55 Date (java.util.Date)49 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)48 StepMeta (org.pentaho.di.trans.step.StepMeta)47 Database (org.pentaho.di.core.database.Database)46 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)46 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)44 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43