Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions core/src/main/java/pt/webdetails/cda/utils/TableModelUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2002 - 2015 Webdetails, a Pentaho company. All rights reserved.
* Copyright 2002 - 2016 Webdetails, a Pentaho company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -245,17 +245,27 @@ private static DataTableFilter getRowFilter( final QueryOptions queryOptions, fi
}

if ( searchableIndexes == null ) { //include all
searchableIndexes = new int[ outputIndexes.size() ];
for ( int i = 0; i < searchableIndexes.length; i++ ) {
searchableIndexes[ i ] = outputIndexes.get( i );
}
searchableIndexes = toIntArray( outputIndexes );
}

return new DataTableFilter( filterText, searchableIndexes );
}

for ( Parameter parameter:queryOptions.getParameters() ) {
if ( parameter.getName().equals( "searchBox" ) ) {
return new DataTableFilter( parameter.getStringValue(), toIntArray( outputIndexes ) );
}
}
return null;
}

private static int[] toIntArray( List<Integer> outputIndexes ) {
int [] searchableIndexes = new int[ outputIndexes.size() ];
for ( int i = 0; i < searchableIndexes.length; i++ ) {
searchableIndexes[ i ] = outputIndexes.get( i );
}
return searchableIndexes;
}

private static List<Integer> getOutputIndexes( final DataAccess dataAccess, final QueryOptions queryOptions,
TableModel table ) throws InvalidOutputIndexException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2002 - 2015 Webdetails, a Pentaho company. All rights reserved.
* Copyright 2002 - 2016 Webdetails, a Pentaho company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -130,8 +130,15 @@ public void testOutputIdx() throws Exception {
new Object[] { 2.0d, "two" } ), result );
checker.assertColumnNames( result, "c3", "c2" );
checker.assertColumnClasses( result, Double.class, String.class );
opts.addParameter( "searchBox", "one" );
result = TableModelUtils.postProcessTableModel( dataAccess, opts, tm );
checker = new TableModelChecker();
checker.assertEquals( new SimpleTableModel(
new Object[] { 1.0d, "one" } ), result );

when( dataAccess.getOutputMode( 6 ) ).thenReturn( OutputMode.EXCLUDE );
opts = new QueryOptions();
opts.setOutputIndexId( 6 );
result = TableModelUtils.postProcessTableModel( dataAccess, opts, tm );
checker.assertEquals(
new SimpleTableModel( new Object[] { 1L }, new Object[] { 2L } ),
Expand Down