org.pentaho.di.core.Const Java Examples

The following examples show how to use org.pentaho.di.core.Const. 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: ConfigurationDialog.java    From pentaho-kettle with 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 #2
Source File: CPythonScriptExecutorDialog.java    From pentaho-cpython-plugin with 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 #3
Source File: JobExecutionConfigurationDialog.java    From pentaho-kettle with 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 #4
Source File: CPythonScriptExecutorDialog.java    From pentaho-cpython-plugin with 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 #5
Source File: CarteStatusCache.java    From pentaho-kettle with 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 #6
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with 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 #7
Source File: ZIPCompressionOutputStream.java    From pentaho-kettle with 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 #8
Source File: JobEntryWaitForSQLDialog.java    From pentaho-kettle with 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 #9
Source File: TextFileOutput.java    From pentaho-kettle with 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 #10
Source File: HTTPPOSTDialog.java    From pentaho-kettle with 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 #11
Source File: PluginPropertiesUtil.java    From pentaho-hadoop-shims with 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 #12
Source File: SwitchCaseDialog.java    From pentaho-kettle with 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 #13
Source File: CreateDatabaseWizardPageJDBC.java    From pentaho-kettle with 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 #14
Source File: ValueDataUtilTest.java    From pentaho-kettle with 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 #15
Source File: ValueDataUtil.java    From pentaho-kettle with 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 #16
Source File: GetPreviousRowFieldMeta.java    From pentaho-kettle with 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 #17
Source File: SplitFieldToRows.java    From pentaho-kettle with 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 #18
Source File: TextVar.java    From pentaho-kettle with 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 #19
Source File: PaloCellInputDialog.java    From pentaho-kettle with 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 #20
Source File: JobEntryMssqlBulkLoadDialog.java    From pentaho-kettle with 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 #21
Source File: DynamicSQLRowMeta.java    From pentaho-kettle with 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 #22
Source File: SocketWriterDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

  wPort.setText( Const.NVL( input.getPort(), "" ) );
  wBufferSize.setText( Const.NVL( input.getBufferSize(), "" ) );
  wFlushInterval.setText( Const.NVL( input.getFlushInterval(), "" ) );
  wCompressed.setSelection( input.isCompressed() );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example #23
Source File: XsltMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public String getXML() {
  StringBuffer retval = new StringBuffer();

  retval.append( "    " + XMLHandler.addTagValue( "xslfilename", xslFilename ) );
  retval.append( "    " + XMLHandler.addTagValue( "fieldname", fieldName ) );
  retval.append( "    " + XMLHandler.addTagValue( "resultfieldname", resultFieldname ) );
  retval.append( "    " + XMLHandler.addTagValue( "xslfilefield", xslFileField ) );
  retval.append( "    " + XMLHandler.addTagValue( "xslfilefielduse", xslFileFieldUse ) );
  retval.append( "    " + XMLHandler.addTagValue( "xslfieldisafile", xslFieldIsAFile ) );

  retval.append( "    " + XMLHandler.addTagValue( "xslfactory", xslFactory ) );
  retval.append( "    <parameters>" ).append( Const.CR );

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

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

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

  retval.append( "    </outputproperties>" ).append( Const.CR );
  return retval.toString();
}
 
Example #24
Source File: JobEntryFTPSPUT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadRep( Repository rep, IMetaStore metaStore, ObjectId id_jobentry, List<DatabaseMeta> databases,
  List<SlaveServer> slaveServers ) throws KettleException {
  try {
    serverName = rep.getJobEntryAttributeString( id_jobentry, "servername" );
    serverPort = rep.getJobEntryAttributeString( id_jobentry, "serverport" );
    userName = rep.getJobEntryAttributeString( id_jobentry, "username" );
    password =
      Encr.decryptPasswordOptionallyEncrypted( rep.getJobEntryAttributeString( id_jobentry, "password" ) );
    remoteDirectory = rep.getJobEntryAttributeString( id_jobentry, "remoteDirectory" );
    localDirectory = rep.getJobEntryAttributeString( id_jobentry, "localDirectory" );
    wildcard = rep.getJobEntryAttributeString( id_jobentry, "wildcard" );
    binaryMode = rep.getJobEntryAttributeBoolean( id_jobentry, "binary" );
    timeout = (int) rep.getJobEntryAttributeInteger( id_jobentry, "timeout" );
    remove = rep.getJobEntryAttributeBoolean( id_jobentry, "remove" );
    onlyPuttingNewFiles = rep.getJobEntryAttributeBoolean( id_jobentry, "only_new" );
    activeConnection = rep.getJobEntryAttributeBoolean( id_jobentry, "active" );

    proxyHost = rep.getJobEntryAttributeString( id_jobentry, "proxy_host" );
    proxyPort = rep.getJobEntryAttributeString( id_jobentry, "proxy_port" );
    proxyUsername = rep.getJobEntryAttributeString( id_jobentry, "proxy_username" );
    proxyPassword = rep.getJobEntryAttributeString( id_jobentry, "proxy_password" );
    connectionType =
      FTPSConnection.getConnectionTypeByCode( Const.NVL( rep.getJobEntryAttributeString(
        id_jobentry, "connection_type" ), "" ) );
  } catch ( KettleException dbe ) {
    throw new KettleException( BaseMessages.getString( PKG, "JobFTPSPUT.UnableToLoadFromRepo", String
      .valueOf( id_jobentry ) ), dbe );
  }
}
 
Example #25
Source File: KettleFileRepositoryIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void storeFile( String xml, String filename ) throws Exception {
  File file = new File( filename );
  FileOutputStream fos = new FileOutputStream( file );

  fos.write( XMLHandler.getXMLHeader( Const.XML_ENCODING ).getBytes( Const.XML_ENCODING ) );
  fos.write( xml.getBytes( Const.XML_ENCODING ) );
  fos.close();

}
 
Example #26
Source File: CreateDatabaseWizardPageInformix.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void createControl( Composite parent ) {
  int margin = Const.MARGIN;
  int middle = props.getMiddlePct();

  // create the composite to hold the widgets
  Composite composite = new Composite( parent, SWT.NONE );
  props.setLook( composite );

  FormLayout compLayout = new FormLayout();
  compLayout.marginHeight = Const.FORM_MARGIN;
  compLayout.marginWidth = Const.FORM_MARGIN;
  composite.setLayout( compLayout );

  wlServername = new Label( composite, SWT.RIGHT );
  wlServername.setText( BaseMessages.getString( PKG, "CreateDatabaseWizardPageInformix.Servername.Label" ) );
  props.setLook( wlServername );
  fdlServername = new FormData();
  fdlServername.top = new FormAttachment( 0, 0 );
  fdlServername.left = new FormAttachment( 0, 0 );
  fdlServername.right = new FormAttachment( middle, 0 );
  wlServername.setLayoutData( fdlServername );

  wServername = new Text( composite, SWT.SINGLE | SWT.BORDER );
  props.setLook( wServername );
  fdServername = new FormData();
  fdServername.top = new FormAttachment( 0, 0 );
  fdServername.left = new FormAttachment( middle, margin );
  fdServername.right = new FormAttachment( 100, 0 );
  wServername.setLayoutData( fdServername );
  wServername.addModifyListener( new ModifyListener() {
    public void modifyText( ModifyEvent arg0 ) {
      setPageComplete( false );
    }
  } );

  // set the composite as the control for this page
  setControl( composite );
}
 
Example #27
Source File: MongoDbInputMetaTest.java    From pentaho-mongodb-plugin with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws KettleException {
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init();
  String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example #28
Source File: Delete.java    From pentaho-kettle with 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 #29
Source File: SplitFieldToRowsDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void getData() {
  wSplitfield.setText( Const.NVL( input.getSplitField(), "" ) );
  wDelimiter.setText( Const.NVL( input.getDelimiter(), "" ) );
  wValName.setText( Const.NVL( input.getNewFieldname(), "" ) );
  wInclRownum.setSelection( input.includeRowNumber() );
  wDelimiterIsRegex.setSelection( input.isDelimiterRegex() );
  if ( input.getRowNumberField() != null ) {
    wInclRownumField.setText( input.getRowNumberField() );
  }
  wResetRownum.setSelection( input.resetRowNumber() );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example #30
Source File: ValueMetaAndDataTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest( { EnvUtil.class } )
public void testLoadXML() throws ParseException, KettleXMLException {
  PowerMockito.mockStatic( EnvUtil.class );
  Mockito.when( EnvUtil.getSystemProperty( Const.KETTLE_DEFAULT_DATE_FORMAT ) )
    .thenReturn( "yyyy-MM-dd HH:mm:ss.SSS" );
  ValueMetaAndData valueMetaAndData = new ValueMetaAndData( Mockito.mock( ValueMetaInterface.class ), new Object() );
  List<PluginInterface> pluginTypeList = new ArrayList<>();
  PluginInterface plugin = Mockito.mock( PluginInterface.class );
  Mockito.when( plugin.getName() ).thenReturn( "3" );
  String[] ids = { "3" };
  Mockito.when( plugin.getIds() ).thenReturn( ids );
  pluginTypeList.add( plugin );
  Mockito.when( pluginRegistry.getPlugins( ValueMetaPluginType.class ) ).thenReturn( pluginTypeList );
  ValueMetaFactory.pluginRegistry = pluginRegistry;

  String testData = "2010/01/01 00:00:00.000";
  Node node = XMLHandler.loadXMLString(
    "<value>\n"
      + "    <name/>\n"
      + "    <type>3</type>\n"
      + "    <text>" + testData + "</text>\n"
      + "    <length>-1</length>\n"
      + "    <precision>-1</precision>\n"
      + "    <isnull>N</isnull>\n"
      + "    <mask/>\n"
      + "</value>", "value" );

  valueMetaAndData.loadXML( node );
  Assert.assertEquals( valueMetaAndData.getValueData(),
    new SimpleDateFormat( ValueMetaBase.COMPATIBLE_DATE_FORMAT_PATTERN ).parse( testData ) );
}