Search in sources :

Example 31 with ValueMetaString

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

the class TableView method getRowWithoutValues.

public RowMetaInterface getRowWithoutValues() {
    RowMetaInterface f = new RowMeta();
    f.addValueMeta(new ValueMetaInteger("#"));
    for (int i = 0; i < columns.length; i++) {
        f.addValueMeta(new ValueMetaString(columns[i].getName()));
    }
    return f;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) Point(org.eclipse.swt.graphics.Point)

Example 32 with ValueMetaString

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

the class StringSearchResult method getResultRowMeta.

public static final RowMetaInterface getResultRowMeta() {
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.TransOrJob")));
    rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.StepDatabaseNotice")));
    rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.String")));
    rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.FieldName")));
    return rowMeta;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 33 with ValueMetaString

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

the class ValueMetaAndData method loadXML.

/**
 * Read the data for this Value from an XML Node
 *
 * @param valnode
 *          The XML Node to read from
 * @return true if all went well, false if something went wrong.
 */
public boolean loadXML(Node valnode) {
    valueMeta = null;
    try {
        String valname = XMLHandler.getTagValue(valnode, "name");
        int valtype = ValueMetaBase.getType(XMLHandler.getTagValue(valnode, "type"));
        String text = XMLHandler.getTagValue(valnode, "text");
        boolean isnull = "Y".equalsIgnoreCase(XMLHandler.getTagValue(valnode, "isnull"));
        int len = Const.toInt(XMLHandler.getTagValue(valnode, "length"), -1);
        int prec = Const.toInt(XMLHandler.getTagValue(valnode, "precision"), -1);
        String mask = XMLHandler.getTagValue(valnode, "mask");
        valueMeta = new ValueMeta(valname, valtype);
        valueData = text;
        valueMeta.setLength(len);
        valueMeta.setPrecision(prec);
        if (mask != null) {
            valueMeta.setConversionMask(mask);
        }
        if (valtype != ValueMetaInterface.TYPE_STRING) {
            ValueMetaInterface originMeta = new ValueMetaString(valname);
            if (valueMeta.isNumeric()) {
                originMeta.setDecimalSymbol(".");
                originMeta.setGroupingSymbol(null);
                originMeta.setCurrencySymbol(null);
            }
            if (valtype == ValueMetaInterface.TYPE_DATE) {
                originMeta.setConversionMask(ValueMetaBase.COMPATIBLE_DATE_FORMAT_PATTERN);
            }
            valueData = Const.trim(text);
            valueData = valueMeta.convertData(originMeta, valueData);
        }
        if (isnull) {
            valueData = null;
        }
    } catch (Exception e) {
        valueData = null;
        return false;
    }
    return true;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleValueException(org.pentaho.di.core.exception.KettleValueException)

Example 34 with ValueMetaString

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

the class ValueMetaTest method testDateString8601.

@Test
public void testDateString8601() throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Kaliningrad"));
    ValueMetaInterface datValueMeta = new ValueMetaString();
    datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000Z'");
    try {
        Date res = datValueMeta.getDate("2011-03-13T02:23:18.000Z");
        Calendar c = Calendar.getInstance();
        c.setTime(res);
        assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
        assertEquals("Day should be 13", 13, c.get(Calendar.DAY_OF_MONTH));
        assertEquals("Year should be 2011", 2011, c.get(Calendar.YEAR));
    } catch (Exception ex) {
        fail("Error converting date." + ex.getMessage());
    }
    TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
    datValueMeta = new ValueMetaString();
    datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000Z'");
    try {
        datValueMeta.getDate("2011-03-13T02:23:18.000Z");
        fail("Expected exception when trying to convert date");
    } catch (Exception ex) {
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Calendar(java.util.Calendar) Date(java.util.Date) KettleException(org.pentaho.di.core.exception.KettleException) Test(org.junit.Test)

Example 35 with ValueMetaString

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

the class ValueMetaTest method testDateStringDL8601.

@Test
public void testDateStringDL8601() throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
    ValueMetaInterface datValueMeta = new ValueMetaString();
    datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000'XXX");
    try {
        Date res = datValueMeta.getDate("2008-03-09T02:34:54.000Z");
        // make sure it's what we expect...
        Calendar c = Calendar.getInstance();
        c.setTime(res);
        assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
        assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
        assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
    } catch (Exception ex) {
        fail("Error converting date." + ex.getMessage());
    }
    datValueMeta = new ValueMetaString();
    datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000'XXX");
    try {
        Date res = datValueMeta.getDate("2008-03-09T02:34:54.000+01:00");
        // make sure it's what we expect...
        Calendar c = Calendar.getInstance();
        c.setTime(res);
        assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
        assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
        assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
    } catch (Exception ex) {
        fail("Error converting date." + ex.getMessage());
    }
    datValueMeta = new ValueMetaString();
    datValueMeta.setConversionMask("yyyy-MM-dd'T'HH-mm-ss'.000'XXX");
    try {
        Date res = datValueMeta.getDate("2008-03-09T02-34-54.000-01:00");
        // make sure it's what we expect...
        Calendar c = Calendar.getInstance();
        c.setTime(res);
        assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
        assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
        assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
    } catch (Exception ex) {
        fail("Error converting date." + ex.getMessage());
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Calendar(java.util.Calendar) Date(java.util.Date) KettleException(org.pentaho.di.core.exception.KettleException) Test(org.junit.Test)

Aggregations

ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)447 RowMeta (org.pentaho.di.core.row.RowMeta)219 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)181 Test (org.junit.Test)179 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)176 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)141 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)86 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)67 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)66 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)57 KettleException (org.pentaho.di.core.exception.KettleException)40 ArrayList (java.util.ArrayList)33 LongObjectId (org.pentaho.di.repository.LongObjectId)29 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)27 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)26 ObjectId (org.pentaho.di.repository.ObjectId)26 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 RowSet (org.pentaho.di.core.RowSet)18 Date (java.util.Date)17 ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)16