SimpleReportingAction implements IStreamProcessingAction, IStreamingAction, IVarArgsAction { protected ReportOutputHandler createOutputHandlerForOutputType( final String outputType ) throws IOException { if ( inputs == null ) { throw new IllegalStateException( "Inputs are null, this component did not validate properly" ); } final Object attribute = report.getAttribute( AttributeNames.Pentaho.NAMESPACE, AttributeNames.Pentaho.REPORT_CACHE ); final ReportCacheKey reportCacheKey = new ReportCacheKey( getViewerSessionId(), inputs ); ReportCache cache; if ( Boolean.FALSE.equals( attribute ) ) { cache = new NullReportCache(); } else { cache = PentahoSystem.get( ReportCache.class ); if ( cache == null ) { cache = new DefaultReportCache(); } final ReportOutputHandler outputHandler = cache.get( reportCacheKey ); if ( outputHandler != null ) { return outputHandler; } } if ( dashboardMode ) { report.getReportConfiguration().setConfigProperty( HtmlTableModule.BODY_FRAGMENT, "true" ); } ReportOutputHandlerFactory handlerFactory = PentahoSystem.get( ReportOutputHandlerFactory.class ); if ( handlerFactory == null ) { handlerFactory = new FastExportReportOutputHandlerFactory(); } ReportOutputHandler reportOutputHandler = handlerFactory.createOutputHandlerForOutputType( new InternalOutputHandlerSelector( outputType ) ); if ( reportOutputHandler == null ) { return null; } return cache.put( reportCacheKey, reportOutputHandler ); } SimpleReportingAction(); String getDefaultOutputTarget(); void setDefaultOutputTarget( final String defaultOutputTarget ); String getOutputTarget(); void setOutputTarget( final String outputTarget ); void setOutputType( final String outputType ); String getOutputType(); IActionSequenceResource getReportDefinition(); void setReportDefinition( final IActionSequenceResource reportDefinition ); void setInputStream( InputStream reportDefinitionInputStream ); String getReportDefinitionPath(); void setReportDefinitionPath( String reportDefinitionPath ); boolean isPaginateOutput(); void setPaginateOutput( final boolean paginateOutput ); int getAcceptedPage(); void setAcceptedPage( final int acceptedPage ); boolean isDashboardMode(); void setDashboardMode( final boolean dashboardMode ); boolean getUseJCR(); void setUseJcr( final Boolean useJcr ); String getJcrOutputPath(); void setJcrOutputPath( String jcrOutputPath ); String getMimeType( String ignored ); String getMimeType(); void setOutputStream( final OutputStream outputStream ); boolean isPrint(); void setPrint( final boolean print ); String getPrinter(); void setPrinter( final String printer ); Map<String, Object> getInputs(); void setVarArgs( Map<String, Object> inputs ); void setReport( MasterReport report ); MasterReport getReport(); String getComputedOutputTarget(); void applyInputsToReportParameters( final MasterReport report, final ParameterContext context ); ValidationResult applyInputsToReportParameters( final ParameterContext context,
                                                         ValidationResult validationResult ); int getPageCount(); boolean validate(); void execute(); boolean _execute(); int paginate(); static final String OUTPUT_TARGET; static final String OUTPUT_TYPE; static final String MIME_TYPE_HTML; static final String MIME_TYPE_EMAIL; static final String MIME_TYPE_PDF; static final String MIME_TYPE_XLS; static final String MIME_TYPE_XLSX; static final String MIME_TYPE_RTF; static final String MIME_TYPE_CSV; static final String MIME_TYPE_TXT; static final String MIME_TYPE_XML; static final String MIME_TYPE_PNG; static final String XLS_WORKBOOK_PARAM; static final String REPORTLOAD_RESURL; static final String REPORT_DEFINITION_INPUT; static final String USE_JCR; static final String REPORTHTML_CONTENTHANDLER_PATTERN; static final String REPORTGENERATE_YIELDRATE; static final String ACCEPTED_PAGE; static final String PAGINATE_OUTPUT; static final String PRINT; static final String PRINTER_NAME; static final String DASHBOARD_MODE; static final String MIME_GENERIC_FALLBACK; static final String PNG_EXPORT_TYPE; static final String RESERVEDMAPKEY_LINEAGE_ID; }
@Test public void testCreateOutputHandlerForOutputtype() throws Exception { MasterReport report = mock( MasterReport.class ); Configuration config = mock( Configuration.class ); doReturn( config ).when( report ).getConfiguration(); doNothing().when( report ).setReportEnvironment( any( ReportEnvironment.class ) ); doReturn( false ).when( report ).getAttribute( anyString(), anyString() ); ModifiableConfiguration modifiableConfiguration = mock( ModifiableConfiguration.class ); doNothing().when( modifiableConfiguration ).setConfigProperty( anyString(), anyString() ); doReturn( modifiableConfiguration ).when( report ).getReportConfiguration(); sra.setReport( report ); sra.setDashboardMode( true ); ReportOutputHandler result = sra.createOutputHandlerForOutputType( "pageable/text" ); assertNotNull( result ); verify( modifiableConfiguration, times( 1 ) ).setConfigProperty( HtmlTableModule.BODY_FRAGMENT, "true" ); }