alamuvinai Posted December 28, 2012 Share Posted December 28, 2012 Custom checkbox in Scheduler Job UI:Requirement is to add a custom checkbox (Pipe) and when scheduleder is run, it should export txt file with pipe delimiter (very similar to csv output)added a custom check box (Pipe) in addition to the existing ones - Pdf, Csv, Excel, Docx etc - these code changes works fineviewReportBeans.xml reportJobBeans.xml ReportJob.java (added a constant for pipe with value of 13) jasperserver_messages.properties (for UI display)When scheduling the report to run (immediately or in interval), the pipe delimiter code (custom) is not picked up.For scheduler, made changes toapplicationContext-report-scheduling.xml added customCode - PipeReportOutput.javaadded loggging in the CSVReportOutput, PipeReportOutput, and other reportOutput classes; when the scheduled job is run, there is no logging output from any of these files. (including CSVReportOutput) But the job runs fine and able to see the report output in the path specified. (not for pipe delimiter though)Can someone please share your ideas of what files to be modified so that scheduler picks up this custom code when exporting?FYI: applicationContext-adhoc.xml changes (very similar to csvExport but with pipe delimiter and txt extension, so using csvExportParameters as parent):bean id="jobPipeExportParameters" parent="csvExportParameters" .. util:map id="jobExportParametersMap" entry key="pipe" value-ref="jobPipeExportParameters" .. util:map id="outputKeyMapping" entry key="13" value="pipe" .. bean id="pipeOutput" class="com.jaspersoft.jasperserver.api.engine.scheduling.quartz.PipeReportOutput" property name="exportParams" ref="jobPipeExportParameters" bean .. util:map id="outputFormatMap" entry key="pipe" value-ref="pipeOutput" PipeReportOutput.java public class PipeReportOutput extends AbstractReportOutput { private CsvExportParametersBean exportParams; ........ ...... public ReportOutput getOutput( EngineService engineService, ExecutionContext executionContext, String reportUnitURI, DataContainer csvData, JRHyperlinkProducerFactory hyperlinkProducerFactory, RepositoryService repositoryService, JasperPrint jasperPrint, String baseFilename, Locale locale, String characterEncoding) throws JobExecutionException { try { System.out.println("pipe getOutput method entry ** "); JRCsvExporter exporter = new JRCsvExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); boolean close = false; OutputStream csvDataOut = csvData.getOutputStream(); try { exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, characterEncoding); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, csvDataOut); if(exportParams != null) exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, "|"); exporter.exportReport(); close = false; csvDataOut.close(); String fileName = baseFilename + ".txt"; return new ReportOutput(csvData, ContentResource.TYPE_CSV, fileName); } catch (IOException e) { throw new JSExceptionWrapper(e); } finally { if (close) { try { csvDataOut.close(); } catch (IOException e) { log.error("Error closing stream", e); } } } } catch (JRException e) { throw new JSExceptionWrapper(e); } } Link to comment Share on other sites More sharing options...
alamuvinai Posted January 11, 2013 Author Share Posted January 11, 2013 Hi,In addition to the above changes, modified the file jasperserver_config.properties file and added this line:report.scheduling.output.format.13=pipeAble to run the scheduled job output for pipe only once after the job is scheduled. On subsequent runs from the same job, pipe delimiter output doesnot show up. Is there any caching involved for this?Also, when run immediately, pipe delimiter doesn't output at all. Is there any other setting to be changed for this? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now