org.pentaho.di.trans.step.StepMetaInterface Java Examples
The following examples show how to use
org.pentaho.di.trans.step.StepMetaInterface.
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: FileStream.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean init( StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface ) { super.init( stepMetaInterface, stepDataInterface ); Preconditions.checkNotNull( stepMetaInterface ); fileStreamMeta = (FileStreamMeta) stepMetaInterface; String sourceFile = getFilePath( fileStreamMeta.getSourcePath() ); RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "line" ) ); window = new FixedTimeStreamWindow<>( subtransExecutor, rowMeta, getDuration(), getBatchSize() ); try { source = new TailFileStreamSource( sourceFile, this ); } catch ( FileNotFoundException e ) { logError( e.getLocalizedMessage(), e ); return false; } return true; }
Example #2
Source File: InfobrightLoader.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * @see org.pentaho.di.trans.step.BaseStep#init(org.pentaho.di.trans.step.StepMetaInterface, * org.pentaho.di.trans.step.StepDataInterface) */ public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { boolean res = false; meta = (InfobrightLoaderMeta) smi; data = (InfobrightLoaderData) sdi; if ( super.init( smi, sdi ) ) { try { verifyDatabaseConnection(); data.databaseSetup( meta, this ); res = true; } catch ( Exception ex ) { logError( "An error occurred intialising this step", ex ); logError( Const.getStackTracker( ex ) ); stopAll(); setErrors( 1 ); return false; } } return res; }
Example #3
Source File: KettleBeamUtil.java From kettle-beam with Apache License 2.0 | 6 votes |
public static void loadStepMetadataFromXml( String stepname, StepMetaInterface stepMetaInterface, String stepMetaInterfaceXml, IMetaStore metaStore ) throws KettleException { synchronized ( object ) { Document stepDocument = XMLHandler.loadXMLString( stepMetaInterfaceXml ); if ( stepDocument == null ) { throw new KettleException( "Unable to load step XML document from : " + stepMetaInterfaceXml ); } Node stepNode = XMLHandler.getSubNode( stepDocument, StepMeta.XML_TAG ); if ( stepNode == null ) { throw new KettleException( "Unable to find XML tag " + StepMeta.XML_TAG + " from : " + stepMetaInterfaceXml ); } try { stepMetaInterface.loadXML( stepNode, new ArrayList<>(), metaStore ); } catch ( Exception e ) { throw new KettleException( "There was an error loading step metadata information (loadXML) for step '" + stepname + "'", e ); } finally { XMLHandlerCache.getInstance().clear(); } } }
Example #4
Source File: Delete.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (DeleteMeta) smi; data = (DeleteData) sdi; if ( data.db != null ) { try { if ( !data.db.isAutoCommit() ) { if ( getErrors() == 0 ) { data.db.commit(); } else { data.db.rollback(); } } data.db.closeUpdate(); } catch ( KettleDatabaseException e ) { logError( BaseMessages.getString( PKG, "Delete.Log.UnableToCommitUpdateConnection" ) + data.db + "] :" + e.toString() ); setErrors( 1 ); } finally { data.db.disconnect(); } } super.dispose( smi, sdi ); }
Example #5
Source File: ReservoirSampling.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Initialize the step. * * @param smi * a <code>StepMetaInterface</code> value * @param sdi * a <code>StepDataInterface</code> value * @return a <code>boolean</code> value */ public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { m_meta = (ReservoirSamplingMeta) smi; m_data = (ReservoirSamplingData) sdi; if ( super.init( smi, sdi ) ) { boolean remoteInput = getStepMeta().getRemoteInputSteps().size() > 0; List<StepMeta> previous = getTransMeta().findPreviousSteps( getStepMeta() ); if ( !remoteInput && ( previous == null || previous.size() <= 0 ) ) { m_data.setProcessingMode( PROC_MODE.DISABLED ); } return true; } return false; }
Example #6
Source File: Abort.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (AbortMeta) smi; if ( super.init( smi, sdi ) ) { // Add init code here. nrInputRows = 0; String threshold = environmentSubstitute( meta.getRowThreshold() ); nrThresholdRows = Const.toInt( threshold, -1 ); if ( nrThresholdRows < 0 ) { logError( BaseMessages.getString( PKG, "Abort.Log.ThresholdInvalid", threshold ) ); } return true; } return false; }
Example #7
Source File: RegexEval.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (RegexEvalMeta) smi; data = (RegexEvalData) sdi; if ( super.init( smi, sdi ) ) { // Embedded options String options = meta.getRegexOptions(); // Regular expression String regularexpression = meta.getScript(); if ( meta.isUseVariableInterpolationFlagSet() ) { regularexpression = environmentSubstitute( meta.getScript() ); } if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "RegexEval.Log.Regexp" ) + " " + options + regularexpression ); } if ( meta.isCanonicalEqualityFlagSet() ) { data.pattern = Pattern.compile( options + regularexpression, Pattern.CANON_EQ ); } else { data.pattern = Pattern.compile( options + regularexpression ); } return true; } return false; }
Example #8
Source File: SocketWriter.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (SocketWriterMeta) smi; data = (SocketWriterData) sdi; if ( super.init( smi, sdi ) ) { try { data.serverSocketPort = Integer.parseInt( environmentSubstitute( meta.getPort() ) ); data.serverSocket = getTrans().getSocketRepository().openServerSocket( data.serverSocketPort, getTransMeta().getName() + " - " + this.toString() ); return true; } catch ( Exception e ) { logError( "Error creating server socket: " + e.toString() ); logError( Const.getStackTracker( e ) ); } } return false; }
Example #9
Source File: Injector.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { // Get a row from the previous step OR from an extra RowSet // Object[] row = getRow(); // Nothing more to be had from any input rowset // if ( row == null ) { setOutputDone(); return false; } putRow( getInputRowMeta(), row ); // copy row to possible alternate rowset(s). if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "Injector.Log.LineNumber" ) + getLinesRead() ); } return true; }
Example #10
Source File: GPLoad.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (GPLoadMeta) smi; data = (GPLoadData) sdi; Trans trans = getTrans(); preview = trans.isPreview(); if ( super.init( smi, sdi ) ) { try { verifyDatabaseConnection(); } catch ( KettleException ex ) { logError( ex.getMessage() ); return false; } return true; } return false; }
Example #11
Source File: RepositoryImporterTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testImportJob_patchJobEntries_when_directory_path_ends_with_variable() throws KettleException { JobEntryInterface jobEntryInterface = createJobEntry( "/myDir/${USER_VARIABLE}" ); StepMetaInterface stepMeta = createStepMeta( "" ); RepositoryImporter importer = createRepositoryImporter( jobEntryInterface, stepMeta, true ); importer.setBaseDirectory( baseDirectory ); importer.importJob( entityNode, feedback ); verify( (HasRepositoryDirectories) jobEntryInterface ).setDirectories( new String[] { "/myDir/${USER_VARIABLE}" } ); JobEntryInterface jobEntryInterface2 = createJobEntry( "/myDir/${USER_VARIABLE}" ); RepositoryImporter importerWithCompatibilityImportPath = createRepositoryImporter( jobEntryInterface2, stepMeta, false ); importerWithCompatibilityImportPath.setBaseDirectory( baseDirectory ); importerWithCompatibilityImportPath.importJob( entityNode, feedback ); verify( (HasRepositoryDirectories) jobEntryInterface2 ).setDirectories( new String[] { ROOT_PATH + "/myDir/${USER_VARIABLE}" } ); }
Example #12
Source File: JoinRows.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (JoinRowsMeta) smi; data = (JoinRowsData) sdi; if ( first ) { first = false; initialize(); } if ( data.caching ) { if ( !cacheInputRow() ) { return false; } } else { if ( !outputRow() ) { return false; } } return true; }
Example #13
Source File: TeraFast.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * @see org.pentaho.di.trans.step.BaseStep#init(org.pentaho.di.trans.step.StepMetaInterface, * org.pentaho.di.trans.step.StepDataInterface) */ @Override public boolean init( final StepMetaInterface smi, final StepDataInterface sdi ) { this.meta = (TeraFastMeta) smi; // this.data = (GenericStepData) sdi; simpleDateFormat = new SimpleDateFormat( FastloadControlBuilder.DEFAULT_DATE_FORMAT ); if ( super.init( smi, sdi ) ) { try { verifyDatabaseConnection(); } catch ( KettleException ex ) { logError( ex.getMessage() ); return false; } return true; } return false; }
Example #14
Source File: OpenERPObjectOutput.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (OpenERPObjectOutputMeta) smi; data = (OpenERPObjectOutputData) sdi; if ( super.init( smi, sdi ) ) { try { this.logDebug( "Initializing OpenERP Session" ); data.helper = new OpenERPHelper( meta.getDatabaseMeta() ); data.helper.StartSession(); openerERPAdapter = data.helper.getAdapter( meta.getModelName() ); return true; } catch ( Exception e ) { logError( "An error occurred, processing will be stopped: " + e.getMessage() ); setErrors( 1 ); stopAll(); } } return false; }
Example #15
Source File: RowsToResult.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (RowsToResultMeta) smi; data = (RowsToResultData) sdi; Object[] r = getRow(); // get row, set busy! if ( r == null ) { // no more input to be expected... getTrans().getResultRows().addAll( data.rows ); getTrans().setResultRowSet( true ); setOutputDone(); return false; } // Add all rows to rows buffer... data.rows.add( new RowMetaAndData( getInputRowMeta(), r ) ); data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); putRow( data.outputRowMeta, r ); // copy row to possible alternate // rowset(s). if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "RowsToResult.Log.LineNumber" ) + getLinesRead() ); } return true; }
Example #16
Source File: CiviStep.java From civicrm-data-integration with GNU General Public License v3.0 | 5 votes |
public boolean init(StepMetaInterface smi, StepDataInterface sdi) { civiMeta = smi; civiData = sdi; /* * Aqui garantizamos seguir el procesamiento de las filas extraidas de CiviCRM, si fallara * algo deberiamos retornar false y kettle detendria el paso y la transformacion */ boolean passed = true; if (super.init(smi, sdi)) { if (Const.isEmpty(environmentSubstitute(((CiviMeta) civiMeta).getCiviCrmApiKey()))) { logError(BaseMessages.getString(PKG, "CiviCrmStep.Error.EmptyApiKey")); passed = false; } if (passed && Const.isEmpty(environmentSubstitute(((CiviMeta) civiMeta).getCiviCrmSiteKey()))) { logError(BaseMessages.getString(PKG, "CiviCrmStep.Error.EmptySiteKey")); passed = false; } if (passed && Const.isEmpty(environmentSubstitute(((CiviMeta) civiMeta).getCiviCrmRestUrl()))) { logError(BaseMessages.getString(PKG, "CiviCrmStep.Error.EmptyRestUrl")); passed = false; } if (passed && Const.isEmpty(environmentSubstitute(((CiviMeta) civiMeta).getCiviCrmEntity()))) { logError(BaseMessages.getString(PKG, "CiviCrmStep.Error.EmptyEntity")); passed = false; } } return passed; }
Example #17
Source File: RepositoryImporterTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testImportJob_patchJobEntries_without_variables() throws KettleException { JobEntryInterface jobEntry = createJobEntry( "/userName" ); StepMetaInterface stepMeta = createStepMeta( "" ); RepositoryImporter importer = createRepositoryImporter( jobEntry, stepMeta, true ); importer.setBaseDirectory( baseDirectory ); importer.importJob( entityNode, feedback ); verify( (HasRepositoryDirectories) jobEntry ).setDirectories( new String[]{ ROOT_PATH + USER_NAME_PATH } ); }
Example #18
Source File: RepositoryImporter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * package-local visibility for testing purposes */ void patchTransSteps( TransMeta transMeta ) { for ( StepMeta stepMeta : transMeta.getSteps() ) { StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface(); if ( stepMetaInterface instanceof HasRepositoryDirectories ) { patchRepositoryDirectories( stepMetaInterface.isReferencedObjectEnabled(), (HasRepositoryDirectories) stepMetaInterface ); } } }
Example #19
Source File: BlockingStep.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (BlockingStepMeta) smi; data = (BlockingStepData) sdi; if ( super.init( smi, sdi ) ) { // Set Embedded NamedCluter MetatStore Provider Key so that it can be passed to VFS if ( getTransMeta().getNamedClusterEmbedManager() != null ) { getTransMeta().getNamedClusterEmbedManager().passEmbeddedMetastoreKey( getTransMeta(), getTransMeta().getEmbeddedMetastoreProviderKey() ); } // Add init code here. return true; } return false; }
Example #20
Source File: TransMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void getThisStepFieldsPassesCloneRowMeta() throws Exception { final String overriddenValue = "overridden"; StepMeta nextStep = mockStepMeta( "nextStep" ); StepMetaInterface smi = mock( StepMetaInterface.class ); StepIOMeta ioMeta = mock( StepIOMeta.class ); when( smi.getStepIOMeta() ).thenReturn( ioMeta ); doAnswer( new Answer<Object>() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { RowMetaInterface rmi = (RowMetaInterface) invocation.getArguments()[ 0 ]; rmi.clear(); rmi.addValueMeta( new ValueMetaString( overriddenValue ) ); return null; } } ).when( smi ).getFields( any( RowMetaInterface.class ), anyString(), any( RowMetaInterface[].class ), eq( nextStep ), any( VariableSpace.class ), any( Repository.class ), any( IMetaStore.class ) ); StepMeta thisStep = mockStepMeta( "thisStep" ); when( thisStep.getStepMetaInterface() ).thenReturn( smi ); RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "value" ) ); RowMetaInterface thisStepsFields = transMeta.getThisStepFields( thisStep, nextStep, rowMeta ); assertEquals( 1, thisStepsFields.size() ); assertEquals( overriddenValue, thisStepsFields.getValueMeta( 0 ).getName() ); }
Example #21
Source File: GetXMLData.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { if ( first && !meta.isInFields() ) { first = false; data.files = meta.getFiles( this ); if ( !meta.isdoNotFailIfNoFile() && data.files.nrOfFiles() == 0 ) { throw new KettleException( BaseMessages.getString( PKG, "GetXMLData.Log.NoFiles" ) ); } handleMissingFiles(); // Create the output row meta-data data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); // Create convert meta-data objects that will contain Date & Number formatters // For String to <type> conversions, we allocate a conversion meta data row as well... // data.convertRowMeta = data.outputRowMeta.cloneToType( ValueMetaInterface.TYPE_STRING ); } // Grab a row Object[] r = getXMLRow(); if ( data.errorInRowButContinue ) { return true; // continue without putting the row out } if ( r == null ) { setOutputDone(); // signal end to receiver(s) return false; // end of data or error. } return putRowOut( r ); }
Example #22
Source File: WriteToLog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (WriteToLogMeta) smi; data = (WriteToLogData) sdi; if ( super.init( smi, sdi ) ) { // Add init code here. return true; } return false; }
Example #23
Source File: XMLInputSax.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); // For String to <type> conversions, we allocate a conversion meta data row as well... // data.convertRowMeta = data.outputRowMeta.cloneToType( ValueMetaInterface.TYPE_STRING ); } Object[] outputRowData = getRowFromXML(); if ( outputRowData == null ) { setOutputDone(); // signal end to receiver(s) return false; // This is the end of this step. } if ( log.isRowLevel() ) { logRowlevel( "Read row: " + data.outputRowMeta.getString( outputRowData ) ); } putRow( data.outputRowMeta, outputRowData ); // limit has been reached: stop now. // if ( meta.getRowLimit() > 0 && data.rownr >= meta.getRowLimit() ) { setOutputDone(); return false; } return true; }
Example #24
Source File: OlapInput.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { if ( log.isBasic() ) { logBasic( "Finished reading query, closing connection." ); } try { data.olapHelper.close(); } catch ( KettleDatabaseException e ) { logError( "Error closing connection: ", e ); } super.dispose( smi, sdi ); }
Example #25
Source File: DatabaseLookup.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Stop the running query */ @Override public void stopRunning( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (DatabaseLookupMeta) smi; data = (DatabaseLookupData) sdi; if ( data.db != null && !data.isCanceled ) { synchronized ( data.db ) { data.db.cancelQuery(); } data.isCanceled = true; } }
Example #26
Source File: ExecSQLRow.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (ExecSQLRowMeta) smi; data = (ExecSQLRowData) sdi; if ( super.init( smi, sdi ) ) { if ( meta.getDatabaseMeta() == null ) { logError( BaseMessages.getString( PKG, "ExecSQLRow.Init.ConnectionMissing", getStepname() ) ); return false; } data.db = new Database( this, meta.getDatabaseMeta() ); data.db.shareVariablesWith( this ); // Connect to the database try { if ( getTransMeta().isUsingUniqueConnections() ) { synchronized ( getTrans() ) { data.db.connect( getTrans().getTransactionId(), getPartitionID() ); } } else { data.db.connect( getPartitionID() ); } if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "ExecSQLRow.Log.ConnectedToDB" ) ); } if ( meta.getCommitSize() >= 1 ) { data.db.setCommit( meta.getCommitSize() ); } return true; } catch ( KettleException e ) { logError( BaseMessages.getString( PKG, "ExecSQLRow.Log.ErrorOccurred" ) + e.getMessage() ); setErrors( 1 ); stopAll(); } } return false; }
Example #27
Source File: RssInput.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (RssInputMeta) smi; data = (RssInputData) sdi; if ( data.feed != null ) { data.feed = null; } super.dispose( smi, sdi ); }
Example #28
Source File: OdpsInput.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 5 votes |
public void dispose(StepMetaInterface smi, StepDataInterface sdi) { try { if (data.tunnelRecordReader != null) { data.tunnelRecordReader.close(); } } catch (IOException e) { logError(e.getMessage(), e); } super.dispose(smi, sdi); }
Example #29
Source File: XMLInputStream.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (XMLInputStreamMeta) smi; data = (XMLInputStreamData) sdi; // free resources closeFile(); data.staxInstance = null; super.dispose( smi, sdi ); }
Example #30
Source File: Flattener.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (FlattenerMeta) smi; data = (FlattenerData) sdi; if ( super.init( smi, sdi ) ) { return true; } return false; }