Java Code Examples for org.pentaho.di.core.variables.Variables#getADefaultVariableSpace()
The following examples show how to use
org.pentaho.di.core.variables.Variables#getADefaultVariableSpace() .
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: DataSetCsvGroup.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
/** * Get the base folder for the data set group * * @param group * @return */ private static String getDataSetFolder( DataSetGroup group ) { String folderName = group.getFolderName(); if ( StringUtils.isEmpty( folderName ) ) { folderName = System.getProperty( VARIABLE_DATASETS_BASE_PATH ); } if ( StringUtils.isEmpty( folderName ) ) { // Local folder folderName = "."; } else { // Let's not forget to replace variables as well... // VariableSpace space = Variables.getADefaultVariableSpace(); folderName = space.environmentSubstitute( folderName ); } if ( !folderName.endsWith( File.separator ) ) { folderName += File.separator; } return folderName; }
Example 2
Source File: EnterPreviewRowsDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void show() { if ( rowDatas.size() == 0 ) { return; } int nr = wStepList.getSelectionIndex(); java.util.List<Object[]> buffer = rowDatas.get( nr ); RowMetaInterface rowMeta = rowMetas.get( nr ); String name = stepNames.get( nr ); if ( rowMeta != null && buffer != null && buffer.size() > 0 ) { PreviewRowsDialog prd = new PreviewRowsDialog( shell, Variables.getADefaultVariableSpace(), SWT.NONE, name, rowMeta, buffer ); prd.open(); } else { MessageBox mb = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.OK ); mb.setText( BaseMessages.getString( PKG, "EnterPreviewRowsDialog.Dialog.NoPreviewRowsFound.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "EnterPreviewRowsDialog.Dialog.NoPreviewRowsFound.Message" ) ); mb.open(); } }
Example 3
Source File: SpoonDBDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Get & show the SQL required to run the loaded transformation... * */ public void getTransSQL( TransMeta transMeta ) { GetSQLProgressDialog pspd = new GetSQLProgressDialog( spoon.getShell(), transMeta ); List<SQLStatement> stats = pspd.open(); if ( stats != null ) { // null means error, but we already displayed the error if ( stats.size() > 0 ) { SQLStatementsDialog ssd = new SQLStatementsDialog( spoon.getShell(), Variables.getADefaultVariableSpace(), SWT.NONE, stats ); String sn = ssd.open(); if ( sn != null ) { StepMeta esi = transMeta.findStep( sn ); if ( esi != null ) { spoon.delegates.steps.editStep( transMeta, esi ); } } } else { MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION ); mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.NoSQLNeedEexecuted.Message" ) ); mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.NoSQLNeedEexecuted.Title" ) ); // "SQL" mb.open(); } } }
Example 4
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public static List<DatabaseMeta> getAvailableDatabases( Repository repository ) throws KettleException { List<DatabaseMeta> list = new ArrayList<DatabaseMeta>(); // Load database connections from the central repository if we're connected to one // if ( repository != null ) { ObjectId[] databaseIDs = repository.getDatabaseIDs( false ); for ( ObjectId databaseId : databaseIDs ) { list.add( repository.loadDatabaseMeta( databaseId, null ) ); } } // We need to share a default VariableSpace (env vars) with these objects... // VariableSpace space = Variables.getADefaultVariableSpace(); // Also load from the standard shared objects file // SharedObjects sharedObjects = new SharedObjects( Const.getSharedObjectsFile() ); Collection<SharedObjectInterface> localSharedObjects = sharedObjects.getObjectsMap().values(); for ( SharedObjectInterface localSharedObject : localSharedObjects ) { if ( localSharedObject instanceof DatabaseMeta ) { DatabaseMeta databaseMeta = (DatabaseMeta) localSharedObject; // Only add a local database if it doesn't exist in the central repository // if ( !list.contains( databaseMeta ) ) { list.add( databaseMeta ); // To allow these connections to be parameterized // databaseMeta.initializeVariablesFrom( space ); } } } return list; }
Example 5
Source File: JobExecutionConfiguration.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getUsedVariables( JobMeta jobMeta ) { Properties sp = new Properties(); VariableSpace space = Variables.getADefaultVariableSpace(); String[] keys = space.listVariables(); for ( int i = 0; i < keys.length; i++ ) { sp.put( keys[i], space.getVariable( keys[i] ) ); } List<String> vars = jobMeta.getUsedVariables(); if ( vars != null && vars.size() > 0 ) { HashMap<String, String> newVariables = new HashMap<String, String>(); for ( int i = 0; i < vars.size(); i++ ) { String varname = vars.get( i ); if ( !varname.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) { // add all new non-internal variables to newVariablesMap newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); } } // variables.clear(); variables.putAll( newVariables ); } // Also add the internal job variables if these are set... // for ( String variableName : Const.INTERNAL_JOB_VARIABLES ) { String value = jobMeta.getVariable( variableName ); if ( !Utils.isEmpty( value ) ) { variables.put( variableName, value ); } } }
Example 6
Source File: TransExecutionConfiguration.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getAllVariables( TransMeta transMeta ) { Properties sp = new Properties(); VariableSpace space = Variables.getADefaultVariableSpace(); String[] keys = space.listVariables(); for ( int i = 0; i < keys.length; i++ ) { sp.put( keys[i], space.getVariable( keys[i] ) ); } String[] vars = transMeta.listVariables(); if ( vars != null && vars.length > 0 ) { HashMap<String, String> newVariables = new HashMap<String, String>(); for ( int i = 0; i < vars.length; i++ ) { String varname = vars[i]; newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); } // variables.clear(); variables.putAll( newVariables ); } // Also add the internal job variables if these are set... // for ( String variableName : Const.INTERNAL_JOB_VARIABLES ) { String value = transMeta.getVariable( variableName ); if ( !Utils.isEmpty( value ) ) { variables.put( variableName, value ); } } }
Example 7
Source File: TransExecutionConfiguration.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getUsedVariables( TransMeta transMeta ) { Properties sp = new Properties(); VariableSpace space = Variables.getADefaultVariableSpace(); String[] keys = space.listVariables(); for ( int i = 0; i < keys.length; i++ ) { sp.put( keys[i], space.getVariable( keys[i] ) ); } List<String> vars = transMeta.getUsedVariables(); if ( vars != null && vars.size() > 0 ) { HashMap<String, String> newVariables = new HashMap<String, String>(); for ( int i = 0; i < vars.size(); i++ ) { String varname = vars.get( i ); if ( !varname.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) { newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); } } // variables.clear(); variables.putAll( newVariables ); } // Also add the internal job variables if these are set... // for ( String variableName : Const.INTERNAL_JOB_VARIABLES ) { String value = transMeta.getVariable( variableName ); if ( !Utils.isEmpty( value ) ) { variables.put( variableName, value ); } } }
Example 8
Source File: BeamJobConfigDialog.java From kettle-beam with Apache License 2.0 | 4 votes |
private void buildFatJar( Event event ) { try { VariableSpace space = Variables.getADefaultVariableSpace(); BeamJobConfig jobConfig = new BeamJobConfig(); getInfo( jobConfig ); FileDialog dialog = new FileDialog( shell, SWT.SAVE ); dialog.setText( "Select the location of the Kettle+Beam+Plugins fat jar" ); dialog.setFilterNames( new String[] { "Jar files (*.jar)", "All Files (*.*)" } ); dialog.setFilterExtensions( new String[] { "*.jar", "*.*" } ); // Windows if ( StringUtils.isNotEmpty( jobConfig.getFatJar() ) ) { dialog.setFileName( space.environmentSubstitute( jobConfig.getFatJar() ) ); } String filename = dialog.open(); if ( StringUtils.isEmpty( filename ) ) { return; } List<String> files = BeamConst.findLibraryFilesToStage( null, jobConfig.getPluginsToStage(), true, true ); files.removeIf( s -> s.contains( "commons-logging" ) || s.startsWith( "log4j" ) || s.contains( "xml-apis" ) ); // Find the plugin classes for the specified plugins... // String stepPluginClasses = findPluginClasses( Step.class.getName() ); if (StringUtils.isNotEmpty(jobConfig.getStepPluginClasses())) { if (StringUtils.isEmpty( stepPluginClasses )) { stepPluginClasses=""; } else { stepPluginClasses+=","; } stepPluginClasses+=jobConfig.getStepPluginClasses(); } String xpPluginClasses = findPluginClasses( ExtensionPoint.class.getName() ); if (StringUtils.isNotEmpty(jobConfig.getXpPluginClasses())) { if (StringUtils.isEmpty( xpPluginClasses )) { xpPluginClasses=""; } else { xpPluginClasses+=","; } xpPluginClasses+=jobConfig.getStepPluginClasses(); } FatJarBuilder fatJarBuilder = new FatJarBuilder( filename, files ); fatJarBuilder.setExtraStepPluginClasses( stepPluginClasses ); fatJarBuilder.setExtraXpPluginClasses( xpPluginClasses ); Cursor waitCursor = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT ); Cursor regularCursor = shell.getCursor(); try { shell.setCursor( waitCursor ); fatJarBuilder.buildTargetJar(); } finally { shell.setCursor( regularCursor ); waitCursor.dispose(); } // All went well, insert the filename... // wFatJar.setText( filename ); } catch ( Exception e ) { new ErrorDialog( shell, "Error", "Error building fat jar: " + e.getMessage(), e ); } }
Example 9
Source File: Translator.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void addGrid() { Composite composite = new Composite( sashform, SWT.NONE ); props.setLook( composite ); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; composite.setLayout( formLayout ); wReload = new Button( composite, SWT.NONE ); wReload.setText( " &Reload " ); wLocale = new Button( composite, SWT.NONE ); wLocale.setText( " &Select locale " ); wClose = new Button( composite, SWT.NONE ); wClose.setText( " &Close " ); wVerify = new Button( composite, SWT.CHECK ); wVerify.setText( "&Verify usage" ); wVerify.setSelection( true ); // Check it! wUsed = new Button( composite, SWT.CHECK ); wUsed.setText( "&Remove used keys" ); wUsed.setSelection( false ); // Check it! wAvailable = new Button( composite, SWT.CHECK ); wAvailable.setText( "&Check key against other locale" ); wAvailable.setSelection( true ); // Check it! BaseStepDialog.positionBottomButtons( composite, new Button[] { wReload, wLocale, wClose, wVerify, wUsed, wAvailable }, Const.MARGIN, null ); ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo( "Locale", ColumnInfo.COLUMN_TYPE_TEXT, true ), new ColumnInfo( "Package", ColumnInfo.COLUMN_TYPE_TEXT, true ), new ColumnInfo( "Class", ColumnInfo.COLUMN_TYPE_TEXT, true ), new ColumnInfo( "Key", ColumnInfo.COLUMN_TYPE_TEXT, true ), new ColumnInfo( "Value", ColumnInfo.COLUMN_TYPE_TEXT, true ), new ColumnInfo( "Used?", ColumnInfo.COLUMN_TYPE_TEXT, true ), new ColumnInfo( "Not available in", ColumnInfo.COLUMN_TYPE_TEXT, true ), }; wGrid = new TableView( Variables.getADefaultVariableSpace(), composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 0, null, PropsUI.getInstance() ); FormData fdGrid = new FormData(); fdGrid.left = new FormAttachment( 0, 0 ); fdGrid.top = new FormAttachment( 0, 0 ); fdGrid.right = new FormAttachment( 100, 0 ); fdGrid.bottom = new FormAttachment( wReload, -Const.MARGIN * 3 ); wGrid.setLayoutData( fdGrid ); }