Java Code Examples for org.pentaho.di.core.Const

The following examples show how to use org.pentaho.di.core.Const. These examples are extracted from open source projects. 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 Project: pentaho-kettle   Author: pentaho   File: JobEntryWaitForSQLDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wName.setText( Const.nullToEmpty( jobEntry.getName() ) );

  if ( jobEntry.getDatabase() != null ) {
    wConnection.setText( jobEntry.getDatabase().getName() );
  }

  wSchemaname.setText( Const.nullToEmpty( jobEntry.schemaname ) );
  wTablename.setText( Const.nullToEmpty( jobEntry.tablename ) );

  wSuccessCondition.setText( JobEntryWaitForSQL.getSuccessConditionDesc( jobEntry.successCondition ) );
  wRowsCountValue.setText( Const.NVL( jobEntry.rowsCountValue, "0" ) );
  wcustomSQL.setSelection( jobEntry.iscustomSQL );
  wUseSubs.setSelection( jobEntry.isUseVars );
  wAddRowsToResult.setSelection( jobEntry.isAddRowsResult );
  wClearResultList.setSelection( jobEntry.isClearResultList );
  wSQL.setText( Const.nullToEmpty( jobEntry.customSQL ) );
  wMaximumTimeout.setText( Const.NVL( jobEntry.getMaximumTimeout(), "" ) );
  wCheckCycleTime.setText( Const.NVL( jobEntry.getCheckCycleTime(), "" ) );
  wSuccesOnTimeout.setSelection( jobEntry.isSuccessOnTimeout() );

  wName.selectAll();
  wName.setFocus();
}
 
Example #2
Source Project: pentaho-kettle   Author: pentaho   File: JobExecutionConfigurationDialog.java    License: Apache License 2.0 6 votes vote down vote up
public boolean open() {

    mainLayout( PKG, "JobExecutionConfigurationDialog", GUIResource.getInstance().getImageJobGraph() );
    runConfigurationSectionLayout( PKG, "TransExecutionConfigurationDialog" );
    optionsSectionLayout( PKG, "JobExecutionConfigurationDialog" );
    parametersSectionLayout( PKG, "JobExecutionConfigurationDialog" );

    String docUrl =
        Const.getDocUrl( BaseMessages.getString( Spoon.class, "Spoon.JobExecutionConfigurationDialog.Help" ) );
    String docTitle = BaseMessages.getString( PKG, "JobExecutionConfigurationDialog.docTitle" );
    String docHeader = BaseMessages.getString( PKG, "JobExecutionConfigurationDialog.docHeader" );
    buttonsSectionLayout( PKG, "JobExecutionConfigurationDialog", docTitle, docUrl, docHeader );

    getData();
    openDialog();
    return retval;
  }
 
Example #3
Source Project: pentaho-kettle   Author: pentaho   File: RepositoryExplorerDialog.java    License: Apache License 2.0 6 votes vote down vote up
public void exportAll( RepositoryDirectoryInterface dir ) {
  FileDialog dialog = Spoon.getInstance().getExportFileDialog(); // new FileDialog( shell, SWT.SAVE | SWT.SINGLE );
  if ( dialog.open() == null ) {
    return;
  }

  String filename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName();

  // check if file is exists
  MessageBox box = RepositoryExportProgressDialog.checkIsFileIsAcceptable( shell, log, filename );
  int answer = ( box == null ) ? SWT.OK : box.open();
  if ( answer != SWT.OK ) {
    // seems user don't want to overwrite file...
    return;
  }

  if ( log.isBasic() ) {
    log.logBasic( "Exporting All", "Export objects to file [" + filename + "]" ); //$NON-NLS-3$
  }

  // check file is not empty
  RepositoryExportProgressDialog repd = new RepositoryExportProgressDialog( shell, rep, dir, filename );
  repd.open();
}
 
Example #4
Source Project: pentaho-kettle   Author: pentaho   File: TextFileOutput.java    License: Apache License 2.0 6 votes vote down vote up
protected boolean writeEndedLine() {
  boolean retval = false;
  try {
    String sLine = environmentSubstitute( meta.getEndedLine() );
    if ( sLine != null ) {
      if ( sLine.trim().length() > 0 ) {
        data.writer.write( getBinaryString( sLine ) );
        incrementLinesOutput();
      }
    }
  } catch ( Exception e ) {
    logError( "Error writing ended tag line: " + e.toString() );
    logError( Const.getStackTracker( e ) );
    retval = true;
  }

  return retval;
}
 
Example #5
Source Project: pentaho-kettle   Author: pentaho   File: ConfigurationDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void optionsSectionLayout( Class<?> PKG, String prefix ) {
  gDetails = new Group( cContainer, SWT.SHADOW_ETCHED_IN );
  gDetails.setText( BaseMessages.getString( PKG, prefix + ".DetailsGroup.Label" ) );
  props.setLook( gDetails );

  // The layout
  gDetails.setLayout( new FormLayout() );
  fdDetails = new FormData();
  fdDetails.top = new FormAttachment( cRunConfiguration, Const.FORM_MARGIN );
  fdDetails.right = new FormAttachment( 100, -Const.FORM_MARGIN );
  fdDetails.left = new FormAttachment( 0, Const.FORM_MARGIN );
  gDetails.setBackground( shell.getBackground() ); // the default looks ugly
  gDetails.setLayoutData( fdDetails );

  optionsSectionControls();
}
 
Example #6
Source Project: pentaho-kettle   Author: pentaho   File: PaloCellInputDialog.java    License: Apache License 2.0 6 votes vote down vote up
public static void showPaloLibWarningDialog( Shell shell ) {
  PropsUI props = PropsUI.getInstance();

  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_PALO_LIB_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle(
        shell,
        BaseMessages.getString( PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogMessage", Const.CR )
          + Const.CR,
        MessageDialog.WARNING,
        new String[]{ BaseMessages.getString( PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option1" ) },
        0,
        BaseMessages.getString( PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_PALO_LIB_WARNING_PARAMETER, "Y" )
        )
      );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_PALO_LIB_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }
}
 
Example #7
Source Project: pentaho-kettle   Author: pentaho   File: JobEntryMssqlBulkLoadDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void getTableName() {
  // New class: SelectTableDialog
  int connr = wConnection.getSelectionIndex();
  if ( connr >= 0 ) {
    DatabaseMeta inf = jobMeta.getDatabase( connr );

    DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, inf, jobMeta.getDatabases() );
    std.setSelectedSchemaAndTable( wSchemaname.getText(), wTablename.getText() );
    if ( std.open() ) {
      wTablename.setText( Const.NVL( std.getTableName(), "" ) );
    }
  } else {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "JobMssqlBulkLoad.ConnectionError2.DialogMessage" ) );
    mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) );
    mb.open();
  }
}
 
Example #8
Source Project: pentaho-kettle   Author: pentaho   File: DynamicSQLRowMeta.java    License: Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode, List<DatabaseMeta> databases ) throws KettleXMLException {
  try {
    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    sql = XMLHandler.getTagValue( stepnode, "sql" );
    outerJoin = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "outer_join" ) );
    replacevars = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "replace_vars" ) );
    queryonlyonchange = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "query_only_on_change" ) );

    rowLimit = Const.toInt( XMLHandler.getTagValue( stepnode, "rowlimit" ), 0 );
    sqlfieldname = XMLHandler.getTagValue( stepnode, "sql_fieldname" );

  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "DynamicSQLRowMeta.Exception.UnableToLoadStepInfo" ), e );
  }
}
 
Example #9
Source Project: pentaho-kettle   Author: pentaho   File: TextVar.java    License: Apache License 2.0 6 votes vote down vote up
protected ModifyListener getModifyListenerTooltipText( final Text textField ) {
  return new ModifyListener() {
    public void modifyText( ModifyEvent e ) {
      if ( textField.getEchoChar() == '\0' ) { // Can't show passwords ;-)

        String tip = textField.getText();
        if ( !Utils.isEmpty( tip ) && !Utils.isEmpty( toolTipText ) ) {
          tip += Const.CR + Const.CR + toolTipText;
        }

        if ( Utils.isEmpty( tip ) ) {
          tip = toolTipText;
        }
        textField.setToolTipText( variables.environmentSubstitute( tip ) );
      }
    }
  };
}
 
Example #10
Source Project: pentaho-kettle   Author: pentaho   File: SplitFieldToRows.java    License: Apache License 2.0 6 votes vote down vote up
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
  meta = (SplitFieldToRowsMeta) smi;
  data = (SplitFieldToRowsData) sdi;

  if ( super.init( smi, sdi ) ) {
    data.rownr = 1L;

    try {
      String delimiter = Const.nullToEmpty( meta.getDelimiter() );
      if ( meta.isDelimiterRegex() ) {
        data.delimiterPattern = Pattern.compile( environmentSubstitute( delimiter ) );
      } else {
        data.delimiterPattern = Pattern.compile( Pattern.quote( environmentSubstitute( delimiter ) ) );
      }
    } catch ( PatternSyntaxException pse ) {
      log.logError( pse.getMessage() );
      throw pse;
    }

    return true;
  }
  return false;
}
 
Example #11
Source Project: pentaho-kettle   Author: pentaho   File: GetPreviousRowFieldMeta.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String getXML() {
  StringBuffer retval = new StringBuffer( 500 );

  retval.append( "    <fields>" ).append( Const.CR );

  for ( int i = 0; i < fieldInStream.length; i++ ) {
    retval.append( "      <field>" ).append( Const.CR );
    retval.append( "        " ).append( XMLHandler.addTagValue( "in_stream_name", fieldInStream[i] ) );
    retval.append( "        " ).append( XMLHandler.addTagValue( "out_stream_name", fieldOutStream[i] ) );
    retval.append( "      </field>" ).append( Const.CR );
  }

  retval.append( "    </fields>" ).append( Const.CR );

  return retval.toString();
}
 
Example #12
Source Project: pentaho-kettle   Author: pentaho   File: ValueDataUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Object hourOfDay( ValueMetaInterface metaA, Object dataA ) throws KettleValueException {
  if ( dataA == null ) {
    return null;
  }

  Calendar calendar = Calendar.getInstance();
  calendar.setTime( metaA.getDate( dataA ) );

  Boolean oldDateCalculation = Boolean.parseBoolean(
    Const.getEnvironmentVariable( Const.KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION, "false" ) );
  if ( !oldDateCalculation ) {
    calendar.setTimeZone( metaA.getDateFormatTimeZone() );
  }

  return new Long( calendar.get( Calendar.HOUR_OF_DAY ) );
}
 
Example #13
Source Project: pentaho-kettle   Author: pentaho   File: ValueDataUtilTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDivisionBigNumbersWithPrecision1AndRoundingModeHalfEven() {
  space.setVariable( Const.KETTLE_BIGDECIMAL_DIVISION_PRECISION, "1" );
  space.setVariable( Const.KETTLE_BIGDECIMAL_DIVISION_ROUNDING_MODE, "HALF_EVEN" );

  BigDecimal field1 = new BigDecimal( "4.8" );
  BigDecimal field2 = new BigDecimal( "2.0" );
  BigDecimal field3 = new BigDecimal( "5.2" );
  BigDecimal field4 = new BigDecimal( "15.0" );
  BigDecimal field5 = new BigDecimal( "13.0" );

  BigDecimal expResult1 = new BigDecimal( "2" );
  BigDecimal expResult2 = new BigDecimal( "3" );
  BigDecimal expResult3 = new BigDecimal( "8" );
  BigDecimal expResult4 = new BigDecimal( "6" );

  assertEquals( expResult1, ValueDataUtil.divideBigDecimals( field1, field2, space ) );
  assertEquals( expResult2, ValueDataUtil.divideBigDecimals( field3, field2, space ) );
  assertEquals( expResult3, ValueDataUtil.divideBigDecimals( field4, field2, space ) );
  assertEquals( expResult4, ValueDataUtil.divideBigDecimals( field5, field2, space ) );
}
 
Example #14
Source Project: pentaho-kettle   Author: pentaho   File: CreateDatabaseWizardPageJDBC.java    License: Apache License 2.0 6 votes vote down vote up
public void setData() {
  wHostname.setText( Const.NVL( databaseMeta.getHostname(), "" ) );
  wPort.setText( Const.NVL( databaseMeta.getDatabasePortNumberString(), "" ) );

  if ( !defaultWebAppNameSet && isDataServiceConnection() ) {
    wDBName.setText( DEFAULT_WEB_APPLICATION_NAME );
    defaultWebAppNameSet = true;
  } else {
    wDBName.setText( Const.NVL( databaseMeta.getDatabaseName(), "" ) );
  }

  if ( isDataServiceConnection() ) {
    wlDBName.setText( BaseMessages.getString( PKG, "CreateDatabaseWizardPageJDBC.WebAppName.Label" ) );
  } else {
    wlDBName.setText( BaseMessages.getString( PKG, "CreateDatabaseWizardPageJDBC.DBName.Label" ) );
  }
}
 
Example #15
Source Project: pentaho-kettle   Author: pentaho   File: SwitchCaseDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wFieldName.setText( Const.NVL( input.getFieldname(), "" ) );
  wContains.setSelection( input.isContains() );
  wDataType.setText( ValueMetaBase.getTypeDesc( input.getCaseValueType() ) );
  wDecimalSymbol.setText( Const.NVL( input.getCaseValueDecimal(), "" ) );
  wGroupingSymbol.setText( Const.NVL( input.getCaseValueGroup(), "" ) );
  wConversionMask.setText( Const.NVL( input.getCaseValueFormat(), "" ) );

  for ( int i = 0; i < input.getCaseTargets().size(); i++ ) {
    TableItem item = wValues.table.getItem( i );
    SwitchCaseTarget target = input.getCaseTargets().get( i );
    if ( target != null ) {
      item.setText( 1, Const.NVL( target.caseValue, "" ) ); // The value
      item.setText( 2, target.caseTargetStep == null ? "" : target.caseTargetStep.getName() ); // The target step name
    }
  }
  wValues.removeEmptyRows();
  wValues.setRowNums();
  wValues.optWidth( true );

  wDefaultTarget.setText( input.getDefaultTargetStep() == null ? "" : input.getDefaultTargetStep().getName() );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example #16
Source Project: pentaho-hadoop-shims   Author: pentaho   File: PluginPropertiesUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Loads a properties file from the plugin directory for the plugin interface provided
 *
 * @param plugin
 * @return
 * @throws KettleFileException
 * @throws IOException
 */
protected Properties loadProperties( PluginInterface plugin, String relativeName ) throws KettleFileException,
  IOException {
  if ( plugin == null ) {
    throw new NullPointerException();
  }
  FileObject propFile =
    KettleVFS.getFileObject( plugin.getPluginDirectory().getPath() + Const.FILE_SEPARATOR + relativeName );
  if ( !propFile.exists() ) {
    throw new FileNotFoundException( propFile.toString() );
  }
  try {
    return new PropertiesConfigurationProperties( propFile );
  } catch ( ConfigurationException e ) {
    throw new IOException( e );
  }
}
 
Example #17
Source Project: pentaho-kettle   Author: pentaho   File: HTTPPOSTDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void setComboBoxes() {
  // Something was changed in the row.
  //
  final Map<String, Integer> fields = new HashMap<String, Integer>();

  // Add the currentMeta fields...
  fields.putAll( inputFields );

  Set<String> keySet = fields.keySet();
  List<String> entries = new ArrayList<String>( keySet );

  fieldNames = entries.toArray( new String[entries.size()] );

  Const.sortStrings( fieldNames );
  colinf[0].setComboValues( fieldNames );
  colinfquery[0].setComboValues( fieldNames );
}
 
Example #18
Source Project: pentaho-kettle   Author: pentaho   File: ZIPCompressionOutputStream.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addEntry( String filename, String extension ) throws IOException {
  // remove folder hierarchy
  int index = filename.lastIndexOf( Const.FILE_SEPARATOR );
  String entryPath;
  if ( index != -1 ) {
    entryPath = filename.substring( index + 1 );
  } else {
    entryPath = filename;
  }

  // remove ZIP extension
  index = entryPath.toLowerCase().lastIndexOf( ".zip" );
  if ( index != -1 ) {
    entryPath = entryPath.substring( 0, index ) + entryPath.substring( index + ".zip".length() );
  }

  // add real extension if needed
  if ( !Utils.isEmpty( extension ) ) {
    entryPath += "." + extension;
  }

  ZipEntry zipentry = new ZipEntry( entryPath );
  zipentry.setComment( "Compressed by Kettle" );
  ( (ZipOutputStream) delegate ).putNextEntry( zipentry );
}
 
Example #19
Source Project: pentaho-cpython-plugin   Author: pentaho-labs   File: CPythonScriptExecutorDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void checkWidgets() {
  wtvScriptLocation.setEnabled( wbLoadScriptFile.getSelection() );
  wstcScriptEditor.setEnabled( !wbLoadScriptFile.getSelection() );
  if ( wbLoadScriptFile.getSelection() ) {
    wtvScriptLocation.setEditable( true );
    wstcScriptEditor.getStyledText().setBackground( GUIResource.getInstance().getColorDemoGray() );
  } else {
    wtvScriptLocation.setEditable( false );
    wstcScriptEditor.getStyledText().setBackground( GUIResource.getInstance().getColorWhite() );
  }
  wbScriptBrowse.setEnabled( wbLoadScriptFile.getSelection() );

  String currVars = wtvPyVarsToGet.getText();
  if ( !Const.isEmpty( currVars ) ) {
    List<String> varList = stringToList( currVars );
    wbGetFields.setEnabled( varList.size() == 1 );
    wbIncludeRowIndex.setEnabled( varList.size() == 1 );
  }
}
 
Example #20
Source Project: pentaho-kettle   Author: pentaho   File: CarteStatusCache.java    License: Apache License 2.0 6 votes vote down vote up
public void put( String logId, String cacheString, int from ) {
  String randomPref = UUID.randomUUID().toString();
  File file = null;
  try {
    file = File.createTempFile( randomPref, null );
    file.deleteOnExit();
    Files.write( file.toPath(), cacheString.getBytes( Const.XML_ENCODING ) );
    CachedItem item = new CachedItem( file, from );
    if ( ( item = cachedMap.put( logId, item ) ) != null ) {
      removeTask( item.getFile() );
    }
  } catch ( Exception e ) {
    cachedMap.remove( logId );
    if ( file != null ) {
      file.delete();
    }
  }
}
 
Example #21
Source Project: pentaho-cpython-plugin   Author: pentaho-labs   File: CPythonScriptExecutorDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Ok general method
 */
private void ok() {
  if ( Const.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  setData( m_inputMeta );
  if ( !m_originalMeta.equals( m_inputMeta ) ) {
    m_inputMeta.setChanged();
    changed = m_inputMeta.hasChanged();
  }

  dispose();
}
 
Example #22
Source Project: pentaho-kettle   Author: pentaho   File: Delete.java    License: Apache License 2.0 5 votes vote down vote up
public void prepareDelete( RowMetaInterface rowMeta ) throws KettleDatabaseException {
  DatabaseMeta databaseMeta = meta.getDatabaseMeta();
  data.deleteParameterRowMeta = new RowMeta();

  String sql = "DELETE FROM " + data.schemaTable + Const.CR;

  sql += "WHERE ";

  for ( int i = 0; i < meta.getKeyLookup().length; i++ ) {
    if ( i != 0 ) {
      sql += "AND   ";
    }
    sql += databaseMeta.quoteField( meta.getKeyLookup()[i] );
    if ( "BETWEEN".equalsIgnoreCase( meta.getKeyCondition()[i] ) ) {
      sql += " BETWEEN ? AND ? ";
      data.deleteParameterRowMeta.addValueMeta( rowMeta.searchValueMeta( meta.getKeyStream()[i] ) );
      data.deleteParameterRowMeta.addValueMeta( rowMeta.searchValueMeta( meta.getKeyStream2()[i] ) );
    } else if ( "IS NULL".equalsIgnoreCase( meta.getKeyCondition()[i] )
      || "IS NOT NULL".equalsIgnoreCase( meta.getKeyCondition()[i] ) ) {
      sql += " " + meta.getKeyCondition()[i] + " ";
    } else {
      sql += " " + meta.getKeyCondition()[i] + " ? ";
      data.deleteParameterRowMeta.addValueMeta( rowMeta.searchValueMeta( meta.getKeyStream()[i] ) );
    }
  }

  try {
    if ( log.isDetailed() ) {
      logDetailed( "Setting delete preparedStatement to [" + sql + "]" );
    }
    data.prepStatementDelete = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sql ) );
  } catch ( SQLException ex ) {
    throw new KettleDatabaseException( "Unable to prepare statement for SQL statement [" + sql + "]", ex );
  }
}
 
Example #23
Source Project: pentaho-kettle   Author: pentaho   File: ConfigurationDialog.java    License: Apache License 2.0 5 votes vote down vote up
protected void ok() {
  abstractMeta.setAlwaysShowRunOptions( alwaysShowOption.getSelection() );
  abstractMeta.setShowDialog( alwaysShowOption.getSelection() );
  if ( Const.isOSX() ) {
    // OSX bug workaround.
    wVariables.applyOSXChanges();
    wParams.applyOSXChanges();
  }
  getInfo();
  retval = true;
  dispose();
}
 
Example #24
Source Project: pentaho-hadoop-shims   Author: pentaho   File: DistributedCacheUtilImplOSDependentTest.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {

  PLUGIN_BASE = System.getProperty( Const.PLUGIN_BASE_FOLDERS_PROP );
  // Fake out the "plugins" directory for the project's root directory
  System.setProperty( Const.PLUGIN_BASE_FOLDERS_PROP, KettleVFS.getFileObject( "." ).getURL().toURI().getPath() );
}
 
Example #25
Source Project: pentaho-kettle   Author: pentaho   File: PropsUI.java    License: Apache License 2.0 5 votes vote down vote up
public String[] getLastPreview() {
  String snr = properties.getProperty( STRING_LAST_PREVIEW_STEP );
  int nr = Const.toInt( snr, 0 );
  String[] lp = new String[ nr ];
  for ( int i = 0; i < nr; i++ ) {
    lp[ i ] = properties.getProperty( STRING_LAST_PREVIEW_STEP + ( i + 1 ), "" );
  }
  return lp;
}
 
Example #26
Source Project: pentaho-kettle   Author: pentaho   File: NullIfMeta.java    License: Apache License 2.0 5 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder();

  retval.append( "    <fields>" + Const.CR );

  for ( int i = 0; i < fields.length; i++ ) {
    retval.append( "      <field>" + Const.CR );
    retval.append( "        " + XMLHandler.addTagValue( "name", fields[i].getFieldName() ) );
    retval.append( "        " + XMLHandler.addTagValue( "value", fields[i].getFieldValue() ) );
    retval.append( "        </field>" + Const.CR );
  }
  retval.append( "      </fields>" + Const.CR );

  return retval.toString();
}
 
Example #27
Source Project: pentaho-kettle   Author: pentaho   File: SalesforceUpdateDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Read the data from the TextFileInputMeta object and show it in this dialog.
 *
 * @param in
 *          The SalesforceUpdateMeta object to obtain the data from.
 */
public void getData( SalesforceUpdateMeta in ) {
  wURL.setText( Const.NVL( in.getTargetURL(), "" ) );
  wUserName.setText( Const.NVL( in.getUsername(), "" ) );
  wPassword.setText( Const.NVL( in.getPassword(), "" ) );
  wBatchSize.setText( in.getBatchSize() );
  wModule.setText( Const.NVL( in.getModule(), "Account" ) );
  wBatchSize.setText( "" + in.getBatchSize() );

  if ( isDebug() ) {
    logDebug( BaseMessages.getString( PKG, "SalesforceUpdateDialog.Log.GettingFieldsInfo" ) );
  }

  if ( input.getUpdateLookup() != null ) {
    for ( int i = 0; i < input.getUpdateLookup().length; i++ ) {
      TableItem item = wReturn.table.getItem( i );
      if ( input.getUpdateLookup()[i] != null ) {
        item.setText( 1, input.getUpdateLookup()[i] );
      }
      if ( input.getUpdateStream()[i] != null ) {
        item.setText( 2, input.getUpdateStream()[i] );
      }
      if ( input.getUseExternalId()[i] == null || input.getUseExternalId()[i].booleanValue() ) {
        item.setText( 3, "Y" );
      } else {
        item.setText( 3, "N" );
      }
    }
  }

  wReturn.removeEmptyRows();
  wReturn.setRowNums();
  wReturn.optWidth( true );
  wTimeOut.setText( Const.NVL( in.getTimeout(), SalesforceConnectionUtils.DEFAULT_TIMEOUT ) );
  wUseCompression.setSelection( in.isCompression() );
  wRollbackAllChangesOnError.setSelection( in.isRollbackAllChangesOnError() );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example #28
Source Project: pentaho-kettle   Author: pentaho   File: PostgreSQLDatabaseMeta.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param tableNames
 *          The names of the tables to lock
 * @return The SQL commands to lock database tables for write purposes.
 */
@Override
public String getSQLLockTables( String[] tableNames ) {
  String sql = "LOCK TABLE ";
  for ( int i = 0; i < tableNames.length; i++ ) {
    if ( i > 0 ) {
      sql += ", ";
    }
    sql += tableNames[i] + " ";
  }
  sql += "IN ACCESS EXCLUSIVE MODE;" + Const.CR;

  return sql;
}
 
Example #29
Source Project: pentaho-kettle   Author: pentaho   File: JaninoDialog.java    License: Apache License 2.0 5 votes vote down vote up
protected void setComboBoxes() {
  // Something was changed in the row.
  //
  final Map<String, Integer> fields = new HashMap<String, Integer>();

  // Add the currentMeta fields...
  fields.putAll( inputFields );

  shell.getDisplay().syncExec( new Runnable() {
    public void run() {
      // Add the newly create fields.
      //
      /*
       * int nrNonEmptyFields = wFields.nrNonEmpty(); for (int i=0;i<nrNonEmptyFields;i++) { TableItem item =
       * wFields.getNonEmpty(i); fields.put(item.getText(1), new Integer(1000000+i)); // The number is just to debug
       * the origin of the fieldname }
       */

      Set<String> keySet = fields.keySet();
      List<String> entries = new ArrayList<String>( keySet );

      String[] fieldNames = entries.toArray( new String[entries.size()] );

      Const.sortStrings( fieldNames );

      colinf[5].setComboValues( fieldNames );
    }
  } );

}
 
Example #30
Source Project: pentaho-kettle   Author: pentaho   File: StreamLookupDialog.java    License: Apache License 2.0 5 votes vote down vote up
protected void setComboBoxes() {
  //
  // Search the fields in the background
  //

  final Runnable runnable = new Runnable() {
    public void run() {
      StepMeta stepMeta = transMeta.findStep( stepname );
      if ( stepMeta != null ) {
        try {
          RowMetaInterface row = transMeta.getPrevStepFields( stepMeta );
          Map<String, Integer> prevFields = new HashMap<String, Integer>();
          // Remember these fields...
          for ( int i = 0; i < row.size(); i++ ) {
            prevFields.put( row.getValueMeta( i ).getName(), Integer.valueOf( i ) );
          }

          // Something was changed in the row.
          //
          final Map<String, Integer> fields = new HashMap<String, Integer>();

          // Add the currentMeta fields...
          fields.putAll( prevFields );

          Set<String> keySet = fields.keySet();
          List<String> entries = new ArrayList<String>( keySet );

          String[] fieldNames = entries.toArray( new String[entries.size()] );
          Const.sortStrings( fieldNames );
          // return fields
          ciKey[0].setComboValues( fieldNames );
        } catch ( KettleException e ) {
          logError( BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ) );
        }
      }
    }
  };
  new Thread( runnable ).start();

}