Jump to content
We've recently updated our Privacy Statement, available here ×

Custom checkbox to Scheduler Job UI


alamuvinai

Recommended Posts

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 fine

viewReportBeans.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 to

applicationContext-report-scheduling.xml
added customCode - PipeReportOutput.java

added 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

  • 2 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

In addition to the above changes, modified the file jasperserver_config.properties file and added this line:

report.scheduling.output.format.13=pipe

Able 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...