/** * @param key * key to set. * @return new string property. * @throws IllegalArgumentException * if key is invalid. */ public StringPluginProperty createString( final String key ) throws IllegalArgumentException { final StringPluginProperty property = new StringPluginProperty( key ); this.properties.add( property ); return property; }
/** * {@inheritDoc} * * @see at.aschauer.commons.pentaho.plugin.PluginProperty#evaluate() */ public boolean evaluate() { return StringUtils.isNotBlank( this.getValue() ); }
/** * {@inheritDoc} * * @see org.pentaho.di.trans.step.StepMetaInterface#setDefault() */ public void setDefault() { this.fastloadPath.setValue( DEFAULT_FASTLOAD_PATH ); this.dataFile.setValue( DEFAULT_DATA_FILE ); this.sessions.setValue( DEFAULT_SESSIONS ); this.errorLimit.setValue( DEFAULT_ERROR_LIMIT ); this.truncateTable.setValue( DEFAULT_TRUNCATETABLE ); this.variableSubstitution.setValue( DEFAULT_VARIABLE_SUBSTITUTION ); this.targetTable.setValue( DEFAULT_TARGET_TABLE ); this.useControlFile.setValue( true ); }
/** * @param databaseList * A list of available DatabaseMeta in this transformation. */ private void initDbMeta( final List<DatabaseMeta> databaseList ) { if ( !StringUtils.isEmpty( this.connectionName.getValue() ) ) { this.dbMeta = DatabaseMeta.findDatabase( databaseList, this.connectionName.getValue() ); } }
/** * {@inheritDoc} * * @see at.aschauer.commons.pentaho.plugin.PluginProperty#saveToRepositoryStep(org.pentaho.di.repository.Repository, * long, long) */ public void saveToRepositoryStep( final Repository repository, final IMetaStore metaStore, final ObjectId transformationId, final ObjectId stepId ) throws KettleException { repository.saveStepAttribute( transformationId, stepId, this.getKey(), this.getValue() ); }
/** * {@inheritDoc} * * @see at.aschauer.commons.pentaho.plugin.PluginProperty#readFromRepositoryStep(org.pentaho.di.repository.Repository, * long) */ public void readFromRepositoryStep( final Repository repository, final IMetaStore metaStore, final ObjectId stepId ) throws KettleException { final String value = repository.getStepAttributeString( stepId, this.getKey() ); this.setValue( value ); }
/** * Ok clicked. */ public void ok() { this.stepname = this.wStepname.getText(); // return value this.meta.getUseControlFile().setValue( this.wUseControlFile.getSelection() ); this.meta.getVariableSubstitution().setValue( this.wVariableSubstitution.getSelection() ); this.meta.getControlFile().setValue( this.wControlFile.getText() ); this.meta.getFastloadPath().setValue( this.wFastLoadPath.getText() ); this.meta.getDataFile().setValue( this.wDataFile.getText() ); this.meta.getLogFile().setValue( this.wLogFile.getText() ); this.meta.getErrorLimit().setValue( Const.toInt( this.wErrLimit.getText(), TeraFastMeta.DEFAULT_ERROR_LIMIT ) ); this.meta.getSessions().setValue( Const.toInt( this.wSessions.getText(), TeraFastMeta.DEFAULT_SESSIONS ) ); this.meta.getTargetTable().setValue( this.wTable.getText() ); this.meta.getConnectionName().setValue( this.wConnection.getText() ); this.meta.getTruncateTable().setValue( this.wbTruncateTable.getSelection() && this.wbTruncateTable.getEnabled() ); this.meta.setDbMeta( this.transMeta.findDatabase( this.wConnection.getText() ) ); this.meta.getTableFieldList().getValue().clear(); this.meta.getStreamFieldList().getValue().clear(); int nrfields = this.wReturn.nrNonEmpty(); for ( int i = 0; i < nrfields; i++ ) { TableItem item = this.wReturn.getNonEmpty( i ); this.meta.getTableFieldList().getValue().add( item.getText( 1 ) ); this.meta.getStreamFieldList().getValue().add( item.getText( 2 ) ); } dispose(); }
/** * Invoke loading with control file. * * @throws KettleException * ... */ private void invokeLoadingControlFile() throws KettleException { File controlFile = null; final InputStream control; final String controlContent; try { controlFile = new File( resolveFileName( this.meta.getControlFile().getValue() ) ); control = FileUtils.openInputStream( controlFile ); controlContent = environmentSubstitute( FileUtils.readFileToString( controlFile ) ); } catch ( IOException e ) { throw new KettleException( "Cannot open control file [path=" + controlFile + "]", e ); } try { IOUtils.write( controlContent, this.fastload ); this.fastload.flush(); } catch ( IOException e ) { throw new KettleException( "Cannot pipe content of control file to fastload [path=" + controlFile + "]", e ); } finally { IOUtils.closeQuietly( control ); IOUtils.closeQuietly( this.fastload ); } }
this.meta.getTargetTable().setValue( this.wTable.getText() ); try { targetFields = this.meta.getRequiredFields( this.transMeta );
if ( StringUtils.isBlank( this.meta.getFastloadPath().getValue() ) ) { throw new KettleException( "Fastload path not set" ); try { final FileObject fileObject = KettleVFS.getFileObject( environmentSubstitute( this.meta.getFastloadPath().getValue() ) ); final String fastloadExec = KettleVFS.getFilename( fileObject ); builder.append( fastloadExec ); if ( StringUtils.isNotBlank( this.meta.getLogFile().getValue() ) ) { try { FileObject fileObject = KettleVFS.getFileObject( environmentSubstitute( this.meta.getLogFile().getValue() ) ); builder.append( " -e " ); builder.append( "\"" + KettleVFS.getFilename( fileObject ) + "\"" );
/** * {@inheritDoc} * * @see org.pentaho.di.trans.step.BaseStepMeta#getRequiredFields(org.pentaho.di.core.variables.VariableSpace) */ @Override public RowMetaInterface getRequiredFields( final VariableSpace space ) throws KettleException { if ( !this.useControlFile.getValue() ) { final Database database = connectToDatabase(); database.shareVariablesWith( space ); RowMetaInterface fields = database.getTableFieldsMeta( StringUtils.EMPTY, space.environmentSubstitute( this.targetTable.getValue() ) ); database.disconnect(); if ( fields == null ) { throw new KettleException( MESSAGES.getString( "TeraFastMeta.Exception.TableNotFound" ) ); } return fields; } return null; }
this.first = false; try { final File tempDataFile = new File( resolveFileName( this.meta.getDataFile().getValue() ) ); this.dataFile = FileUtils.openOutputStream( tempDataFile ); this.dataFilePrintStream = new PrintStream( dataFile );
this.wConnection.setText( this.meta.getConnectionName().getValue() ); } else { if ( this.transMeta.nrDatabases() == 1 ) {
builder.define( this.meta.getRequiredFields( this.getTransMeta() ), meta.getTableFieldList(), resolveFileName( this.meta .getDataFile().getValue() ) ); } catch ( Exception ex ) { throw new KettleException( "Error defining data file!", ex ); builder.beginLoading( this.meta.getDbMeta().getPreferredSchemaName(), this.meta.getTargetTable().getValue() ); .getTargetTable().getValue() ); builder.endLoading(); builder.logoff();
/** * Execute fastload. * * @throws KettleException * ... */ public void execute() throws KettleException { if ( this.meta.getTruncateTable().getValue() ) { Database db = new Database( this, this.meta.getDbMeta() ); db.connect(); db.truncateTable( this.meta.getTargetTable().getValue() ); db.commit(); db.disconnect(); } startFastLoad(); if ( this.meta.getUseControlFile().getValue() ) { this.invokeLoadingControlFile(); } else { this.invokeLoadingCommand(); } }