Java Code Examples for org.pentaho.di.core.util.Utils#isEmpty()
The following examples show how to use
org.pentaho.di.core.util.Utils#isEmpty() .
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: LucidDBStreamingLoaderDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void ok() { if ( Utils.isEmpty( wStepname.getText() ) ) { return; } // Get the information for the dialog into the input structure. getInfo( input ); if ( input.getDatabaseMeta() == null ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb .setMessage( BaseMessages .getString( PKG, "LucidDBStreamingLoaderDialog.InvalidConnection.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "LucidDBStreamingLoaderDialog.InvalidConnection.DialogTitle" ) ); mb.open(); } dispose(); }
Example 2
Source File: Const.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Return non digits only. * * @return non digits in a string. */ public static String removeDigits( String input ) { if ( Utils.isEmpty( input ) ) { return null; } StringBuilder digitsOnly = new StringBuilder(); char c; for ( int i = 0; i < input.length(); i++ ) { c = input.charAt( i ); if ( !Character.isDigit( c ) ) { digitsOnly.append( c ); } } return digitsOnly.toString(); }
Example 3
Source File: XsltDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void PopulateFields( CCombo cc ) { if ( cc.isDisposed() ) { return; } try { String initValue = cc.getText(); cc.removeAll(); RowMetaInterface r = transMeta.getPrevStepFields( stepname ); if ( r != null ) { cc.setItems( r.getFieldNames() ); } if ( !Utils.isEmpty( initValue ) ) { cc.setText( initValue ); } } catch ( KettleException ke ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "XsltDialog.FailedToGetFields.DialogTitle" ), BaseMessages .getString( PKG, "XsltDialog.FailedToGetFields.DialogMessage" ), ke ); } }
Example 4
Source File: WebServiceMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Returns the WebServicesField for the given wsName. * * @param wsName * The name of the WebServiceField to return * @param ignoreWsNsPrefix * If true the lookup of the cache of WebServiceFields will not include the target namespace prefix. * @return */ public WebServiceField getFieldOutFromWsName( String wsName, boolean ignoreWsNsPrefix ) { WebServiceField param = null; if ( Utils.isEmpty( wsName ) ) { return param; } // if we are ignoring the name space prefix if ( ignoreWsNsPrefix ) { // we split the wsName and set it to the last element of what was parsed String[] wsNameParsed = wsName.split( ":" ); wsName = wsNameParsed[wsNameParsed.length - 1]; } // we now look for the wsname for ( Iterator<WebServiceField> iter = getFieldsOut().iterator(); iter.hasNext(); ) { WebServiceField paramCour = iter.next(); if ( paramCour.getWsName().equals( wsName ) ) { param = paramCour; break; } } return param; }
Example 5
Source File: JobEntryMoveFiles.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/********************************************************** * * @param selectedfile * @param wildcard * @return True if the selectedfile matches the wildcard **********************************************************/ private boolean GetFileWildcard( String selectedfile, String wildcard ) { Pattern pattern = null; boolean getIt = true; if ( !Utils.isEmpty( wildcard ) ) { pattern = Pattern.compile( wildcard ); // First see if the file matches the regular expression! if ( pattern != null ) { Matcher matcher = pattern.matcher( selectedfile ); getIt = matcher.matches(); } } return getIt; }
Example 6
Source File: JobExecutorMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String[] getTargetSteps() { List<String> targetSteps = new ArrayList<String>(); if ( !Utils.isEmpty( resultFilesTargetStep ) ) { targetSteps.add( resultFilesTargetStep ); } if ( !Utils.isEmpty( resultRowsTargetStep ) ) { targetSteps.add( resultRowsTargetStep ); } if ( targetSteps.isEmpty() ) { return null; } return targetSteps.toArray( new String[targetSteps.size()] ); }
Example 7
Source File: Mail.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void cacheWildCardField() throws KettleException { if ( !Utils.isEmpty( meta.getDynamicWildcard() ) ) { if ( data.indexOfSourceWildcard < 0 ) { String realSourceattachedWildcard = meta.getDynamicWildcard(); data.indexOfSourceWildcard = data.previousRowMeta.indexOfValue( realSourceattachedWildcard ); if ( data.indexOfSourceWildcard < 0 ) { throw new KettleException( BaseMessages.getString( PKG, "Mail.Exception.CouldnotSourceAttachedWildcard", realSourceattachedWildcard ) ); } } } }
Example 8
Source File: Database.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean getUseBatchInsert( boolean batch ) throws KettleDatabaseException { try { return batch && getDatabaseMetaData().supportsBatchUpdates() && databaseMeta.supportsBatchUpdates() && Utils.isEmpty( connectionGroup ); } catch ( SQLException e ) { throw createKettleDatabaseBatchException( "Error determining whether to use batch", e ); } }
Example 9
Source File: OraBulkLoader.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private String encodeRecordTerminator( String terminator, String encoding ) throws KettleException { final String in = substituteRecordTerminator( terminator ); final StringBuilder out = new StringBuilder(); byte[] bytes; try { // use terminator in hex representation due to character set // terminator in hex representation must be in character set // of data file if ( Utils.isEmpty( encoding ) ) { bytes = in.getBytes(); } else { bytes = in.getBytes( encoding ); } for ( byte aByte : bytes ) { final String hex = Integer.toHexString( aByte ); if ( hex.length() == 1 ) { out.append( '0' ); } out.append( hex ); } } catch ( UnsupportedEncodingException e ) { throw new KettleException( "Unsupported character encoding: " + encoding, e ); } return out.toString(); }
Example 10
Source File: Database.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public boolean getBooleanValueOfVariable( String variableName, boolean defaultValue ) { if ( !Utils.isEmpty( variableName ) ) { String value = environmentSubstitute( variableName ); if ( !Utils.isEmpty( value ) ) { return ValueMetaBase.convertStringToBoolean( value ); } } return defaultValue; }
Example 11
Source File: SelectionAdapterFileDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private static String replaceCurrentDir( String path, String parentPath ) { if ( !Utils.isEmpty( path ) && !Utils.isEmpty( parentPath ) && path.startsWith( parentPath ) ) { path = path.replace( parentPath, "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}" ); // Ensure the path is uniform for windows. Path's using the internal variable need to use forward slash if ( Const.isWindows() ) { path = path.replace( '\\', '/' ); } } return path; }
Example 12
Source File: SortedMergeDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { if ( Utils.isEmpty( wStepname.getText() ) ) { return; } stepname = wStepname.getText(); // return value int nrfields = wFields.nrNonEmpty(); input.allocate( nrfields ); //CHECKSTYLE:Indentation:OFF for ( int i = 0; i < nrfields; i++ ) { TableItem ti = wFields.getNonEmpty( i ); input.getFieldName()[i] = ti.getText( 1 ); input.getAscending()[i] = BaseMessages.getString( PKG, "System.Combo.Yes" ).equalsIgnoreCase( ti.getText( 2 ) ); } // Show a warning (optional) // if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) { MessageDialogWithToggle md = new MessageDialogWithToggle( shell, BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.DialogTitle" ), null, BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.Option1" ) }, 0, BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.Option2" ), "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ); MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() ); md.open(); props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" ); props.saveProps(); } dispose(); }
Example 13
Source File: RootNode.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void checkUpdate( AbstractMeta abstractMeta, String filter ) { TreeNode treeNode = abstractMetas.get( abstractMeta ); if ( treeNode != null ) { for ( TreeFolderProvider treeFolderProvider : treeFolderProviders ) { TreeNode childTreeNode = getChildTreeNode( treeNode, treeFolderProvider.getTitle() ); if ( childTreeNode != null ) { treeFolderProvider.checkUpdate( abstractMeta, childTreeNode, filter ); if ( !Utils.isEmpty( filter ) ) { childTreeNode.setExpanded( true ); } } } } }
Example 14
Source File: SSHDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { if ( Utils.isEmpty( wStepname.getText() ) ) { return; } try { getInfo( input ); } catch ( KettleException e ) { new ErrorDialog( shell, "Error", "Error while previewing data", e ); } dispose(); }
Example 15
Source File: MappingMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private boolean isInfoMapping( MappingIODefinition def ) { return !def.isMainDataPath() && !Utils.isEmpty( def.getInputStepname() ); }
Example 16
Source File: JobEntryFTPSGet.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * @param string * the filename from the FTPS server * * @return the calculated target filename */ private String returnTargetFilename( String filename ) { String retval = null; // Replace possible environment variables... if ( filename != null ) { retval = filename; } else { return null; } int lenstring = retval.length(); int lastindexOfDot = retval.lastIndexOf( "." ); if ( lastindexOfDot == -1 ) { lastindexOfDot = lenstring; } if ( isAddDateBeforeExtension() ) { retval = retval.substring( 0, lastindexOfDot ); } SimpleDateFormat daf = new SimpleDateFormat(); Date now = new Date(); if ( SpecifyFormat && !Utils.isEmpty( date_time_format ) ) { daf.applyPattern( date_time_format ); String dt = daf.format( now ); retval += dt; } else { if ( adddate ) { daf.applyPattern( "yyyyMMdd" ); String d = daf.format( now ); retval += "_" + d; } if ( addtime ) { daf.applyPattern( "HHmmssSSS" ); String t = daf.format( now ); retval += "_" + t; } } if ( isAddDateBeforeExtension() ) { retval += retval.substring( lastindexOfDot, lenstring ); } // Add foldername to filename retval = localFolder + Const.FILE_SEPARATOR + retval; return retval; }
Example 17
Source File: JobExecutorDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void loadJob() throws KettleException { String filename = wPath.getText(); if ( repository != null ) { specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME; } else { specificationMethod = ObjectLocationSpecificationMethod.FILENAME; } switch ( specificationMethod ) { case FILENAME: if ( Utils.isEmpty( filename ) ) { return; } if ( !filename.endsWith( ".kjb" ) ) { filename = filename + ".kjb"; wPath.setText( filename ); } loadFileJob( filename ); break; case REPOSITORY_BY_NAME: if ( Utils.isEmpty( filename ) ) { return; } String transPath = transMeta.environmentSubstitute( filename ); String realJobname = transPath; String realDirectory = ""; int index = transPath.lastIndexOf( "/" ); if ( index != -1 ) { realJobname = transPath.substring( index + 1 ); realDirectory = transPath.substring( 0, index ); } if ( Utils.isEmpty( realDirectory ) || Utils.isEmpty( realJobname ) ) { throw new KettleException( BaseMessages.getString( PKG, "JobExecutorDialog.Exception.NoValidMappingDetailsFound" ) ); } RepositoryDirectoryInterface repdir = repository.findDirectory( realDirectory ); if ( repdir == null ) { throw new KettleException( BaseMessages.getString( PKG, "JobExecutorDialog.Exception.UnableToFindRepositoryDirectory" ) ); } loadRepositoryJob( realJobname, repdir ); break; default: break; } }
Example 18
Source File: JobEntryGetPOP.java From pentaho-kettle with Apache License 2.0 | 4 votes |
String createOutputDirectory( int folderType ) throws KettleException, FileSystemException, IllegalArgumentException { if ( ( folderType != JobEntryGetPOP.FOLDER_OUTPUT ) && ( folderType != JobEntryGetPOP.FOLDER_ATTACHMENTS ) ) { throw new IllegalArgumentException( "Invalid folderType argument" ); } String folderName = ""; switch ( folderType ) { case JobEntryGetPOP.FOLDER_OUTPUT: folderName = getRealOutputDirectory(); break; case JobEntryGetPOP.FOLDER_ATTACHMENTS: if ( isSaveAttachment() && isDifferentFolderForAttachment() ) { folderName = getRealAttachmentFolder(); } else { folderName = getRealOutputDirectory(); } break; } if ( Utils.isEmpty( folderName ) ) { switch ( folderType ) { case JobEntryGetPOP.FOLDER_OUTPUT: throw new KettleException( BaseMessages .getString( PKG, "JobGetMailsFromPOP.Error.OutputFolderEmpty" ) ); case JobEntryGetPOP.FOLDER_ATTACHMENTS: throw new KettleException( BaseMessages .getString( PKG, "JobGetMailsFromPOP.Error.AttachmentFolderEmpty" ) ); } } FileObject folder = KettleVFS.getFileObject( folderName, this ); if ( folder.exists() ) { if ( folder.getType() != FileType.FOLDER ) { switch ( folderType ) { case JobEntryGetPOP.FOLDER_OUTPUT: throw new KettleException( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Error.NotAFolderNot", folderName ) ); case JobEntryGetPOP.FOLDER_ATTACHMENTS: throw new KettleException( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Error.AttachmentFolderNotAFolder", folderName ) ); } } if ( isDebug() ) { switch ( folderType ) { case JobEntryGetPOP.FOLDER_OUTPUT: logDebug( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Log.OutputFolderExists", folderName ) ); break; case JobEntryGetPOP.FOLDER_ATTACHMENTS: logDebug( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Log.AttachmentFolderExists", folderName ) ); break; } } } else { if ( isCreateLocalFolder() ) { folder.createFolder(); } else { switch ( folderType ) { case JobEntryGetPOP.FOLDER_OUTPUT: throw new KettleException( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Error.OutputFolderNotExist", folderName ) ); case JobEntryGetPOP.FOLDER_ATTACHMENTS: throw new KettleException( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Error.AttachmentFolderNotExist", folderName ) ); } } } String returnValue = KettleVFS.getFilename( folder ); try { folder.close(); } catch ( IOException ignore ) { //Ignore error, as the folder was created successfully } return returnValue; }
Example 19
Source File: BaseStreamStepMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public boolean[] isReferencedObjectEnabled() { return new boolean[] { !Utils.isEmpty( transformationPath ) }; }
Example 20
Source File: SetVariable.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SetVariableMeta) smi; data = (SetVariableData) sdi; // Get one row from one of the rowsets... // Object[] rowData = getRow(); if ( rowData == null ) { // means: no more input to be expected... if ( first ) { // We do not received any row !! logBasic( BaseMessages.getString( PKG, "SetVariable.Log.NoInputRowSetDefault" ) ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { if ( !Utils.isEmpty( meta.getDefaultValue()[i] ) ) { setValue( rowData, i, true ); } } } logBasic( "Finished after " + getLinesWritten() + " rows." ); setOutputDone(); return false; } if ( first ) { first = false; data.outputMeta = getInputRowMeta().clone(); logBasic( BaseMessages.getString( PKG, "SetVariable.Log.SettingVar" ) ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { setValue( rowData, i, false ); } putRow( data.outputMeta, rowData ); return true; } throw new KettleStepException( BaseMessages.getString( PKG, "SetVariable.RuntimeError.MoreThanOneRowReceived.SETVARIABLE0007" ) ); }