/** * Returns the fields that are emitted by a certain step. * * @param stepMeta * The step to be queried. * @return A row containing the fields emitted. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getStepFields( StepMeta stepMeta ) throws KettleStepException { return getStepFields( stepMeta, null ); }
/** * Returns the fields that are emitted by a certain step. * * @param stepMeta * The step to be queried. * @param monitor * The progress monitor for progress dialog. (null if not used!) * @return A row containing the fields emitted. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ) throws KettleStepException { setRepositoryOnMappingSteps(); return getStepFields( stepMeta, null, monitor ); }
/** * Returns the fields that are emitted by a certain step name. * * @param stepname * The stepname of the step to be queried. * @return A row containing the fields emitted. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getStepFields( String stepname ) throws KettleStepException { StepMeta stepMeta = findStep( stepname ); if ( stepMeta != null ) { return getStepFields( stepMeta ); } else { return null; } }
/** * Calculate the lineage for the specified step only... * * @param stepMeta * The step to calculate the lineage for. * @throws KettleStepException * In case there is an exception calculating the lineage. This is usually caused by unavailable data sources * etc. */ private void calculateLineage( StepMeta stepMeta ) throws KettleStepException { RowMetaInterface outputMeta = transMeta.getStepFields( stepMeta ); // The lineage is basically a calculation of origin for each output of a certain step. // for ( ValueMetaInterface valueMeta : outputMeta.getValueMetaList() ) { StepMeta originStepMeta = transMeta.findStep( valueMeta.getOrigin(), stepMeta ); if ( originStepMeta != null ) { /* List<StepMeta> list = */fieldStepsMap.get( originStepMeta ); } } }
public RowMetaInterface getFieldsFromStep( boolean parent, boolean input ) throws KettleException { if ( input ) { // INPUT // if ( parent ) { return transMeta.getPrevStepFields( stepMeta ); } else { if ( mappingTransMeta == null ) { throw new KettleException( BaseMessages.getString( PKG, "SimpleMappingDialog.Exception.NoMappingSpecified" ) ); } StepMeta mappingInputStepMeta = mappingTransMeta.findMappingInputStep( null ); return mappingTransMeta.getStepFields( mappingInputStepMeta ); } } else { // OUTPUT // StepMeta mappingOutputStepMeta = mappingTransMeta.findMappingOutputStep( null ); return mappingTransMeta.getStepFields( mappingOutputStepMeta ); } }
/** * Gets the fields for each of the specified steps and merges them into a single set * * @param stepMeta * the step meta * @return an interface to the step fields * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getStepFields( StepMeta[] stepMeta ) throws KettleStepException { RowMetaInterface fields = new RowMeta(); for ( int i = 0; i < stepMeta.length; i++ ) { RowMetaInterface flds = getStepFields( stepMeta[i] ); if ( flds != null ) { fields.mergeRowMeta( flds, stepMeta[i].getName() ); } } return fields; }
@Override public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( space instanceof TransMeta ) { TransMeta transMeta = (TransMeta) space; StepMeta[] steps = transMeta.getPrevSteps( transMeta.findStep( origin ) ); StepMeta mainStep = transMeta.findStep( getMainStepname() ); rowMeta.clear(); if ( mainStep != null ) { rowMeta.addRowMeta( transMeta.getStepFields( mainStep ) ); } for ( StepMeta step : steps ) { if ( mainStep == null || !step.equals( mainStep ) ) { rowMeta.addRowMeta( transMeta.getStepFields( step ) ); } } } }
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { int size = transMeta.findNrPrevSteps( stepInfo ); try { if ( before ) { monitor.beginTask( BaseMessages.getString( PKG, "SearchFieldsProgressDialog.Dialog.SearchInputFields.Message" ), size ); // Searching // for // input // fields... fields = transMeta.getPrevStepFields( stepInfo, new ProgressMonitorAdapter( monitor ) ); } else { monitor.beginTask( BaseMessages.getString( PKG, "SearchFieldsProgressDialog.Dialog.SearchOutputFields.Message" ), size ); // Searching // for // output // fields... fields = transMeta.getStepFields( stepInfo, new ProgressMonitorAdapter( monitor ) ); } } catch ( KettleStepException kse ) { throw new InvocationTargetException( kse, BaseMessages.getString( PKG, "SearchFieldsProgressDialog.Log.UnableToGetFields", stepInfo.toString(), kse.getMessage() ) ); } monitor.done(); }
public void run() { try { CCombo wInputStep = wInputStepArray[inputStreamIndex]; String stepName = wInputStep.getText(); StepMeta stepMeta = transMeta.findStep( stepName ); if ( stepMeta != null ) { prev = transMeta.getStepFields( stepMeta ); if ( prev != null ) { // Remember these fields... for ( int i = 0; i < prev.size(); i++ ) { inputFields.put( prev.getValueMeta( i ).getName(), Integer.valueOf( i ) ); } setComboBoxes(); } } } catch ( KettleException e ) { logError( BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ) ); } } };
private void getKeys() { try { StepMeta stepMeta = transMeta.findStep( wReference.getText() ); if ( stepMeta != null ) { RowMetaInterface prev = transMeta.getStepFields( stepMeta ); if ( prev != null ) { BaseStepDialog.getFieldsFromPrevious( prev, wKeys, 1, new int[] { 1 }, new int[] {}, -1, -1, null ); } } } catch ( KettleException e ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "MergeRowsDialog.ErrorGettingFields.DialogTitle" ), BaseMessages .getString( PKG, "MergeRowsDialog.ErrorGettingFields.DialogMessage" ), e ); } }
private void getValues() { try { StepMeta stepMeta = transMeta.findStep( wReference.getText() ); if ( stepMeta != null ) { RowMetaInterface prev = transMeta.getStepFields( stepMeta ); if ( prev != null ) { BaseStepDialog.getFieldsFromPrevious( prev, wValues, 1, new int[] { 1 }, new int[] {}, -1, -1, null ); } } } catch ( KettleException e ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "MergeRowsDialog.ErrorGettingFields.DialogTitle" ), BaseMessages .getString( PKG, "MergeRowsDialog.ErrorGettingFields.DialogMessage" ), e ); } } }
private void getKeys2() { MergeJoinMeta joinMeta = new MergeJoinMeta(); getMeta( joinMeta ); try { List<StreamInterface> infoStreams = joinMeta.getStepIOMeta().getInfoStreams(); StepMeta stepMeta = infoStreams.get( 1 ).getStepMeta(); if ( stepMeta != null ) { RowMetaInterface prev = transMeta.getStepFields( stepMeta ); if ( prev != null ) { BaseStepDialog.getFieldsFromPrevious( prev, wKeys2, 1, new int[] { 1 }, new int[] {}, -1, -1, null ); } } } catch ( KettleException e ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "MergeJoinDialog.ErrorGettingFields.DialogTitle" ), BaseMessages .getString( PKG, "MergeJoinDialog.ErrorGettingFields.DialogMessage" ), e ); } }
private void getKeys1() { MergeJoinMeta joinMeta = new MergeJoinMeta(); getMeta( joinMeta ); try { List<StreamInterface> infoStreams = joinMeta.getStepIOMeta().getInfoStreams(); StepMeta stepMeta = infoStreams.get( 0 ).getStepMeta(); if ( stepMeta != null ) { RowMetaInterface prev = transMeta.getStepFields( stepMeta ); if ( prev != null ) { BaseStepDialog.getFieldsFromPrevious( prev, wKeys1, 1, new int[] { 1 }, new int[] {}, -1, -1, null ); } } } catch ( KettleException e ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "MergeJoinDialog.ErrorGettingFields.DialogTitle" ), BaseMessages .getString( PKG, "MergeJoinDialog.ErrorGettingFields.DialogMessage" ), e ); } }
@Test public void prevStepFieldsAreIncludedInGetStepFields() throws KettleStepException { TransMeta transMeta = new TransMeta( new Variables() ); StepMeta prevStep1 = testStep( "prevStep1", emptyList(), asList( "field1", "field2" ) ); StepMeta prevStep2 = testStep( "prevStep2", emptyList(), asList( "field3", "field4", "field5" ) ); StepMeta someStep = testStep( "step", asList( "prevStep1" ), asList( "outputField" ) ); StepMeta after = new StepMeta( "after", new DummyTransMeta() ); wireUpTestTransMeta( transMeta, prevStep1, prevStep2, someStep, after ); RowMetaInterface results = transMeta.getStepFields( someStep, after, mock( ProgressMonitorListener.class ) ); assertThat( 4, equalTo( results.size() ) ); assertThat( new String[] { "field3", "field4", "field5", "outputField" }, equalTo( results.getFieldNames() ) ); }
public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // First load some interesting data... // // Then see which fields get added to the row. // TransMeta mappingTransMeta = null; try { mappingTransMeta = loadSingleThreadedTransMeta( this, repository, space ); } catch ( KettleException e ) { throw new KettleStepException( BaseMessages.getString( PKG, "SingleThreaderMeta.Exception.UnableToLoadMappingTransformation" ), e ); } row.clear(); // Let's keep it simple! // if ( !Utils.isEmpty( space.environmentSubstitute( retrieveStep ) ) ) { RowMetaInterface stepFields = mappingTransMeta.getStepFields( retrieveStep ); row.addRowMeta( stepFields ); } }
public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { ValueMetaInterface v = new ValueMeta( this.getValueXMLfield(), ValueMetaInterface.TYPE_STRING ); v.setOrigin( name ); TransMeta transMeta = (TransMeta) space; try { // Row should only include fields from the target and not the source. During the preview table generation // the fields from all previous steps (source and target) are included in the row so lets remove the // source fields. for ( String fieldName : transMeta.getStepFields( transMeta.findStep( getSourceXMLstep() ), null, null ).getFieldNames() ) { row.removeValueMeta( fieldName ); } } catch ( KettleValueException e ) { // Pass } row.addValueMeta( v ); }
@Test public void infoStepFieldsAreNotIncludedInGetStepFields() throws KettleStepException { // validates that the fields from info steps are not included in the resulting step fields for a stepMeta. // This is important with steps like StreamLookup and Append, where the previous steps may or may not // have their fields included in the current step. TransMeta transMeta = new TransMeta( new Variables() ); StepMeta toBeAppended1 = testStep( "toBeAppended1", emptyList(), // no info steps asList( "field1", "field2" ) // names of fields from this step ); StepMeta toBeAppended2 = testStep( "toBeAppended2", emptyList(), asList( "field1", "field2" ) ); StepMeta append = testStep( "append", asList( "toBeAppended1", "toBeAppended2" ), // info step names singletonList( "outputField" ) // output field of this step ); StepMeta after = new StepMeta( "after", new DummyTransMeta() ); wireUpTestTransMeta( transMeta, toBeAppended1, toBeAppended2, append, after ); RowMetaInterface results = transMeta.getStepFields( append, after, mock( ProgressMonitorListener.class ) ); assertThat( 1, equalTo( results.size() ) ); assertThat( "outputField", equalTo( results.getFieldNames()[ 0 ] ) ); }
@Test public void stopsAll() throws KettleException { TransMeta parentMeta = new TransMeta( this.getClass().getResource( "subtrans-executor-parent.ktr" ).getPath(), new Variables() ); TransMeta subMeta = new TransMeta( this.getClass().getResource( "subtrans-executor-sub.ktr" ).getPath(), new Variables() ); LoggingObjectInterface loggingObject = new LoggingObject( "anything" ); Trans parentTrans = new Trans( parentMeta, loggingObject ); SubtransExecutor subtransExecutor = new SubtransExecutor( "subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "" ); subtransExecutor.running = Mockito.spy( subtransExecutor.running ); RowMetaInterface rowMeta = parentMeta.getStepFields( "Data Grid" ); List<RowMetaAndData> rows = Arrays.asList( new RowMetaAndData( rowMeta, "Pentaho", 1L ), new RowMetaAndData( rowMeta, "Pentaho", 2L ), new RowMetaAndData( rowMeta, "Pentaho", 3L ), new RowMetaAndData( rowMeta, "Pentaho", 4L ) ); subtransExecutor.execute( rows ); verify( subtransExecutor.running ).add( any() ); subtransExecutor.stop(); assertTrue( subtransExecutor.running.isEmpty() ); }
private void setLookupField() { if ( !gotLookupFields ) { String field = wLookupField.getText(); try { wLookupField.removeAll(); RowMetaInterface r = transMeta.getStepFields( wStep.getText() ); if ( r != null ) { wLookupField.setItems( r.getFieldNames() ); } } catch ( KettleException ke ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "FuzzyMatchDialog.FailedToGetLookupFields.DialogTitle" ), BaseMessages.getString( PKG, "FuzzyMatchDialog.FailedToGetLookupFields.DialogMessage" ), ke ); } if ( field != null ) { wLookupField.setText( field ); } gotLookupFields = true; } }
private void getFields() { Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT ); shell.setCursor( busy ); try { String sourceStepName = wSourceStep.getText(); if ( !Utils.isEmpty( sourceStepName ) ) { String fieldName = wSourceField.getText(); RowMetaInterface r = transMeta.getStepFields( sourceStepName ); if ( r != null ) { wSourceField.setItems( r.getFieldNames() ); } wSourceField.setText( fieldName ); } shell.setCursor( null ); busy.dispose(); } catch ( KettleException ke ) { shell.setCursor( null ); busy.dispose(); new ErrorDialog( shell, BaseMessages.getString( PKG, "ValidatorDialog.FailedToGetFields.DialogTitle" ), BaseMessages .getString( PKG, "ValidatorDialog.FailedToGetFields.DialogMessage" ), ke ); } } }