Java Code Examples for org.pentaho.di.core.row.ValueMetaInterface#TYPE_SERIALIZABLE
The following examples show how to use
org.pentaho.di.core.row.ValueMetaInterface#TYPE_SERIALIZABLE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraColumnMetaData.java From learning-hadoop with Apache License 2.0 | 6 votes |
/** * Return the Cassandra column type (internal cassandra class name relative to * org.apache.cassandra.db.marshal) for the given Kettle column. * * @param vm the ValueMetaInterface for the Kettle column * @return the corresponding internal cassandra type. */ public static String getCassandraTypeForValueMeta(ValueMetaInterface vm) { switch (vm.getType()) { case ValueMetaInterface.TYPE_STRING: return "UTF8Type"; case ValueMetaInterface.TYPE_BIGNUMBER: return "DecimalType"; case ValueMetaInterface.TYPE_BOOLEAN: return "BooleanType"; case ValueMetaInterface.TYPE_INTEGER: return "LongType"; case ValueMetaInterface.TYPE_NUMBER: return "DoubleType"; case ValueMetaInterface.TYPE_DATE: return "DateType"; case ValueMetaInterface.TYPE_BINARY: case ValueMetaInterface.TYPE_SERIALIZABLE: return "BytesType"; } return "UTF8Type"; }
Example 2
Source File: CassandraColumnMetaData.java From learning-hadoop with Apache License 2.0 | 6 votes |
/** * Return the Cassandra CQL column/key type for the given Kettle column. We * use this type for CQL create column family statements since, for some * reason, the internal type isn't recognized for the key. Internal types * *are* recognized for column definitions. The CQL reference guide states * that fully qualified (or relative to org.apache.cassandra.db.marshal) class * names can be used instead of CQL types - however, using these when defining * the key type always results in BytesType getting set for the key for some * reason. * * @param vm the ValueMetaInterface for the Kettle column * @return the corresponding CQL type */ public static String getCQLTypeForValueMeta(ValueMetaInterface vm) { switch (vm.getType()) { case ValueMetaInterface.TYPE_STRING: return "varchar"; case ValueMetaInterface.TYPE_BIGNUMBER: return "decimal"; case ValueMetaInterface.TYPE_BOOLEAN: return "boolean"; case ValueMetaInterface.TYPE_INTEGER: return "bigint"; case ValueMetaInterface.TYPE_NUMBER: return "double"; case ValueMetaInterface.TYPE_DATE: return "timestamp"; case ValueMetaInterface.TYPE_BINARY: case ValueMetaInterface.TYPE_SERIALIZABLE: return "blob"; } return "blob"; }
Example 3
Source File: ValueMetaConverter.java From pentaho-kettle with Apache License 2.0 | 6 votes |
protected Object convertFromSerializableMetaInterface( int targetValueMetaType, Object value ) throws ValueMetaConversionException { if ( value == null ) { return null; } if ( !( value instanceof Serializable ) ) { handleConversionError( "Error. Expecting value of type Serializable. actual value type = '" + value.getClass() + "'. value = '" + value + "'." ); } try { switch ( targetValueMetaType ) { case ValueMetaInterface.TYPE_SERIALIZABLE: return value; default: throwBadConversionCombination( ValueMetaInterface.TYPE_SERIALIZABLE, targetValueMetaType, value ); } } catch ( Exception e ) { throwErroredConversion( ValueMetaInterface.TYPE_SERIALIZABLE, targetValueMetaType, value, e ); } return null; }
Example 4
Source File: CiviStep.java From civicrm-data-integration with GNU General Public License v3.0 | 5 votes |
protected Object getObjectValue(String field, String object) { try { if (object == null || object.equals("")) { return null; } CiviField cf = ((CiviMeta) civiMeta).getCiviCrmListingFields().get(field); int metaType = ValueMetaInterface.TYPE_STRING; if (cf != null) metaType = cf.getMetaInterfaceType(); switch (metaType) { case ValueMetaInterface.TYPE_INTEGER: return Long.parseLong(object); case ValueMetaInterface.TYPE_STRING: return object.toString(); case ValueMetaInterface.TYPE_NUMBER: return Double.parseDouble(object); case ValueMetaInterface.TYPE_DATE: SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); return formatter.parse(object); case ValueMetaInterface.TYPE_BIGNUMBER: return new BigDecimal(object.toString()); case ValueMetaInterface.TYPE_BOOLEAN: return Boolean.parseBoolean(object); case ValueMetaInterface.TYPE_BINARY: throw new KettleValueException(toString() + " : I don't know how to convert binary values to integers."); case ValueMetaInterface.TYPE_SERIALIZABLE: throw new KettleValueException(toString() + " : I don't know how to convert serializable values to integers."); default: throw new KettleValueException(toString() + " : Unknown type " + metaType + " specified."); } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 5
Source File: ValueMetaConverter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public Object convertFromSourceToTargetDataType( int sourceValueMetaType, int targetValueMetaType, Object value ) throws ValueMetaConversionException { if ( value == null ) { return null; } switch ( sourceValueMetaType ) { case ValueMetaInterface.TYPE_INET: return convertFromInetMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_STRING: return convertFromStringMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_INTEGER: return convertFromIntegerMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_NUMBER: return convertFromNumberMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_BIGNUMBER: return convertFromBigNumberMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_TIMESTAMP: return convertFromTimestampMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_DATE: return convertFromDateMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_BOOLEAN: return convertFromBooleanMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_BINARY: return convertFromBinaryMetaInterface( targetValueMetaType, value ); case ValueMetaInterface.TYPE_SERIALIZABLE: return convertFromSerializableMetaInterface( targetValueMetaType, value ); default: throwBadConversionCombination( sourceValueMetaType, targetValueMetaType, value ); } return null; }
Example 6
Source File: ValueMetaFactory.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static String[] getValueMetaNames() { List<String> strings = new ArrayList<String>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { int id = Integer.valueOf( plugin.getIds()[0] ); if ( id > 0 && id != ValueMetaInterface.TYPE_SERIALIZABLE ) { strings.add( plugin.getName() ); } } return strings.toArray( new String[strings.size()] ); }
Example 7
Source File: FieldHelper.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public static String getGetSignature( String accessor, ValueMetaInterface v ) { StringBuilder sb = new StringBuilder(); switch ( v.getType() ) { case ValueMetaInterface.TYPE_BIGNUMBER: sb.append( "BigDecimal " ); break; case ValueMetaInterface.TYPE_BINARY: sb.append( "byte[] " ); break; case ValueMetaInterface.TYPE_BOOLEAN: sb.append( "Boolean " ); break; case ValueMetaInterface.TYPE_DATE: sb.append( "Date " ); break; case ValueMetaInterface.TYPE_INTEGER: sb.append( "Long " ); break; case ValueMetaInterface.TYPE_NUMBER: sb.append( "Double " ); break; case ValueMetaInterface.TYPE_STRING: sb.append( "String " ); break; case ValueMetaInterface.TYPE_INET: sb.append( "InetAddress " ); break; case ValueMetaInterface.TYPE_TIMESTAMP: sb.append( "Timestamp " ); break; case ValueMetaInterface.TYPE_SERIALIZABLE: default: sb.append( "Object " ); break; } if ( validJavaIdentifier.matcher( v.getName() ).matches() ) { sb.append( v.getName() ); } else { sb.append( "value" ); } String name = getNativeDataTypeSimpleName( v ); sb .append( " = " ).append( accessor ).append( ".get" ).append( "-".equals( name ) ? "Object" : name ) .append( "(r);" ); return sb.toString(); }
Example 8
Source File: ValueMetaSerializable.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public ValueMetaSerializable( String name ) { super( name, ValueMetaInterface.TYPE_SERIALIZABLE ); }
Example 9
Source File: ValueMetaBase.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Clones the data. Normally, we don't have to do anything here, but just for arguments and safety, we do a little * extra work in case of binary blobs and Date objects. We should write a programmers manual later on to specify in * all clarity that "we always overwrite/replace values in the Object[] data rows, we never modify them" . * * @return a cloned data object if needed */ @Override public Object cloneValueData( Object object ) throws KettleValueException { if ( object == null ) { return null; } if ( storageType == STORAGE_TYPE_NORMAL ) { switch ( getType() ) { case ValueMetaInterface.TYPE_STRING: case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BOOLEAN: case ValueMetaInterface.TYPE_BIGNUMBER: // primitive data types: we can only // overwrite these, not change them return object; case ValueMetaInterface.TYPE_DATE: return new Date( ( (Date) object ).getTime() ); // just to make sure: very // inexpensive too. case ValueMetaInterface.TYPE_BINARY: byte[] origin = (byte[]) object; byte[] target = new byte[origin.length]; System.arraycopy( origin, 0, target, 0, origin.length ); return target; case ValueMetaInterface.TYPE_SERIALIZABLE: // Let's not create a copy but simply return the same value. // return object; default: throw new KettleValueException( toString() + ": unable to make copy of value type: " + getType() ); } } else { return object; } }
Example 10
Source File: SalesforceInputMetaInjectionTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Test public void test() throws Exception { check( "SALESFORCE_URL", () -> meta.getTargetURL() ); check( "SALESFORCE_USERNAME", () -> meta.getUsername() ); check( "SALESFORCE_PASSWORD", () -> meta.getPassword() ); check( "TIME_OUT", () -> meta.getTimeout() ); check( "USE_COMPRESSION", () -> meta.isCompression() ); check( "MODULE", () -> meta.getModule() ); check( "INCLUDE_SQL_IN_OUTPUT", () -> meta.includeSQL() ); check( "SQL_FIELDNAME", () -> meta.getSQLField() ); check( "INCLUDE_TIMESTAMP_IN_OUTPUT", () -> meta.includeTimestamp() ); check( "TIMESTAMP_FIELDNAME", () -> meta.getTimestampField() ); check( "INCLUDE_URL_IN_OUTPUT", () -> meta.includeTargetURL() ); check( "URL_FIELDNAME", () -> meta.getTargetURLField() ); check( "INCLUDE_MODULE_IN_OUTPUT", () -> meta.includeModule() ); check( "MODULE_FIELDNAME", () -> meta.getModuleField() ); check( "INCLUDE_DELETION_DATE_IN_OUTPUT", () -> meta.includeDeletionDate() ); check( "DELETION_DATE_FIELDNAME", () -> meta.getDeletionDateField() ); check( "INCLUDE_ROWNUM_IN_OUTPUT", () -> meta.includeRowNumber() ); check( "ROWNUM_FIELDNAME", () -> meta.getRowNumberField() ); check( "QUERY_CONDITION", () -> meta.getCondition() ); check( "LIMIT", () -> meta.getRowLimit() ); check( "USE_SPECIFIED_QUERY", () -> meta.isSpecifyQuery() ); check( "SPECIFY_QUERY", () -> meta.getQuery() ); check( "END_DATE", () -> meta.getReadTo() ); check( "START_DATE", () -> meta.getReadFrom() ); check( "QUERY_ALL", () -> meta.isQueryAll() ); checkStringToInt( "RETRIEVE", () -> meta.getRecordsFilter(), SalesforceConnectionUtils.recordsFilterCode, new int[]{ RECORDS_FILTER_ALL, RECORDS_FILTER_UPDATED, RECORDS_FILTER_DELETED } ); check( "NAME", () -> meta.getInputFields()[0].getName() ); check( "FIELD", () -> meta.getInputFields()[0].getField() ); check( "LENGTH", () -> meta.getInputFields()[0].getLength() ); check( "FORMAT", () -> meta.getInputFields()[0].getFormat() ); check( "PRECISION", () -> meta.getInputFields()[0].getPrecision() ); check( "CURRENCY", () -> meta.getInputFields()[0].getCurrencySymbol() ); check( "DECIMAL", () -> meta.getInputFields()[0].getDecimalSymbol() ); check( "GROUP", () -> meta.getInputFields()[0].getGroupSymbol() ); check( "REPEAT", () -> meta.getInputFields()[0].isRepeated() ); check( "ISIDLOOKUP", () -> meta.getInputFields()[0].isIdLookup() ); checkStringToInt( "TRIM_TYPE", () -> meta.getInputFields()[0].getTrimType(), SalesforceInputField.trimTypeCode, new int[]{ TYPE_TRIM_NONE, TYPE_TRIM_LEFT, TYPE_TRIM_RIGHT, TYPE_TRIM_BOTH }); int[] types = new int[]{ ValueMetaInterface.TYPE_NONE, ValueMetaInterface.TYPE_NUMBER, ValueMetaInterface.TYPE_STRING, ValueMetaInterface.TYPE_DATE, ValueMetaInterface.TYPE_BOOLEAN, ValueMetaInterface.TYPE_INTEGER, ValueMetaInterface.TYPE_BIGNUMBER, ValueMetaInterface.TYPE_SERIALIZABLE, ValueMetaInterface.TYPE_BINARY, ValueMetaInterface.TYPE_TIMESTAMP, ValueMetaInterface.TYPE_INET }; ValueMetaString valueMeta = new ValueMetaString(); checkStringToInt("TYPE", () -> meta.getInputFields()[0].getType(), valueMeta.typeCodes, types ); }