public String getChecksum() throws KettleStepException { String ck = this.className + this.source; try { byte[] b = MessageDigest.getInstance( "MD5" ).digest( ck.getBytes() ); return Hex.encodeHexString( b ); } catch ( Exception ex ) { // Can't get MD5 hashcode ? throw new KettleStepException( "Unable to obtain checksum of UDJC - " + this.className ); } }
public void getDeleteFields( RowMetaInterface inputRowMeta ) throws KettleStepException { if ( deleteName != null && deleteName.length > 0 ) { // DESELECT values from the stream... for ( int i = 0; i < deleteName.length; i++ ) { try { inputRowMeta.removeValueMeta( deleteName[i] ); } catch ( KettleValueException e ) { throw new KettleStepException( e ); } } } }
private byte[] getBinaryString( String string ) throws KettleStepException { try { if ( data.hasEncoding ) { return string.getBytes( meta.getEncoding() ); } else { return string.getBytes(); } } catch ( Exception e ) { throw new KettleStepException( e ); } }
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( outputIDField ) { if ( outputIDFieldName == null || outputIDFieldName.length() == 0 ) { throw new KettleStepException( "Error while retrieving fields", new Exception( "ID field name is null" ) ); } ValueMetaInterface v = new ValueMetaInteger( outputIDFieldName ); v.setOrigin( name ); row.addValueMeta( v ); } }
@Override public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { if ( output ) { try { dialog.addDataRow( rowMeta, rowMeta.cloneRow( row ) ); } catch ( KettleValueException e ) { throw new KettleStepException( e ); } } }
@Override public void errorRowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { if ( error ) { try { dialog.addDataRow( rowMeta, rowMeta.cloneRow( row ) ); } catch ( KettleValueException e ) { throw new KettleStepException( e ); } } } };
public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( int i = 0; i < this.fieldname.length; i++ ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( this.fieldname[i], type[i], length[i], precision[i] ); inputRowMeta.addValueMeta( v ); } catch ( KettlePluginException e ) { throw new KettleStepException( e ); } } }
@Override public void rowReadEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { if ( input ) { try { dialog.addDataRow( rowMeta, rowMeta.cloneRow( row ) ); } catch ( KettleValueException e ) { throw new KettleStepException( e ); } } }
@Override public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { try { rowsData.add( new RowMetaAndData( rowMeta, rowMeta.cloneRow( row ) ) ); if ( rowsData.size() > PropsUI.getInstance().getDefaultPreviewSize() ) { rowsData.remove( 0 ); } } catch ( Exception e ) { throw new KettleStepException( "Unable to clone row for metadata : " + rowMeta, e ); } } } );
private MqttMessage getMessage( Object[] row ) throws KettleStepException { MqttMessage mqttMessage = new MqttMessage(); try { mqttMessage.setQos( Integer.parseInt( meta.qos ) ); } catch ( NumberFormatException e ) { throw new KettleStepException( getString( PKG, "MQTTProducer.Error.QOS", meta.qos ) ); } mqttMessage.setPayload( getField( row, meta.messageField ) .map( fas -> fas.getBytes( Charsets.UTF_8 ) ) .orElse( null ) ); //allow nulls to pass through return mqttMessage; }
@Override public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { if ( rowsData.size() < PropsUI.getInstance().getDefaultPreviewSize() ) { try { rowsData.add( new RowMetaAndData( rowMeta, rowMeta.cloneRow( row ) ) ); } catch ( Exception e ) { throw new KettleStepException( "Unable to clone row for metadata : " + rowMeta, e ); } } } } );
private void initFieldNumbers( RowMetaInterface outputRowMeta, TextFileField[] outputFields ) throws KettleException { data.fieldnrs = new int[outputFields.length]; for ( int i = 0; i < outputFields.length; i++ ) { data.fieldnrs[i] = outputRowMeta.indexOfValue( outputFields[i].getName() ); if ( data.fieldnrs[i] < 0 ) { throw new KettleStepException( "Field [" + outputFields[i].getName() + "] couldn't be found in the input stream!" ); } } }
@Override public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { try { assertEquals( expectedResult, row[ 2 ] ); } catch ( Exception pe ) { throw new KettleStepException( pe ); } } } );
@Override public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException { try { assertEquals( new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).parse( "2014-01-01 00:00:10" ), row[ 2 ] ); } catch ( ParseException pe ) { throw new KettleStepException( pe ); } } } );
public void getFields( RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( int i = 0; i < this.fieldname.length; i++ ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( fieldname[i], type[i], length[i], precision[i] ); v.setOrigin( origin ); r.addValueMeta( v ); } catch ( KettlePluginException e ) { throw new KettleStepException( e ); } } }
/** * @param row * @param requestBuilder */ private void addSourceFromJsonString( Object[] row, IndexRequestBuilder requestBuilder ) throws KettleStepException { Object jsonString = row[jsonFieldIdx]; if ( jsonString instanceof byte[] ) { requestBuilder.setSource( (byte[]) jsonString, XContentType.JSON ); } else if ( jsonString instanceof String ) { requestBuilder.setSource( (String) jsonString, XContentType.JSON ); } else { throw new KettleStepException( BaseMessages.getString( "ElasticSearchBulk.Error.NoJsonFieldFormat" ) ); } }
@VisibleForTesting void checkRemoteFilenameField( String remoteFilenameFieldName, SFTPPutData data ) throws KettleStepException { remoteFilenameFieldName = environmentSubstitute( remoteFilenameFieldName ); if ( !Utils.isEmpty( remoteFilenameFieldName ) ) { data.indexOfRemoteFilename = getInputRowMeta().indexOfValue( remoteFilenameFieldName ); if ( data.indexOfRemoteFilename == -1 ) { // remote file name field is set, but was not found throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", remoteFilenameFieldName ) ); } } }
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { FileInputList fileList = getTextFileList( space ); if ( fileList.nrOfFiles() == 0 ) { throw new KettleStepException( BaseMessages .getString( PKG, "XBaseInputMeta.Exception.NoFilesFoundToProcess" ) ); } row.addRowMeta( getOutputFields( fileList, name ) ); }
@Override public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { rowMeta.clear(); // No defined output is expected from this step. if ( !Utils.isEmpty( sourceStepName ) ) { for ( MetaInjectOutputField field : sourceOutputFields ) { try { rowMeta.addValueMeta( field.createValueMeta() ); } catch ( KettlePluginException e ) { throw new KettleStepException( "Error creating value meta for output field '" + field.getName() + "'", e ); } } } }
protected void addFieldToRow( RowMetaInterface row, String fieldName, int type, int length, int precision ) throws KettleStepException { if ( !Utils.isEmpty( fieldName ) ) { try { ValueMetaInterface value = ValueMetaFactory.createValueMeta( fieldName, type, length, precision ); value.setOrigin( getParentStepMeta().getName() ); row.addValueMeta( value ); } catch ( KettlePluginException e ) { throw new KettleStepException( BaseMessages.getString( PKG, "TransExecutorMeta.ValueMetaInterfaceCreation", fieldName ), e ); } } }