@Test public void testSelectDefault() throws ReportProcessingException { final DefaultTableModel tableModel = new DefaultTableModel( new String[] { "key", "value" }, 1 ); tableModel.setValueAt( "key-entry", 0, 0 ); tableModel.setValueAt( "value-entry", 0, 1 ); final DefaultListParameter listParameter = new DefaultListParameter( "test", "key", "value", "name", false, true, String.class ); listParameter.setParameterAutoSelectFirstValue( true ); listParameter.setMandatory( true ); final DefaultParameterDefinition definition = new DefaultParameterDefinition(); definition.addParameterDefinition( listParameter ); final MasterReport report = new MasterReport(); report.setParameterDefinition( definition ); report.setDataFactory( new TableDataFactory( "test", tableModel ) ); final DefaultParameterContext paramContext = new DefaultParameterContext( report ); final ValidationResult result = validator.validate( new ValidationResult(), definition, paramContext ); assertTrue( result.isEmpty() ); }
public ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition, final ParameterContext parameterContext ) throws ReportProcessingException { if ( parameterContext == null ) { throw new NullPointerException(); } if ( parameterDefinition == null ) { throw new NullPointerException(); } if ( result == null ) { result = new ValidationResult(); } PerformanceLoggingStopWatch sw = parameterContext.getPerformanceMonitorContext().createStopWatch( PerformanceTags.REPORT_PARAMETER ); try { sw.start(); final TrustedParameterContext trustedParameterContext = new TrustedParameterContext( parameterContext ); final ParameterDefinitionEntry[] parameterDefinitionEntries = parameterDefinition.getParameterDefinitions(); for ( int i = 0; i < parameterDefinitionEntries.length; i++ ) { final ParameterDefinitionEntry parameterDefinitionEntry = parameterDefinitionEntries[i]; final String parameterName = parameterDefinitionEntry.getName(); final Object untrustedValue = parameterContext.getParameterData().get( parameterName ); validateSingleParameter( result, trustedParameterContext, parameterDefinitionEntry, untrustedValue ); } result.setParameterValues( trustedParameterContext.getTrustedValues() ); return result; } finally { sw.close(); } }
DefaultReportParameterValidator implements ReportParameterValidator { public ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition, final ParameterContext parameterContext ) throws ReportProcessingException { if ( parameterContext == null ) { throw new NullPointerException(); } if ( parameterDefinition == null ) { throw new NullPointerException(); } if ( result == null ) { result = new ValidationResult(); } PerformanceLoggingStopWatch sw = parameterContext.getPerformanceMonitorContext().createStopWatch( PerformanceTags.REPORT_PARAMETER ); try { sw.start(); final TrustedParameterContext trustedParameterContext = new TrustedParameterContext( parameterContext ); final ParameterDefinitionEntry[] parameterDefinitionEntries = parameterDefinition.getParameterDefinitions(); for ( int i = 0; i < parameterDefinitionEntries.length; i++ ) { final ParameterDefinitionEntry parameterDefinitionEntry = parameterDefinitionEntries[i]; final String parameterName = parameterDefinitionEntry.getName(); final Object untrustedValue = parameterContext.getParameterData().get( parameterName ); validateSingleParameter( result, trustedParameterContext, parameterDefinitionEntry, untrustedValue ); } result.setParameterValues( trustedParameterContext.getTrustedValues() ); return result; } finally { sw.close(); } } }
DefaultReportParameterValidator implements ReportParameterValidator { public ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition, final ParameterContext parameterContext ) throws ReportProcessingException { if ( parameterContext == null ) { throw new NullPointerException(); } if ( parameterDefinition == null ) { throw new NullPointerException(); } if ( result == null ) { result = new ValidationResult(); } PerformanceLoggingStopWatch sw = parameterContext.getPerformanceMonitorContext().createStopWatch( PerformanceTags.REPORT_PARAMETER ); try { sw.start(); final TrustedParameterContext trustedParameterContext = new TrustedParameterContext( parameterContext ); final ParameterDefinitionEntry[] parameterDefinitionEntries = parameterDefinition.getParameterDefinitions(); for ( int i = 0; i < parameterDefinitionEntries.length; i++ ) { final ParameterDefinitionEntry parameterDefinitionEntry = parameterDefinitionEntries[i]; final String parameterName = parameterDefinitionEntry.getName(); final Object untrustedValue = parameterContext.getParameterData().get( parameterName ); validateSingleParameter( result, trustedParameterContext, parameterDefinitionEntry, untrustedValue ); } result.setParameterValues( trustedParameterContext.getTrustedValues() ); return result; } finally { sw.close(); } } DefaultReportParameterValidator(); }
DefaultReportParameterValidator implements ReportParameterValidator { public ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition, final ParameterContext parameterContext ) throws ReportProcessingException { if ( parameterContext == null ) { throw new NullPointerException(); } if ( parameterDefinition == null ) { throw new NullPointerException(); } if ( result == null ) { result = new ValidationResult(); } PerformanceLoggingStopWatch sw = parameterContext.getPerformanceMonitorContext().createStopWatch( PerformanceTags.REPORT_PARAMETER ); try { sw.start(); final TrustedParameterContext trustedParameterContext = new TrustedParameterContext( parameterContext ); final ParameterDefinitionEntry[] parameterDefinitionEntries = parameterDefinition.getParameterDefinitions(); for ( int i = 0; i < parameterDefinitionEntries.length; i++ ) { final ParameterDefinitionEntry parameterDefinitionEntry = parameterDefinitionEntries[i]; final String parameterName = parameterDefinitionEntry.getName(); final Object untrustedValue = parameterContext.getParameterData().get( parameterName ); validateSingleParameter( result, trustedParameterContext, parameterDefinitionEntry, untrustedValue ); } result.setParameterValues( trustedParameterContext.getTrustedValues() ); return result; } finally { sw.close(); } } DefaultReportParameterValidator(); ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition,
      final ParameterContext parameterContext ); }
DefaultReportParameterValidator implements ReportParameterValidator { public ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition, final ParameterContext parameterContext ) throws ReportProcessingException { if ( parameterContext == null ) { throw new NullPointerException(); } if ( parameterDefinition == null ) { throw new NullPointerException(); } if ( result == null ) { result = new ValidationResult(); } PerformanceLoggingStopWatch sw = parameterContext.getPerformanceMonitorContext().createStopWatch( PerformanceTags.REPORT_PARAMETER ); try { sw.start(); final TrustedParameterContext trustedParameterContext = new TrustedParameterContext( parameterContext ); final ParameterDefinitionEntry[] parameterDefinitionEntries = parameterDefinition.getParameterDefinitions(); for ( int i = 0; i < parameterDefinitionEntries.length; i++ ) { final ParameterDefinitionEntry parameterDefinitionEntry = parameterDefinitionEntries[i]; final String parameterName = parameterDefinitionEntry.getName(); final Object untrustedValue = parameterContext.getParameterData().get( parameterName ); validateSingleParameter( result, trustedParameterContext, parameterDefinitionEntry, untrustedValue ); } result.setParameterValues( trustedParameterContext.getTrustedValues() ); return result; } finally { sw.close(); } } DefaultReportParameterValidator(); ValidationResult validate( ValidationResult result, final ReportParameterDefinition parameterDefinition,
      final ParameterContext parameterContext );  }