@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 ) ); } } } }
String realSubStepName = space.environmentSubstitute( getSubStep() ); if ( transMeta.getSteps().stream().anyMatch( stepMeta -> stepMeta.getName().equals( realSubStepName ) ) ) { rowMeta.addRowMeta( transMeta.getPrevStepFields( realSubStepName ) ); transMeta.getSteps().stream().filter( stepMeta -> stepMeta.getName().equals( realSubStepName ) ) .findFirst() rowMeta.addRowMeta( getRowMeta( origin, space ) );
private StepMetaInterface stepMetaInterfaceWithFields( StepMetaInterface smi, List<String> infoStepnames, List<String> fieldNames ) throws KettleStepException { RowMeta rowMetaWithFields = new RowMeta(); StepIOMeta stepIOMeta = mock( StepIOMeta.class ); when( stepIOMeta.getInfoStepnames() ).thenReturn( infoStepnames.toArray( new String[ 0 ] ) ); fieldNames.stream() .forEach( field -> rowMetaWithFields.addValueMeta( new ValueMetaString( field ) ) ); StepMetaInterface newSmi = spy( smi ); when( newSmi.getStepIOMeta() ).thenReturn( stepIOMeta ); doAnswer( (Answer<Void>) invocationOnMock -> { RowMetaInterface passedRmi = (RowMetaInterface) invocationOnMock.getArguments()[ 0 ]; passedRmi.addRowMeta( rowMetaWithFields ); return null; } ).when( newSmi ) .getFields( any(), any(), any(), any(), any(), any(), any() ); return newSmi; }
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { FileInputList fileList = getTextFileList( space ); if ( fileList.nrOfFiles() == 0 ) { throw new KettleStepException( BaseMessages .getString( PKG, "XBaseInputMeta.Exception.NoFilesFoundToProcess" ) ); } row.addRowMeta( getOutputFields( fileList, name ) ); }
public void getFields( final RowMetaInterface row, final String origin, final RowMetaInterface[] info, final StepMeta nextStep, final VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( databaseMeta == null ) { throw new KettleStepException( "There is no OpenERP database server connection defined" ); } final OpenERPHelper helper = new OpenERPHelper( databaseMeta ); try { helper.StartSession(); final RowMetaInterface rowMeta = this.getRowMeta(); row.addRowMeta( rowMeta ); } catch ( Exception e ) { throw new KettleStepException( e ); } }
@Override public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { try { RowMetaInterface rowMeta = inputRowMeta.clone(); inputRowMeta.clear(); inputRowMeta.addRowMeta( rowMeta ); getSelectFields( inputRowMeta, name ); getDeleteFields( inputRowMeta ); getMetadataFields( inputRowMeta, name ); } catch ( Exception e ) { throw new KettleStepException( e ); } }
@Override public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { RowMetaInterface add = null; try { initData( space ); add = data.outputRowMeta; } catch ( Exception dbe ) { throw new KettleStepException( "Unable to get query result for MDX query: " + Const.CR + mdx, dbe ); } // Set the origin // for ( int i = 0; i < add.size(); i++ ) { ValueMetaInterface v = add.getValueMeta( i ); v.setOrigin( origin ); } row.addRowMeta( add ); }
@Override public void getFields( final RowMetaInterface row, final String origin, final RowMetaInterface[] info, final StepMeta nextStep, final VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( databaseMeta == null ) { throw new KettleStepException( "There is no Palo database server connection defined" ); } final PaloHelper helper = new PaloHelper( databaseMeta, DefaultLogLevel.getLogLevel() ); try { helper.connect(); try { final RowMetaInterface rowMeta = helper.getCellRowMeta( this.cube, this.fields, this.cubeMeasure ); row.addRowMeta( rowMeta ); } finally { helper.disconnect(); } } catch ( Exception e ) { throw new KettleStepException( e ); } }
@Test public void getFieldsWithoutSubject() { ValueMetaDate valueMeta = new ValueMetaDate(); valueMeta.setName( "date" ); doReturn( valueMeta ).when( rowMeta ).searchValueMeta( "date" ); groupByMeta.setSubjectField( new String[] { null } ); groupByMeta.setGroupField( new String[] { "date" } ); groupByMeta.setAggregateField( new String[] { "countDate" } ); groupByMeta.setAggregateType( new int[] { TYPE_GROUP_COUNT_ANY } ); groupByMeta.getFields( rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore ); verify( rowMeta, times( 1 ) ).clear(); verify( rowMeta, times( 1 ) ).addRowMeta( any() ); assertNotNull( rowMeta.searchValueMeta( "countDate" ) ); } }
@Test public void getFieldsWithSubject_NoFormat() { ValueMetaDate valueMeta = new ValueMetaDate(); valueMeta.setName( "date" ); doReturn( valueMeta ).when( rowMeta ).searchValueMeta( "date" ); groupByMeta.setSubjectField( new String[] { "date" } ); groupByMeta.setGroupField( new String[] {} ); groupByMeta.setAggregateField( new String[] { "minDate" } ); groupByMeta.setAggregateType( new int[] { TYPE_GROUP_MIN } ); groupByMeta.getFields( rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore ); verify( rowMeta, times( 1 ) ).clear(); verify( rowMeta, times( 1 ) ).addRowMeta( any() ); assertEquals( null, rowMeta.searchValueMeta( "minDate" ).getConversionMask() ); }
@Test public void getFieldsWithSubject_NoFormat() { ValueMetaDate valueMeta = new ValueMetaDate(); valueMeta.setName( "date" ); doReturn( valueMeta ).when( rowMeta ).searchValueMeta( "date" ); memoryGroupByMeta.setSubjectField( new String[] { "date" } ); memoryGroupByMeta.setGroupField( new String[] {} ); memoryGroupByMeta.setAggregateField( new String[] { "minDate" } ); memoryGroupByMeta.setAggregateType( new int[] { TYPE_GROUP_MIN } ); memoryGroupByMeta.getFields( rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore ); verify( rowMeta, times( 1 ) ).clear(); verify( rowMeta, times( 1 ) ).addRowMeta( any() ); assertEquals( null, rowMeta.searchValueMeta( "minDate" ).getConversionMask() ); }
@Test public void getFieldsWithoutSubject() { ValueMetaDate valueMeta = new ValueMetaDate(); valueMeta.setName( "date" ); doReturn( valueMeta ).when( rowMeta ).searchValueMeta( "date" ); memoryGroupByMeta.setSubjectField( new String[] { null } ); memoryGroupByMeta.setGroupField( new String[] { "date" } ); memoryGroupByMeta.setAggregateField( new String[] { "countDate" } ); memoryGroupByMeta.setAggregateType( new int[] { TYPE_GROUP_COUNT_ANY } ); memoryGroupByMeta.getFields( rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore ); verify( rowMeta, times( 1 ) ).clear(); verify( rowMeta, times( 1 ) ).addRowMeta( any() ); assertNotNull( rowMeta.searchValueMeta( "countDate" ) ); } }
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 r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // Add the fields from a ResultFile try { ResultFile resultFile = new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( "foo.bar", space ), "parentOrigin", "origin" ); RowMetaAndData add = resultFile.getRow(); // Set the origin on the fields... for ( int i = 0; i < add.size(); i++ ) { add.getValueMeta( i ).setOrigin( name ); } r.addRowMeta( add.getRowMeta() ); } catch ( KettleFileException e ) { throw new KettleStepException( e ); } }
@Test public void getFieldsWithSubject_WithFormat() { ValueMetaDate valueMeta = new ValueMetaDate(); valueMeta.setConversionMask( "yyyy-MM-dd" ); valueMeta.setName( "date" ); doReturn( valueMeta ).when( rowMeta ).searchValueMeta( "date" ); memoryGroupByMeta.setSubjectField( new String[] { "date" } ); memoryGroupByMeta.setGroupField( new String[] {} ); memoryGroupByMeta.setAggregateField( new String[] { "maxDate" } ); memoryGroupByMeta.setAggregateType( new int[] { TYPE_GROUP_MAX } ); memoryGroupByMeta.getFields( rowMeta, "Memory Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore ); verify( rowMeta, times( 1 ) ).clear(); verify( rowMeta, times( 1 ) ).addRowMeta( any() ); assertEquals( "yyyy-MM-dd", rowMeta.searchValueMeta( "maxDate" ).getConversionMask() ); }
@Test public void getFieldsWithSubject_WithFormat() { ValueMetaDate valueMeta = new ValueMetaDate(); valueMeta.setConversionMask( "yyyy-MM-dd" ); valueMeta.setName( "date" ); doReturn( valueMeta ).when( rowMeta ).searchValueMeta( "date" ); groupByMeta.setSubjectField( new String[] { "date" } ); groupByMeta.setGroupField( new String[] {} ); groupByMeta.setAggregateField( new String[] { "maxDate" } ); groupByMeta.setAggregateType( new int[] { TYPE_GROUP_MAX } ); groupByMeta.getFields( rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore ); verify( rowMeta, times( 1 ) ).clear(); verify( rowMeta, times( 1 ) ).addRowMeta( any() ); assertEquals( "yyyy-MM-dd", rowMeta.searchValueMeta( "maxDate" ).getConversionMask() ); }
@Override public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // The output for the closure table is: // // - parentId // - childId // - distance // // Nothing else. // RowMetaInterface result = new RowMeta(); ValueMetaInterface parentValueMeta = row.searchValueMeta( parentIdFieldName ); if ( parentValueMeta != null ) { result.addValueMeta( parentValueMeta ); } ValueMetaInterface childValueMeta = row.searchValueMeta( childIdFieldName ); if ( childValueMeta != null ) { result.addValueMeta( childValueMeta ); } ValueMetaInterface distanceValueMeta = new ValueMetaInteger( distanceFieldName ); distanceValueMeta.setLength( ValueMetaInterface.DEFAULT_INTEGER_LENGTH ); result.addValueMeta( distanceValueMeta ); row.clear(); row.addRowMeta( result ); }
public void getFields( final RowMetaInterface row, final String origin, final RowMetaInterface[] info, final StepMeta nextStep, final VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( databaseMeta == null ) { throw new KettleStepException( "There is no Palo database server connection defined" ); } final PaloHelper helper = new PaloHelper( databaseMeta, DefaultLogLevel.getLogLevel() ); try { helper.connect(); try { final RowMetaInterface rowMeta = helper.getDimensionRowMeta( this.getDimension(), this.getLevels(), this.getBaseElementsOnly() ); row.addRowMeta( rowMeta ); } finally { helper.disconnect(); } } catch ( Exception e ) { throw new KettleStepException( e ); } }
public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( databaseMeta == null ) { return; // TODO: throw an exception here } RowMetaInterface add = null; try { String mdx = getSQL(); if ( isVariableReplacementActive() ) { mdx = space.environmentSubstitute( mdx ); } MondrianHelper helper = new MondrianHelper( databaseMeta, catalog, mdx, space ); add = helper.getCachedRowMeta(); if ( add == null ) { helper.openQuery(); helper.createRectangularOutput(); add = helper.getOutputRowMeta(); } } catch ( KettleDatabaseException dbe ) { throw new KettleStepException( "Unable to get query result for MDX query: " + Const.CR + sql, dbe ); } // Set the origin // for ( int i = 0; i < add.size(); i++ ) { ValueMetaInterface v = add.getValueMeta( i ); v.setOrigin( origin ); } row.addRowMeta( add ); }
private RowMetaAndData readStartDate() throws KettleException { if ( log.isDetailed() ) { logDetailed( "Reading from step [" + data.infoStream.getStepname() + "]" ); } RowMetaInterface parametersMeta = new RowMeta(); Object[] parametersData = new Object[] {}; RowSet rowSet = findInputRowSet( data.infoStream.getStepname() ); if ( rowSet != null ) { Object[] rowData = getRowFrom( rowSet ); // rows are originating from "lookup_from" while ( rowData != null ) { parametersData = RowDataUtil.addRowData( parametersData, parametersMeta.size(), rowData ); parametersMeta.addRowMeta( rowSet.getRowMeta() ); rowData = getRowFrom( rowSet ); // take all input rows if needed! } if ( parametersMeta.size() == 0 ) { throw new KettleException( "Expected to read parameters from step [" + data.infoStream.getStepname() + "] but none were found." ); } } else { throw new KettleException( "Unable to find rowset to read from, perhaps step [" + data.infoStream.getStepname() + "] doesn't exist. (or perhaps you are trying a preview?)" ); } RowMetaAndData parameters = new RowMetaAndData( parametersMeta, parametersData ); return parameters; }