Search in sources :

Example 61 with ValueMetaDate

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

the class GetRepositoryNamesMeta method getFields.

public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // the directory and name of the object
    // 
    ValueMetaInterface object = new ValueMetaString("object");
    object.setLength(500);
    object.setPrecision(-1);
    object.setOrigin(origin);
    row.addValueMeta(object);
    // the directory
    // 
    ValueMetaInterface directory = new ValueMetaString("directory");
    directory.setLength(500);
    directory.setPrecision(-1);
    directory.setOrigin(origin);
    row.addValueMeta(directory);
    // the name
    // 
    ValueMetaInterface name = new ValueMetaString("name");
    name.setLength(500);
    name.setPrecision(-1);
    name.setOrigin(origin);
    row.addValueMeta(name);
    // the object type
    // 
    ValueMetaInterface objectType = new ValueMetaString("object_type");
    objectType.setLength(500);
    objectType.setPrecision(-1);
    objectType.setOrigin(origin);
    row.addValueMeta(objectType);
    // object_id
    // 
    ValueMetaInterface objectId = new ValueMetaString("object_id");
    object.setLength(500);
    object.setPrecision(-1);
    objectId.setOrigin(origin);
    row.addValueMeta(objectId);
    // modified by
    // 
    ValueMetaInterface modifiedBy = new ValueMetaString("modified_by");
    object.setLength(500);
    object.setPrecision(-1);
    modifiedBy.setOrigin(origin);
    row.addValueMeta(modifiedBy);
    // modified date
    // 
    ValueMetaInterface modifiedDate = new ValueMetaDate("modified_date");
    modifiedDate.setOrigin(origin);
    row.addValueMeta(modifiedDate);
    // description
    // 
    ValueMetaInterface description = new ValueMetaString("description");
    description.setLength(500);
    description.setPrecision(-1);
    description.setOrigin(origin);
    row.addValueMeta(description);
    if (includeRowNumber) {
        ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
        v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
        v.setOrigin(origin);
        row.addValueMeta(v);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 62 with ValueMetaDate

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

the class GetSubFoldersMeta method getFields.

public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // the folderName
    ValueMetaInterface folderName = new ValueMetaString("folderName");
    folderName.setLength(500);
    folderName.setPrecision(-1);
    folderName.setOrigin(name);
    row.addValueMeta(folderName);
    // the short folderName
    ValueMetaInterface short_folderName = new ValueMetaString("short_folderName");
    short_folderName.setLength(500);
    short_folderName.setPrecision(-1);
    short_folderName.setOrigin(name);
    row.addValueMeta(short_folderName);
    // the path
    ValueMetaInterface path = new ValueMetaString("path");
    path.setLength(500);
    path.setPrecision(-1);
    path.setOrigin(name);
    row.addValueMeta(path);
    // the ishidden
    ValueMetaInterface ishidden = new ValueMetaBoolean("ishidden");
    ishidden.setOrigin(name);
    row.addValueMeta(ishidden);
    // the isreadable
    ValueMetaInterface isreadable = new ValueMetaBoolean("isreadable");
    isreadable.setOrigin(name);
    row.addValueMeta(isreadable);
    // the iswriteable
    ValueMetaInterface iswriteable = new ValueMetaBoolean("iswriteable");
    iswriteable.setOrigin(name);
    row.addValueMeta(iswriteable);
    // the lastmodifiedtime
    ValueMetaInterface lastmodifiedtime = new ValueMetaDate("lastmodifiedtime");
    lastmodifiedtime.setOrigin(name);
    row.addValueMeta(lastmodifiedtime);
    // the uri
    ValueMetaInterface uri = new ValueMetaString("uri");
    uri.setOrigin(name);
    row.addValueMeta(uri);
    // the rooturi
    ValueMetaInterface rooturi = new ValueMetaString("rooturi");
    rooturi.setOrigin(name);
    row.addValueMeta(rooturi);
    // childrens
    ValueMetaInterface childrens = new ValueMetaInteger(space.environmentSubstitute("childrens"));
    childrens.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
    childrens.setOrigin(name);
    row.addValueMeta(childrens);
    if (includeRowNumber) {
        ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
        v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
        v.setOrigin(name);
        row.addValueMeta(v);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 63 with ValueMetaDate

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

the class Denormaliser method getConversionMeta.

/**
 * Get the metadata used for conversion to date format See related PDI-4019
 *
 * @param mask
 * @return
 */
private ValueMetaInterface getConversionMeta(String mask) {
    ValueMetaInterface meta = null;
    if (!Utils.isEmpty(mask)) {
        meta = conversionMetaCache.get(mask);
        if (meta == null) {
            meta = new ValueMetaDate();
            meta.setConversionMask(mask);
            conversionMetaCache.put(mask, meta);
        }
    }
    return meta;
}
Also used : ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 64 with ValueMetaDate

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

the class Database method getQueryFieldsFromDatabaseMetaData.

public RowMetaInterface getQueryFieldsFromDatabaseMetaData() throws Exception {
    ResultSet columns = connection.getMetaData().getColumns("", "", databaseMeta.getName(), "");
    RowMetaInterface rowMeta = new RowMeta();
    while (columns.next()) {
        ValueMetaInterface valueMeta = null;
        String name = columns.getString("COLUMN_NAME");
        String type = columns.getString("SOURCE_DATA_TYPE");
        int size = columns.getInt("COLUMN_SIZE");
        if (type.equals("Integer") || type.equals("Long")) {
            valueMeta = new ValueMetaInteger();
        } else if (type.equals("BigDecimal") || type.equals("BigNumber")) {
            valueMeta = new ValueMetaBigNumber();
        } else if (type.equals("Double") || type.equals("Number")) {
            valueMeta = new ValueMetaNumber();
        } else if (type.equals("String")) {
            valueMeta = new ValueMetaString();
        } else if (type.equals("Date")) {
            valueMeta = new ValueMetaDate();
        } else if (type.equals("Boolean")) {
            valueMeta = new ValueMetaBoolean();
        } else if (type.equals("Binary")) {
            valueMeta = new ValueMetaBinary();
        } else if (type.equals("Timestamp")) {
            valueMeta = new ValueMetaTimestamp();
        } else if (type.equals("Internet Address")) {
            valueMeta = new ValueMetaInternetAddress();
        }
        if (valueMeta != null) {
            valueMeta.setName(name);
            valueMeta.setComments(name);
            valueMeta.setLength(size);
            valueMeta.setOriginalColumnTypeName(type);
            valueMeta.setConversionMask(columns.getString("SOURCE_MASK"));
            valueMeta.setDecimalSymbol(columns.getString("SOURCE_DECIMAL_SYMBOL"));
            valueMeta.setGroupingSymbol(columns.getString("SOURCE_GROUPING_SYMBOL"));
            valueMeta.setCurrencySymbol(columns.getString("SOURCE_CURRENCY_SYMBOL"));
            rowMeta.addValueMeta(valueMeta);
        } else {
            log.logBasic("Database.getQueryFields() ValueMetaInterface mapping not resolved for the column " + name);
            rowMeta = null;
            break;
        }
    }
    if (rowMeta != null && !rowMeta.isEmpty()) {
        return rowMeta;
    } else {
        throw new Exception("Error in Database.getQueryFields()");
    }
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Savepoint(java.sql.Savepoint) KettleValueException(org.pentaho.di.core.exception.KettleValueException) BatchUpdateException(java.sql.BatchUpdateException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) KettleDatabaseBatchException(org.pentaho.di.core.exception.KettleDatabaseBatchException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ResultSet(java.sql.ResultSet) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 65 with ValueMetaDate

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

the class Database method getParameterMetaData.

public RowMetaInterface getParameterMetaData(PreparedStatement ps) {
    RowMetaInterface par = new RowMeta();
    try {
        ParameterMetaData pmd = ps.getParameterMetaData();
        for (int i = 1; i <= pmd.getParameterCount(); i++) {
            String name = "par" + i;
            int sqltype = pmd.getParameterType(i);
            int length = pmd.getPrecision(i);
            int precision = pmd.getScale(i);
            ValueMetaInterface val;
            switch(sqltype) {
                case java.sql.Types.CHAR:
                case java.sql.Types.VARCHAR:
                    val = new ValueMetaString(name);
                    break;
                case java.sql.Types.BIGINT:
                case java.sql.Types.INTEGER:
                case java.sql.Types.NUMERIC:
                case java.sql.Types.SMALLINT:
                case java.sql.Types.TINYINT:
                    val = new ValueMetaInteger(name);
                    break;
                case java.sql.Types.DECIMAL:
                case java.sql.Types.DOUBLE:
                case java.sql.Types.FLOAT:
                case java.sql.Types.REAL:
                    val = new ValueMetaNumber(name);
                    break;
                case java.sql.Types.DATE:
                case java.sql.Types.TIME:
                case java.sql.Types.TIMESTAMP:
                    val = new ValueMetaDate(name);
                    break;
                case java.sql.Types.BOOLEAN:
                case java.sql.Types.BIT:
                    val = new ValueMetaBoolean(name);
                    break;
                default:
                    val = new ValueMetaNone(name);
                    break;
            }
            if (val.isNumeric() && (length > 18 || precision > 18)) {
                val = new ValueMetaBigNumber(name);
            }
            par.addValueMeta(val);
        }
    } catch (AbstractMethodError e) {
        // Oops: probably the database or JDBC doesn't support it.
        return null;
    } catch (SQLException e) {
        return null;
    } catch (Exception e) {
        return null;
    }
    return par;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) SQLException(java.sql.SQLException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Savepoint(java.sql.Savepoint) KettleValueException(org.pentaho.di.core.exception.KettleValueException) BatchUpdateException(java.sql.BatchUpdateException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) KettleDatabaseBatchException(org.pentaho.di.core.exception.KettleDatabaseBatchException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ParameterMetaData(java.sql.ParameterMetaData)

Aggregations

ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)104 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)63 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)59 Test (org.junit.Test)50 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)44 RowMeta (org.pentaho.di.core.row.RowMeta)43 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)34 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)33 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)25 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)23 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 Calendar (java.util.Calendar)17 Date (java.util.Date)17 KettleException (org.pentaho.di.core.exception.KettleException)15 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)15 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)14 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)13 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)10 KettleStepException (org.pentaho.di.core.exception.KettleStepException)10 SQLException (java.sql.SQLException)8