Java Code Examples for org.pentaho.di.core.util.StringUtil#EMPTY_STRING
The following examples show how to use
org.pentaho.di.core.util.StringUtil#EMPTY_STRING .
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: ReplaceString.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private String getResolvedReplaceByString( int index, Object[] row ) throws KettleException { if ( data.setEmptyString[index] ) { // return empty string rather than null value return StringUtil.EMPTY_STRING; } // if there is something in the original replaceByString, then use it. if ( data.replaceFieldIndex[index] == -1 ) { return data.replaceByString[index]; } return getInputRowMeta().getString( row, data.replaceFieldIndex[index] ); }
Example 2
Source File: IfNull.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void replaceNull( Object[] row, ValueMetaInterface sourceValueMeta, int i, String realReplaceByValue, String realconversionMask, boolean setEmptystring ) throws Exception { if ( setEmptystring ) { row[i] = StringUtil.EMPTY_STRING; } else { // DO CONVERSION OF THE DEFAULT VALUE ... // Entered by user ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); if ( !Utils.isEmpty( realconversionMask ) ) { sourceValueMeta.setConversionMask( realconversionMask ); } row[i] = targetValueMeta.convertData( sourceValueMeta, realReplaceByValue ); } }
Example 3
Source File: ExcelInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void setDefault() { startsWithHeader = true; ignoreEmptyRows = true; rowNumberField = StringUtil.EMPTY_STRING; sheetRowNumberField = StringUtil.EMPTY_STRING; isaddresult = true; int nrfiles = 0; int nrfields = 0; int nrsheets = 0; allocate( nrfiles, nrsheets, nrfields ); rowLimit = 0L; strictTypes = false; errorIgnored = false; errorLineSkipped = false; warningFilesDestinationDirectory = null; warningFilesExtension = "warning"; errorFilesDestinationDirectory = null; errorFilesExtension = "error"; lineNumberFilesDestinationDirectory = null; lineNumberFilesExtension = "line"; spreadSheetType = SpreadSheetType.JXL; // default. }
Example 4
Source File: TextFileInputMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void whenExportingResourcesWeGetFileObjectsOnlyFromFilesWithNotNullAndNotEmptyFileNames() throws Exception { inputMeta.inputFiles = new BaseFileInputFiles(); inputMeta.inputFiles.fileName = new String[] { FILE_NAME_NULL, FILE_NAME_EMPTY, FILE_NAME_VALID_PATH }; inputMeta.inputFiles.fileMask = new String[] { StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING }; inputMeta.exportResources( variableSpace, null, mock( ResourceNamingInterface.class ), null, null ); verify( inputMeta ).getFileObject( FILE_NAME_VALID_PATH, variableSpace ); verify( inputMeta, never() ).getFileObject( FILE_NAME_NULL, variableSpace ); verify( inputMeta, never() ).getFileObject( FILE_NAME_EMPTY, variableSpace ); }
Example 5
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void setDefault() { super.setDefault(); // overwrite header super.setHeaderEnabled( false ); // PDI-18028: ConcatFields doesn't need or use the 'fileName' field! super.setFileName( StringUtil.EMPTY_STRING ); super.setFileNameInField( false ); // set default for new properties specific to the concat fields targetFieldName = StringUtil.EMPTY_STRING; targetFieldLength = 0; removeSelectedFields = false; }
Example 6
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { super.loadXML( stepnode, databases, metaStore ); targetFieldName = XMLHandler.getTagValue( stepnode, ConcatFieldsNodeNameSpace, "targetFieldName" ); targetFieldLength = Const.toInt( XMLHandler.getTagValue( stepnode, ConcatFieldsNodeNameSpace, "targetFieldLength" ), 0 ); removeSelectedFields = "Y" .equalsIgnoreCase( XMLHandler .getTagValue( stepnode, ConcatFieldsNodeNameSpace, "removeSelectedFields" ) ); // PDI-18028: Avoid fileName handling! super.setFileName( StringUtil.EMPTY_STRING ); super.setFileNameInField( false ); }
Example 7
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public String getXML() { // PDI-18028: Avoid fileName handling! super.setFileName( StringUtil.EMPTY_STRING ); super.setFileNameInField( false ); String retval = super.getXML(); retval = retval + " <" + ConcatFieldsNodeNameSpace + ">" + Const.CR; retval = retval + XMLHandler.addTagValue( "targetFieldName", targetFieldName ); retval = retval + XMLHandler.addTagValue( "targetFieldLength", targetFieldLength ); retval = retval + XMLHandler.addTagValue( "removeSelectedFields", removeSelectedFields ); retval = retval + " </" + ConcatFieldsNodeNameSpace + ">" + Const.CR; return retval; }
Example 8
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { super.readRep( rep, metaStore, id_step, databases ); targetFieldName = rep.getStepAttributeString( id_step, ConcatFieldsNodeNameSpace + "targetFieldName" ); targetFieldLength = (int) rep.getStepAttributeInteger( id_step, ConcatFieldsNodeNameSpace + "targetFieldLength" ); removeSelectedFields = rep.getStepAttributeBoolean( id_step, ConcatFieldsNodeNameSpace + "removeSelectedFields" ); // PDI-18028: Avoid fileName handling! super.setFileName( StringUtil.EMPTY_STRING ); super.setFileNameInField( false ); }
Example 9
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { // PDI-18028: Avoid fileName handling! super.setFileName( StringUtil.EMPTY_STRING ); super.setFileNameInField( false ); super.saveRep( rep, metaStore, id_transformation, id_step ); rep.saveStepAttribute( id_transformation, id_step, ConcatFieldsNodeNameSpace + "targetFieldName", targetFieldName ); rep.saveStepAttribute( id_transformation, id_step, ConcatFieldsNodeNameSpace + "targetFieldLength", targetFieldLength ); rep.saveStepAttribute( id_transformation, id_step, ConcatFieldsNodeNameSpace + "removeSelectedFields", removeSelectedFields ); }
Example 10
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * * @param retVal * @param value */ @Override protected void saveSource( StringBuilder retVal, String value ) { // PDI-18028: Avoid fileName handling! super.setFileName( StringUtil.EMPTY_STRING ); super.setFileNameInField( false ); super.saveSource( retVal, value ); }
Example 11
Source File: SetValueConstant.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SetValueConstantMeta) smi; data = (SetValueConstantData) sdi; Object[] r = getRow(); // get row, set busy! if ( r == null ) { // no more input to be expected... setOutputDone(); return false; } if ( first ) { first = false; // What's the format of the output row? data.setOutputRowMeta( getInputRowMeta().clone() ); meta.getFields( data.getOutputRowMeta(), getStepname(), null, null, this, repository, metaStore ); // Create convert meta-data objects that will contain Date & Number formatters // data.convertRowMeta = data.outputRowMeta.clone(); // For String to <type> conversions, we allocate a conversion meta data row as well... // data.setConvertRowMeta( data.getOutputRowMeta().cloneToType( ValueMetaInterface.TYPE_STRING ) ); // Consider only selected fields List<SetValueConstantMeta.Field> fields = meta.getFields(); int size = fields.size(); if ( !Utils.isEmpty( fields ) ) { data.setFieldnrs( new int[size] ); data.setRealReplaceByValues( new String[size] ); for ( int i = 0; i < size; i++ ) { // Check if this field was specified only one time final SetValueConstantMeta.Field check = fields.get( i ); for ( SetValueConstantMeta.Field field : fields ) { if ( field.getFieldName() != null && field != check && field.getFieldName().equalsIgnoreCase( check.getFieldName() ) ) { throw new KettleException( BaseMessages.getString( PKG, "SetValueConstant.Log" + ".FieldSpecifiedMoreThatOne", check.getFieldName() ) ); } } data.getFieldnrs()[i] = data.getOutputRowMeta().indexOfValue( meta.getField( i ).getFieldName() ); if ( data.getFieldnrs()[i] < 0 ) { logError( BaseMessages.getString( PKG, "SetValueConstant.Log.CanNotFindField", meta.getField( i ).getFieldName() ) ); throw new KettleException( BaseMessages.getString( PKG, "SetValueConstant.Log.CanNotFindField", meta .getField( i ).getFieldName() ) ); } if ( meta.getField( i ).isEmptyString() ) { // Just set empty string data.getRealReplaceByValues()[i] = StringUtil.EMPTY_STRING; } else { // set specified value if ( meta.isUseVars() ) { data.getRealReplaceByValues()[i] = environmentSubstitute( meta.getField( i ).getReplaceValue() ); } else { data.getRealReplaceByValues()[i] = meta.getField( i ).getReplaceValue(); } } } } else { throw new KettleException( BaseMessages.getString( PKG, "SetValueConstant.Log.SelectFieldsEmpty" ) ); } data.setFieldnr( data.getFieldnrs().length ); } // end if first try { updateField( r ); putRow( data.getOutputRowMeta(), r ); // copy row to output rowset(s); } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { // Simply add this row to the error row putError( data.getOutputRowMeta(), r, 1, e.toString(), null, "SVC001" ); } else { logError( BaseMessages.getString( PKG, "SetValueConstant.Log.ErrorInStep", e.getMessage() ) ); setErrors( 1 ); stopAll(); setOutputDone(); // signal end to receiver(s) return false; } } return true; }
Example 12
Source File: JobEntryBaseTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Test public void testAddDatetimeToFilename_NoFilename() { JobEntryBase jobEntryBase = new JobEntryBase(); String fullFilename; String filename; // // null filename // filename = null; // add nothing fullFilename = jobEntryBase.addDatetimeToFilename( filename, false, null, false, null, false, null ); // add date assertNull( fullFilename ); fullFilename = jobEntryBase.addDatetimeToFilename( filename, true, "yyyyMMdd", false, null, false, null ); assertNull( fullFilename ); // add time fullFilename = jobEntryBase.addDatetimeToFilename( filename, false, null, true, "HHmmssSSS", false, null ); assertNull( fullFilename ); // add date and time fullFilename = jobEntryBase.addDatetimeToFilename( filename, true, "yyyyMMdd", true, "HHmmssSSS", false, null ); assertNull( fullFilename ); // add datetime fullFilename = jobEntryBase.addDatetimeToFilename( filename, false, null, false, null, true, "(yyyyMMdd_HHmmssSSS)" ); assertNull( fullFilename ); // // empty filename // filename = StringUtil.EMPTY_STRING; // add nothing fullFilename = jobEntryBase.addDatetimeToFilename( filename, false, null, false, null, false, null ); assertNull( fullFilename ); // add date fullFilename = jobEntryBase.addDatetimeToFilename( filename, true, "yyyyMMdd", false, null, false, null ); assertNull( fullFilename ); // add time fullFilename = jobEntryBase.addDatetimeToFilename( filename, false, null, true, "HHmmssSSS", false, null ); assertNull( fullFilename ); // add date and time fullFilename = jobEntryBase.addDatetimeToFilename( filename, true, "yyyyMMdd", true, "HHmmssSSS", false, null ); assertNull( fullFilename ); // add datetime fullFilename = jobEntryBase.addDatetimeToFilename( filename, false, null, false, null, true, "(yyyyMMdd_HHmmssSSS)" ); assertNull( fullFilename ); }