@Test public void testGetReferencedFields() throws ReportDataFactoryException, SQLException { DataRow parameters = mock( DataRow.class ); String[] result = factory.getReferencedFields( QUERY + "${param}", parameters ); assertThat( result, arrayContainingInAnyOrder( "param", DataFactory.QUERY_LIMIT ) ); factory.setUserField( "user_field" ); factory.setPasswordField( "password_field" ); result = factory.getReferencedFields( QUERY + "${param}", parameters ); assertThat( result, arrayContainingInAnyOrder( "param", "user_field", "password_field", DataFactory.QUERY_LIMIT ) ); }
public String[] getReferencedFields( final String query, final DataRow parameters ) throws ReportDataFactoryException { final boolean isNewConnection = connection == null; try { final ParametrizationProviderFactory factory = createParametrizationProviderFactory(); final Connection connection = getConnection( parameters ); final ParametrizationProvider parametrizationProvider = factory.create( connection ); final String computedQuery = computedQuery( query, parameters ); parametrizationProvider.rewriteQueryForParametrization( connection, computedQuery, parameters ); final LinkedHashSet<String> list = new LinkedHashSet<String>(); list.addAll( Arrays.asList( parametrizationProvider.getPreparedParameterNames() ) ); if ( userField != null ) { list.add( userField ); } if ( passwordField != null ) { list.add( passwordField ); } list.add( DataFactory.QUERY_LIMIT ); return list.toArray( new String[ list.size() ] ); } catch ( ReportDataFactoryException e ) { logger.warn( "Unable to perform cache preparation", e ); throw e; } catch ( SQLException e ) { logger.warn( "Unable to perform cache preparation", e ); throw new ReportDataFactoryException( "Unable to perform cache preparation", e ); } finally { if ( isNewConnection ) { close(); } } }
SimpleSQLReportDataFactory extends AbstractDataFactory { public String[] getReferencedFields( final String query, final DataRow parameters ) throws ReportDataFactoryException { final boolean isNewConnection = connection == null; try { final ParametrizationProviderFactory factory = createParametrizationProviderFactory(); final Connection connection = getConnection( parameters ); final ParametrizationProvider parametrizationProvider = factory.create( connection ); final String computedQuery = computedQuery( query, parameters ); parametrizationProvider.rewriteQueryForParametrization( connection, computedQuery, parameters ); final LinkedHashSet<String> list = new LinkedHashSet<String>(); list.addAll( Arrays.asList( parametrizationProvider.getPreparedParameterNames() ) ); if ( userField != null ) { list.add( userField ); } if ( passwordField != null ) { list.add( passwordField ); } list.add( DataFactory.QUERY_LIMIT ); return list.toArray( new String[ list.size() ] ); } catch ( ReportDataFactoryException e ) { logger.warn( "Unable to perform cache preparation", e ); throw e; } catch ( SQLException e ) { logger.warn( "Unable to perform cache preparation", e ); throw new ReportDataFactoryException( "Unable to perform cache preparation", e ); } finally { if ( isNewConnection ) { close(); } } } }
SimpleSQLReportDataFactory extends AbstractDataFactory { public String[] getReferencedFields( final String query, final DataRow parameters ) throws ReportDataFactoryException { final boolean isNewConnection = connection == null; try { final ParametrizationProviderFactory factory = createParametrizationProviderFactory(); final Connection connection = getConnection( parameters ); final ParametrizationProvider parametrizationProvider = factory.create( connection ); final String computedQuery = computedQuery( query, parameters ); parametrizationProvider.rewriteQueryForParametrization( connection, computedQuery, parameters ); final LinkedHashSet<String> list = new LinkedHashSet<String>(); list.addAll( Arrays.asList( parametrizationProvider.getPreparedParameterNames() ) ); if ( userField != null ) { list.add( userField ); } if ( passwordField != null ) { list.add( passwordField ); } list.add( DataFactory.QUERY_LIMIT ); return list.toArray( new String[ list.size() ] ); } catch ( ReportDataFactoryException e ) { logger.warn( "Unable to perform cache preparation", e ); throw e; } catch ( SQLException e ) { logger.warn( "Unable to perform cache preparation", e ); throw new ReportDataFactoryException( "Unable to perform cache preparation", e ); } finally { if ( isNewConnection ) { close(); } } } SimpleSQLReportDataFactory();  SimpleSQLReportDataFactory( final Connection connection );  SimpleSQLReportDataFactory( final ConnectionProvider connectionProvider ); }
SimpleSQLReportDataFactory extends AbstractDataFactory { public String[] getReferencedFields( final String query, final DataRow parameters ) throws ReportDataFactoryException { final boolean isNewConnection = connection == null; try { final ParametrizationProviderFactory factory = createParametrizationProviderFactory(); final Connection connection = getConnection( parameters ); final ParametrizationProvider parametrizationProvider = factory.create( connection ); final String computedQuery = computedQuery( query, parameters ); parametrizationProvider.rewriteQueryForParametrization( connection, computedQuery, parameters ); final LinkedHashSet<String> list = new LinkedHashSet<String>(); list.addAll( Arrays.asList( parametrizationProvider.getPreparedParameterNames() ) ); if ( userField != null ) { list.add( userField ); } if ( passwordField != null ) { list.add( passwordField ); } list.add( DataFactory.QUERY_LIMIT ); return list.toArray( new String[ list.size() ] ); } catch ( ReportDataFactoryException e ) { logger.warn( "Unable to perform cache preparation", e ); throw e; } catch ( SQLException e ) { logger.warn( "Unable to perform cache preparation", e ); throw new ReportDataFactoryException( "Unable to perform cache preparation", e ); } finally { if ( isNewConnection ) { close(); } } } SimpleSQLReportDataFactory();  SimpleSQLReportDataFactory( final Connection connection );  SimpleSQLReportDataFactory( final ConnectionProvider connectionProvider ); String getUserField(); void setUserField( final String userField ); String getPasswordField(); void setPasswordField( final String passwordField ); int getBestResultSetType( final DataRow dataRow ); synchronized TableModel queryData( final String query, final DataRow parameters ); String[] getReferencedFields( final String query, final DataRow parameters ); static boolean isExpandArrayParameterNeeded( final String query ); ResultSet performQuery( Statement statement, final String translatedQuery, final String[] preparedParameterNames ); void cancelRunningQuery(); synchronized void close(); SimpleSQLReportDataFactory clone(); void setConnectionProvider( final ConnectionProvider connectionProvider ); ConnectionProvider getConnectionProvider(); boolean isQueryExecutable( final String query, final DataRow parameters ); String[] getQueryNames(); ArrayList<Object> getQueryHash( final String queryName, final DataRow parameter ); }
SimpleSQLReportDataFactory extends AbstractDataFactory { public String[] getReferencedFields( final String query, final DataRow parameters ) throws ReportDataFactoryException { final boolean isNewConnection = connection == null; try { final ParametrizationProviderFactory factory = createParametrizationProviderFactory(); final Connection connection = getConnection( parameters ); final ParametrizationProvider parametrizationProvider = factory.create( connection ); final String computedQuery = computedQuery( query, parameters ); parametrizationProvider.rewriteQueryForParametrization( connection, computedQuery, parameters ); final LinkedHashSet<String> list = new LinkedHashSet<String>(); list.addAll( Arrays.asList( parametrizationProvider.getPreparedParameterNames() ) ); if ( userField != null ) { list.add( userField ); } if ( passwordField != null ) { list.add( passwordField ); } list.add( DataFactory.QUERY_LIMIT ); return list.toArray( new String[ list.size() ] ); } catch ( ReportDataFactoryException e ) { logger.warn( "Unable to perform cache preparation", e ); throw e; } catch ( SQLException e ) { logger.warn( "Unable to perform cache preparation", e ); throw new ReportDataFactoryException( "Unable to perform cache preparation", e ); } finally { if ( isNewConnection ) { close(); } } } SimpleSQLReportDataFactory();  SimpleSQLReportDataFactory( final Connection connection );  SimpleSQLReportDataFactory( final ConnectionProvider connectionProvider ); String getUserField(); void setUserField( final String userField ); String getPasswordField(); void setPasswordField( final String passwordField ); int getBestResultSetType( final DataRow dataRow ); synchronized TableModel queryData( final String query, final DataRow parameters ); String[] getReferencedFields( final String query, final DataRow parameters ); static boolean isExpandArrayParameterNeeded( final String query ); ResultSet performQuery( Statement statement, final String translatedQuery, final String[] preparedParameterNames ); void cancelRunningQuery(); synchronized void close(); SimpleSQLReportDataFactory clone(); void setConnectionProvider( final ConnectionProvider connectionProvider ); ConnectionProvider getConnectionProvider(); boolean isQueryExecutable( final String query, final DataRow parameters ); String[] getQueryNames(); ArrayList<Object> getQueryHash( final String queryName, final DataRow parameter ); static Configuration globalConfig; }