Java Code Examples for org.pentaho.di.i18n.BaseMessages#getString()

The following examples show how to use org.pentaho.di.i18n.BaseMessages#getString() . 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: ColumnExistsDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    String columnName = wColumnName.getText();
    String tableName = wTableName.getText();

    wColumnName.removeAll();
    wTableName.removeAll();
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      r.getFieldNames();

      for ( int i = 0; i < r.getFieldNames().length; i++ ) {
        wTableName.add( r.getFieldNames()[i] );
        wColumnName.add( r.getFieldNames()[i] );
      }
    }
    wColumnName.setText( columnName );
    wTableName.setText( tableName );
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "ColumnExistsDialog.FailedToGetFields.DialogTitle" ),
        BaseMessages.getString( PKG, "ColumnExistsDialog.FailedToGetFields.DialogMessage" ), ke );
  }

}
 
Example 2
Source File: RulesExecutorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void loadXML( Node stepnode, List<DatabaseMeta> _databases, IMetaStore metaStore ) throws KettleXMLException {
  try {
    Node fields = XMLHandler.getSubNode( stepnode, StorageKeys.NODE_FIELDS.toString() );
    int nrfields = XMLHandler.countNodes( fields, StorageKeys.SUBNODE_FIELD.toString() );

    ValueMetaInterface vm = null;
    for ( int i = 0; i < nrfields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, StorageKeys.SUBNODE_FIELD.toString(), i );

      String name = XMLHandler.getTagValue( fnode, StorageKeys.COLUMN_NAME.toString() );
      int type = ValueMeta.getType( XMLHandler.getTagValue( fnode, StorageKeys.COLUMN_TYPE.toString() ) );

      vm = ValueMetaFactory.createValueMeta( name, type );
      getRuleResultColumns().add( vm );
    }

    setRuleFile( XMLHandler.getTagValue( stepnode, StorageKeys.RULE_FILE.toString() ) );
    setRuleDefinition( XMLHandler.getTagValue( stepnode, StorageKeys.RULE_DEFINITION.toString() ) );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "RulesMeta.Error.LoadFromXML" ), e );
  }
}
 
Example 3
Source File: AbsSecurityManager.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public List<String> getLocalizedLogicalRoles( String runtimeRole, String locale ) throws KettleException {
  if ( authorizationPolicyRoleBindingService != null ) {
    List<String> localizedLogicalRoles = new ArrayList<String>();
    if ( roleBindingStruct != null && roleBindingStruct.logicalRoleNameMap != null ) {
      List<String> logicalRoles = getLogicalRoles( runtimeRole );
      for ( String logicalRole : logicalRoles ) {
        localizedLogicalRoles.add( roleBindingStruct.logicalRoleNameMap.get( logicalRole ) );
      }
    } else {
      throw new KettleException( BaseMessages.getString( AbsSecurityManager.class,
          "AbsSecurityManager.ERROR_0003_UNABLE_TO_ACCESS_ROLE_BINDING_WEBSVC" ) ); //$NON-NLS-1$
    }
    return localizedLogicalRoles;
  } else {
    throw new KettleException( BaseMessages.getString( AbsSecurityManager.class,
        "AbsSecurityManager.ERROR_0005_INSUFFICIENT_PRIVELEGES" ) ); //$NON-NLS-1$
  }
}
 
Example 4
Source File: FilterRowsMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {
  try {
    allocate();

    setTrueStepname( rep.getStepAttributeString( id_step, "send_true_to" ) );
    setFalseStepname( rep.getStepAttributeString( id_step, "send_false_to" ) );

    condition = rep.loadConditionFromStepAttribute( id_step, "id_condition" );

  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString(
      PKG, "FilterRowsMeta.Exception.UnexpectedErrorInReadingStepInfoFromRepository" ), e );
  }
}
 
Example 5
Source File: KafkaConsumerMetaTest.java    From pentaho-kafka-consumer with Apache License 2.0 5 votes vote down vote up
private void hasi18nValue(String i18nPackageName, String messageId) {
    String fakeId = UUID.randomUUID().toString();
    String fakeLocalized = BaseMessages.getString(i18nPackageName, fakeId);
    assertEquals("The way to identify a missing localization key has changed", "!" + fakeId + "!", fakeLocalized);

    // Real Test
    String localized = BaseMessages.getString(i18nPackageName, messageId);
    assertFalse(Utils.isEmpty(localized));
    assertNotEquals("!" + messageId + "!", localized);
}
 
Example 6
Source File: ConnectionPoolUtil.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private static boolean isDataSourceRegistered( DatabaseMeta dbMeta, String partitionId )
  throws KettleDatabaseException {
  try {
    String name = getDataSourceName( dbMeta, partitionId );
    return dataSources.containsKey( name );
  } catch ( Exception e ) {
    throw new KettleDatabaseException( BaseMessages.getString( PKG,
        "Database.UnableToCheckIfConnectionPoolExists.Exception" ), e );
  }
}
 
Example 7
Source File: DatabaseLookup.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
void determineFieldsTypesQueryingDb() throws KettleException {
  final String[] keyFields = meta.getTableKeyField();
  data.keytypes = new int[ keyFields.length ];

  String schemaTable =
    meta.getDatabaseMeta().getQuotedSchemaTableCombination(
      environmentSubstitute( meta.getSchemaName() ), environmentSubstitute( meta.getTablename() ) );

  RowMetaInterface fields = data.db.getTableFields( schemaTable );
  if ( fields != null ) {
    // Fill in the types...
    for ( int i = 0; i < keyFields.length; i++ ) {
      ValueMetaInterface key = fields.searchValueMeta( keyFields[ i ] );
      if ( key != null ) {
        data.keytypes[ i ] = key.getType();
      } else {
        throw new KettleStepException( BaseMessages.getString(
          PKG, "DatabaseLookup.ERROR0001.FieldRequired5.Exception" )
          + keyFields[ i ]
          + BaseMessages.getString( PKG, "DatabaseLookup.ERROR0001.FieldRequired6.Exception" ) );
      }
    }

    if ( shouldDatabaseReturnValueTypeBeUsed() ) {
      useReturnValueTypeFromDatabase( fields );
    }

  } else {
    throw new KettleStepException( BaseMessages.getString(
      PKG, "DatabaseLookup.ERROR0002.UnableToDetermineFieldsOfTable" )
      + schemaTable + "]" );
  }
}
 
Example 8
Source File: GetStatusServlet.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private String messageDialog() {
  String retVal =
    "<div id=\"messageDialogBackdrop\" style=\"visibility: hidden; position: absolute; top: 0; right: 0; bottom: 0;"
      + " left: 0; opacity: 0.5; background-color: #000; z-index: 1000;\"></div>\n";
  retVal +=
    "<div class=\"pentaho-dialog\" id=\"messageDialog\" style=\"visibility: hidden; margin: 0; position: absolute; "
      + "top: 50%; left: 50%; transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%);"
      + "-webkit-transform: translate(-50%, -50%); padding: 30px; height: auto; width: 423px; border: 1px solid "
      + "#CCC; -webkit-box-shadow: none; -moz-box-shadow: none;"
      + "box-shadow: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; "
      + "overflow: hidden; line-height: 20px; background-color: #FFF; z-index: 10000;\">\n";
  retVal += "<div id=\"messageDialogTitle\" class=\"Caption\"></div>\n";
  retVal += "<div id=\"messageDialogBody\" class=\"dialog-content\"></div>\n";
  retVal +=
    "<div id=\"singleButton\" style=\"margin-top: 30px;\">\n<button class=\"pentaho-button\" style=\"float: right;"
      + "\" onclick=\"closeMessageDialog( true );\">\n<span>"
      + BaseMessages.getString( PKG, "GetStatusServlet.Button.OK" ) + "</span>\n</button>\n</div>\n";
  retVal +=
    "<div id=\"doubleButton\" style=\"margin-top: 30px;\">\n<button class=\"pentaho-button\" style=\"float: right; "
      + "margin-left: 10px;\" onclick=\"closeMessageDialog( false );\">\n<span>"
      + BaseMessages.getString( PKG, "GetStatusServlet.Button.No" )
      + "</span>\n</button>\n<button class=\"pentaho-button\" style=\"float: right;\" onclick=\"closeMessageDialog("
      + " false ); removeSelection();\">\n<span>"
      + BaseMessages.getString( PKG, "GetStatusServlet.Button.YesRemove" ) + "</span>\n</button>\n</div>\n";
  retVal += "</div>\n";
  return retVal;
}
 
Example 9
Source File: TextFileOutput.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void createParentFolder( String filename ) throws Exception {
  // Check for parent folder
  FileObject parentfolder = null;
  try {
    // Get parent folder
    parentfolder = getFileObject( filename, getTransMeta() ).getParent();
    if ( parentfolder.exists() ) {
      if ( isDetailed() ) {
        logDetailed( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderExist",
            KettleVFS.getFriendlyURI( parentfolder ) ) );
      }
    } else {
      if ( isDetailed() ) {
        logDetailed( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderNotExist",
            KettleVFS.getFriendlyURI( parentfolder ) ) );
      }
      if ( meta.isCreateParentFolder() ) {
        parentfolder.createFolder();
        if ( isDetailed() ) {
          logDetailed( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderCreated",
              KettleVFS.getFriendlyURI( parentfolder ) ) );
        }
      } else {
        throw new KettleException( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderNotExistCreateIt",
            KettleVFS.getFriendlyURI( parentfolder ), KettleVFS.getFriendlyURI( filename ) ) );
      }
    }
  } finally {
    if ( parentfolder != null ) {
      try {
        parentfolder.close();
      } catch ( Exception ex ) {
        // Ignore
      }
    }
  }
}
 
Example 10
Source File: JmsProducerDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private ColumnInfo[] getPropertiesColumns() {

    ColumnInfo propertyName = new ColumnInfo( BaseMessages.getString( PKG, "JmsProducerDialog.Properties.Column.Name" ),
      ColumnInfo.COLUMN_TYPE_TEXT, false, false );
    propertyName.setUsingVariables( true );

    ColumnInfo propertyValue =
      new ColumnInfo( BaseMessages.getString( PKG, "JmsProducerDialog.Properties.Column.Value" ),
        ColumnInfo.COLUMN_TYPE_TEXT, false, false );
    propertyValue.setUsingVariables( true );

    return new ColumnInfo[] { propertyName, propertyValue };
  }
 
Example 11
Source File: MqttDialogSecurityLayout.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private ColumnInfo[] getSSLColumns() {
  ColumnInfo optionName = new ColumnInfo( BaseMessages.getString( PKG, "MQTTDialog.Security.SSL.Column.Name" ),
    ColumnInfo.COLUMN_TYPE_TEXT, false, false );

  ColumnInfo value = new ColumnInfo( BaseMessages.getString( PKG, "MQTTDialog.Security.SSL.Column.Value" ),
    ColumnInfo.COLUMN_TYPE_TEXT, false, false, 200 );
  value.setUsingVariables( true );

  return new ColumnInfo[] { optionName, value };
}
 
Example 12
Source File: SparkTuningStepHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "squid:S1181" )
public void openSparkTuning() {
  TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
  StepMeta stepMeta = transGraph.getCurrentStep();
  String title = BaseMessages.getString( PKG, "TransGraph.Dialog.SparkTuning.Title" )
    + " - " + stepMeta.getName();

  List<String> tuningProperties = SparkTunableProperties.getProperties( stepMeta.getStepID() );

  PropertiesComboDialog dialog = new PropertiesComboDialog(
    transGraph.getParent().getShell(),
    transGraph.getTransMeta(),
    stepMeta.getAttributes( SPARK_TUNING_PROPERTIES ),
    title,
    Const.getDocUrl( BaseMessages.getString( PKG, "SparkTuning.Help.Url" ) ),
    BaseMessages.getString( PKG, "SparkTuning.Help.Title" ),
    BaseMessages.getString( PKG, "SparkTuning.Help.Header" )
  );
  dialog.setComboOptions( tuningProperties );
  try {
    Map<String, String> properties = dialog.open();

    // null means the cancel button was clicked otherwise ok was clicked
    if ( null != properties ) {
      stepMeta.setAttributes( SPARK_TUNING_PROPERTIES, properties );
      stepMeta.setChanged();
      transGraph.getSpoon().setShellText();
    }
  } catch ( Throwable e ) {
    new ErrorDialog(
      Spoon.getInstance().getShell(), BaseMessages.getString( PKG, "SparkTuning.UnexpectedError" ), BaseMessages
      .getString( PKG, "SparkTuning.UnexpectedError" ), e );
  }
}
 
Example 13
Source File: OraBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public RowMetaInterface getRequiredFields( VariableSpace space ) throws KettleException {
  String realTableName = space.environmentSubstitute( tableName );
  String realSchemaName = space.environmentSubstitute( schemaName );

  if ( databaseMeta != null ) {
    Database db = new Database( loggingObject, databaseMeta );
    try {
      db.connect();

      if ( !Utils.isEmpty( realTableName ) ) {
        String schemaTable = databaseMeta.getQuotedSchemaTableCombination( realSchemaName, realTableName );

        // Check if this table exists...
        if ( db.checkTableExists( schemaTable ) ) {
          return db.getTableFields( schemaTable );
        } else {
          throw new KettleException( BaseMessages.getString( PKG, "OraBulkLoaderMeta.Exception.TableNotFound" ) );
        }
      } else {
        throw new KettleException( BaseMessages.getString( PKG, "OraBulkLoaderMeta.Exception.TableNotSpecified" ) );
      }
    } catch ( Exception e ) {
      throw new KettleException(
        BaseMessages.getString( PKG, "OraBulkLoaderMeta.Exception.ErrorGettingFields" ), e );
    } finally {
      db.disconnect();
    }
  } else {
    throw new KettleException( BaseMessages.getString( PKG, "OraBulkLoaderMeta.Exception.ConnectionNotDefined" ) );
  }

}
 
Example 14
Source File: SimpleMappingDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

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

  try {
    loadTransformation();
  } catch ( KettleException e ) {
    new ErrorDialog( shell, BaseMessages.getString(
      PKG, "SimpleMappingDialog.ErrorLoadingSpecifiedTransformation.Title" ), BaseMessages.getString(
      PKG, "SimpleMappingDialog.ErrorLoadingSpecifiedTransformation.Message" ), e );
    return;
  }

  mappingMeta.setSpecificationMethod( getSpecificationMethod() );
  switch ( getSpecificationMethod() ) {
    case FILENAME:
      mappingMeta.setFileName( wPath.getText() );
      mappingMeta.setDirectoryPath( null );
      mappingMeta.setTransName( null );
      mappingMeta.setTransObjectId( null );
      break;
    case REPOSITORY_BY_NAME:
      String transPath = wPath.getText();
      String transName = transPath;
      String directory = "";
      int index = transPath.lastIndexOf( "/" );
      if ( index != -1 ) {
        transName = transPath.substring( index + 1 );
        directory = transPath.substring( 0, index );
      }
      mappingMeta.setDirectoryPath( directory );
      mappingMeta.setTransName( transName );
      mappingMeta.setFileName( null );
      mappingMeta.setTransObjectId( null );
    default:
      break;
  }

  // Load the information on the tabs, optionally do some
  // verifications...
  //
  collectInformation();

  mappingMeta.setMappingParameters( mappingParameters );
  mappingMeta.setInputMapping( inputMapping );
  mappingMeta.setOutputMapping( outputMapping );
  mappingMeta.setChanged( true );

  dispose();
}
 
Example 15
Source File: MailInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void preview() {
  try {
    MailInputMeta oneMeta = new MailInputMeta();
    getInfo( oneMeta );

    TransMeta previewMeta =
      TransPreviewFactory.generatePreviewTransformation( transMeta, oneMeta, wStepname.getText() );

    EnterNumberDialog numberDialog = new EnterNumberDialog( shell, props.getDefaultPreviewSize(),
      BaseMessages.getString( PKG, "MailInputDialog.NumberRows.DialogTitle" ),
      BaseMessages.getString( PKG, "MailInputDialog.NumberRows.DialogMessage" ) );

    int previewSize = numberDialog.open();
    if ( previewSize > 0 ) {
      TransPreviewProgressDialog progressDialog =
        new TransPreviewProgressDialog(
          shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize } );
      progressDialog.open();

      if ( !progressDialog.isCancelled() ) {
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();

        if ( trans.getResult() != null && trans.getResult().getNrErrors() > 0 ) {
          EnterTextDialog etd = new EnterTextDialog( shell,
            BaseMessages.getString( PKG, "System.Dialog.PreviewError.Title" ),
            BaseMessages.getString( PKG, "System.Dialog.PreviewError.Message" ), loggingText, true );
          etd.setReadOnly();
          etd.open();
        }
        PreviewRowsDialog prd =
          new PreviewRowsDialog(
            shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta( wStepname
              .getText() ), progressDialog.getPreviewRows( wStepname.getText() ), loggingText );
        prd.open();

      }
    }
  } catch ( KettleException e ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "MailInputDialog.ErrorPreviewingData.DialogTitle" ), BaseMessages
        .getString( PKG, "MailInputDialog.ErrorPreviewingData.DialogMessage" ), e );
  }
}
 
Example 16
Source File: ConnectionsController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void createConnection() {
  try {
    DatabaseMeta databaseMeta = new DatabaseMeta();
    databaseMeta.initializeVariablesFrom( null );
    getDatabaseDialog().setDatabaseMeta( databaseMeta );

    String dbName = getDatabaseDialog().open();
    if ( dbName != null ) {
      dbName = dbName.trim();
      databaseMeta.setName( dbName );
      databaseMeta.setDisplayName( dbName );
      getDatabaseDialog().setDatabaseMeta( databaseMeta );

      if ( !dbName.isEmpty() ) {
        // See if this user connection exists...
        ObjectId idDatabase = repository.getDatabaseID( dbName );
        if ( idDatabase == null ) {
          repository.insertLogEntry( BaseMessages.getString(
            PKG, "ConnectionsController.Message.CreatingDatabase", getDatabaseDialog()
              .getDatabaseMeta().getName() ) );
          repository.save( getDatabaseDialog().getDatabaseMeta(), Const.VERSION_COMMENT_INITIAL_VERSION, null );
          reloadLoadedJobsAndTransformations();
        } else {
          showAlreadyExistsMessage();
        }
      }
    }
    // We should be able to tell the difference between a cancel and an empty database name
    //
    // else {
    // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
    // mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Message"));
    // mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Title"));
    // mb.open();
    // }
  } catch ( KettleException e ) {
    if ( mainController == null || !mainController.handleLostRepository( e ) ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title" ),
        BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Message" ), e );
    }
  } finally {
    refreshConnectionList();
  }
}
 
Example 17
Source File: GetPreviewTableProgressDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Showing an error dialog
 *
 * @param e
 */
private void showErrorDialog( Exception e ) {
  new ErrorDialog(
    shell, BaseMessages.getString( PKG, "GetPreviewTableProgressDialog.Error.Title" ), BaseMessages.getString(
      PKG, "GetPreviewTableProgressDialog.Error.Message" ), e );
}
 
Example 18
Source File: MySQLBulkLoader.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public boolean execute( MySQLBulkLoaderMeta meta ) throws KettleException {
  Runtime rt = Runtime.getRuntime();

  try {
    // 1) Create the FIFO file using the "mkfifo" command...
    // Make sure to log all the possible output, also from STDERR
    //
    data.fifoFilename = environmentSubstitute( meta.getFifoFileName() );

    File fifoFile = new File( data.fifoFilename );
    if ( !fifoFile.exists() ) {
      // MKFIFO!
      //
      String mkFifoCmd = "mkfifo " + data.fifoFilename;
      //
      logBasic( BaseMessages.getString( PKG, "MySQLBulkLoader.Message.CREATINGFIFO",  data.dbDescription, mkFifoCmd ) );
      Process mkFifoProcess = rt.exec( mkFifoCmd );
      StreamLogger errorLogger = new StreamLogger( log, mkFifoProcess.getErrorStream(), "mkFifoError" );
      StreamLogger outputLogger = new StreamLogger( log, mkFifoProcess.getInputStream(), "mkFifoOuptut" );
      new Thread( errorLogger ).start();
      new Thread( outputLogger ).start();
      int result = mkFifoProcess.waitFor();
      if ( result != 0 ) {
        throw new Exception( BaseMessages.getString( PKG, "MySQLBulkLoader.Message.ERRORFIFORC", result, mkFifoCmd ) );
      }

      String chmodCmd = "chmod 666 " + data.fifoFilename;
      logBasic( BaseMessages.getString( PKG, "MySQLBulkLoader.Message.SETTINGPERMISSIONSFIFO",  data.dbDescription, chmodCmd ) );
      Process chmodProcess = rt.exec( chmodCmd );
      errorLogger = new StreamLogger( log, chmodProcess.getErrorStream(), "chmodError" );
      outputLogger = new StreamLogger( log, chmodProcess.getInputStream(), "chmodOuptut" );
      new Thread( errorLogger ).start();
      new Thread( outputLogger ).start();
      result = chmodProcess.waitFor();
      if ( result != 0 ) {
        throw new Exception( BaseMessages.getString( PKG, "MySQLBulkLoader.Message.ERRORFIFORC", result, chmodCmd ) );
      }
    }

    // 2) Make a connection to MySQL for sending SQL commands
    // (Also, we need a clear cache for getting up-to-date target metadata)
    DBCache.getInstance().clear( meta.getDatabaseMeta().getName() );
    if ( meta.getDatabaseMeta() == null ) {
      logError( BaseMessages.getString( PKG, "MySQLBulkLoader.Init.ConnectionMissing", getStepname() ) );
      return false;
    }
    data.db = new Database( this, meta.getDatabaseMeta() );
    data.db.shareVariablesWith( this );
    PluginInterface dbPlugin =
        PluginRegistry.getInstance().getPlugin( DatabasePluginType.class, meta.getDatabaseMeta().getDatabaseInterface() );
    data.dbDescription = ( dbPlugin != null ) ? dbPlugin.getDescription() : BaseMessages.getString( PKG, "MySQLBulkLoader.UnknownDB" );

    // Connect to the database
    if ( getTransMeta().isUsingUniqueConnections() ) {
      synchronized ( getTrans() ) {
        data.db.connect( getTrans().getTransactionId(), getPartitionID() );
      }
    } else {
      data.db.connect( getPartitionID() );
    }

    logBasic( BaseMessages.getString( PKG, "MySQLBulkLoader.Message.CONNECTED",  data.dbDescription ) );

    // 3) Now we are ready to run the load command...
    //
    executeLoadCommand();
  } catch ( Exception ex ) {
    throw new KettleException( ex );
  }

  return true;
}
 
Example 19
Source File: DimensionLookupMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases )
  throws KettleException {
  try {
    this.databases = databases;
    databaseMeta = rep.loadDatabaseMetaFromStepAttribute( id_step, "id_connection", databases );

    schemaName = rep.getStepAttributeString( id_step, "schema" );
    tableName = rep.getStepAttributeString( id_step, "table" );
    commitSize = (int) rep.getStepAttributeInteger( id_step, "commit" );
    update = rep.getStepAttributeBoolean( id_step, "update" );

    int nrkeys = rep.countNrStepAttributes( id_step, "lookup_key_name" );
    int nrfields = rep.countNrStepAttributes( id_step, "field_update" );

    allocate( nrkeys, nrfields );

    for ( int i = 0; i < nrkeys; i++ ) {
      keyStream[i] = rep.getStepAttributeString( id_step, i, "lookup_key_name" );
      keyLookup[i] = rep.getStepAttributeString( id_step, i, "lookup_key_field" );
    }

    dateField = rep.getStepAttributeString( id_step, "date_name" );
    dateFrom = rep.getStepAttributeString( id_step, "date_from" );
    dateTo = rep.getStepAttributeString( id_step, "date_to" );

    for ( int i = 0; i < nrfields; i++ ) {
      fieldStream[i] = rep.getStepAttributeString( id_step, i, "field_name" );
      fieldLookup[i] = rep.getStepAttributeString( id_step, i, "field_lookup" );
      fieldUpdate[i] = getUpdateType( update, rep.getStepAttributeString( id_step, i, "field_update" ) );
      if ( !update ) {
        returnType[i] = fieldUpdate[i];
      }
    }

    keyField = rep.getStepAttributeString( id_step, "return_name" );
    keyRename = rep.getStepAttributeString( id_step, "return_rename" );
    autoIncrement = rep.getStepAttributeBoolean( id_step, "use_autoinc" );
    versionField = rep.getStepAttributeString( id_step, "version_field" );
    techKeyCreation = rep.getStepAttributeString( id_step, "creation_method" );
    if ( update ) { // symmetry with readData above ...
      sequenceName = rep.getStepAttributeString( id_step, "sequence" );
    }
    minYear = (int) rep.getStepAttributeInteger( id_step, "min_year" );
    maxYear = (int) rep.getStepAttributeInteger( id_step, "max_year" );

    cacheSize = (int) rep.getStepAttributeInteger( id_step, "cache_size" );
    preloadingCache = rep.getStepAttributeBoolean( id_step, "preload_cache" );
    useBatchUpdate = rep.getStepAttributeBoolean( id_step, "useBatch" );

    usingStartDateAlternative = rep.getStepAttributeBoolean( id_step, "use_start_date_alternative" );
    startDateAlternative = getStartDateAlternative( rep.getStepAttributeString( id_step, "start_date_alternative" ) );
    startDateFieldName = rep.getStepAttributeString( id_step, "start_date_field_name" );
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString( PKG,
        "DimensionLookupMeta.Exception.UnexpectedErrorReadingStepInfoFromRepository" ), e );
  }
}
 
Example 20
Source File: FTPSConnection.java    From pentaho-kettle with Apache License 2.0 3 votes vote down vote up
/**
 *
 * this method change FTP working directory
 *
 * @param directory
 *          change the working directory
 * @throws KettleException
 */
public void changeDirectory( String directory ) throws KettleException {
  try {
    this.connection.changeDirectory( directory );
  } catch ( Exception f ) {
    throw new KettleException( BaseMessages.getString( PKG, "JobFTPS.Error.ChangingFolder", directory ), f );
  }
}