<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<mediawiki version="0.3" xml:lang="en">
   <siteinfo xmlns:xalan="http://xml.apache.org/xalan">
      <sitename>jobscheduler</sitename>
      <base>http://sourceforge.net/apps/mediawiki/jobscheduler/index.php?title=Main_Page</base>
      <generator>MediaWiki 1.15.1</generator>
      <case>first-letter</case>
   </siteinfo>
   <page>
      <title>Job JobSchedulerJasperReportJob</title>
      <id/>
      <revision>
         <id/>
         <timestamp>xxxxx</timestamp>
         <contributor>
            <username>Soskb</username>
            <id>8</id>
         </contributor>
         <text xml:space="preserve">[[Category:ReadyMadeJobs]][[Category:JobSchedulerJasperReportJob]]
 

 
===Description of JobSchedulerJasperReportJob - Create Report with JasperReport===
 
<div>This job uses JasperReports (see http://jasperreports.sourceforge.net) to ceate a report file from a report configuration.

Report configurations are usually created with a visual editor such as iReport (see http://ireport.sourceforge.net).

The database connection of the Job Scheduler is used or alternatively a configurable database connection can be used to query report data.
TODO:Die Berichtsdaten können zusätzlich mittels Job Parameter generiert werden. Alle Jobparameter werden den JasperReport als Parameter zum Weiterverarbeiten weitergegeben.

This job supports the report formats PDF, HTML, RTF, XML and XLS.
Adding the -Djava.awt.headless=true to your Job: &lt;job title="Create JasperReport for Application Manager" java_options="-Djava.awt.headless=true"&gt;</div>
 

 
An example for a job-xml file:
 
  &lt;job order='no' &gt;
     &lt;params&gt;
       &lt;param name="[[#settings_filename|settings_filename]]" value="" /&gt;
       &lt;param name="[[#report_filename|report_filename]]" value="" /&gt;
       &lt;param name="[[#query_filename|query_filename]]" value="" /&gt;
       &lt;param name="[[#query_statement|query_statement]]" value="" /&gt;
       &lt;param name="[[#parameter_query_filename|parameter_query_filename]]" value="" /&gt;
       &lt;param name="[[#output_type|output_type]]" value="pdf" /&gt;
       &lt;param name="[[#output_filename|output_filename]]" value="" /&gt;
       &lt;param name="[[#printer_name|printer_name]]" value="" /&gt;
       &lt;param name="[[#printer_copies|printer_copies]]" value="1" /&gt;
       &lt;param name="[[#mail_it|mail_it]]" value="false" /&gt;
       &lt;param name="[[#mail_to|mail_to]]" value="" /&gt;
       &lt;param name="[[#mail_cc|mail_cc]]" value="" /&gt;
       &lt;param name="[[#mail_bcc|mail_bcc]]" value="" /&gt;
       &lt;param name="[[#mail_subject|mail_subject]]" value="config/default.xslt" /&gt;
       &lt;param name="[[#mail_body|mail_body]]" value="" /&gt;
       &lt;param name="[[#suspend_attachment|suspend_attachment]]" value="false" /&gt;
       &lt;param name="[[#report_locale|report_locale]]" value="de" /&gt;
       &lt;param name="[[#any additional parameters|any additional parameters]]" value="" /&gt;
     &lt;/params&gt;
     &lt;script language="java" java_class="sos.stacks.jasperreports.JobSchedulerJasperReportJob" /&gt;
  &lt;/job&gt;
 

 

 
===Parameter used by JobSchedulerJasperReportJob===
 
 
 

{| border="1"
|+ List of parameter
! ! Name || title || mandatory || default
|- 
| [[#settings_filename|settings_filename]]
| 
| false
| 
|- 
| [[#report_filename|report_filename]]
| 
| true
| 
|- 
| [[#query_filename|query_filename]]
| 
| false
| 
|- 
| [[#query_statement|query_statement]]
| 
| false
| 
|- 
| [[#parameter_query_filename|parameter_query_filename]]
| 
| false
| 
|- 
| [[#output_type|output_type]]
| 
| false
| pdf
|- 
| [[#output_filename|output_filename]]
| 
| true
| 
|- 
| [[#printer_name|printer_name]]
| 
| false
| 
|- 
| [[#printer_copies|printer_copies]]
| 
| false
| 1
|- 
| [[#mail_it|mail_it]]
| 
| false
| false
|- 
| [[#mail_to|mail_to]]
| 
| false
| 
|- 
| [[#mail_cc|mail_cc]]
| 
| false
| 
|- 
| [[#mail_bcc|mail_bcc]]
| 
| false
| 
|- 
| [[#mail_subject|mail_subject]]
| 
| false
| config/default.xslt
|- 
| [[#mail_body|mail_body]]
| 
| false
| 
|- 
| [[#suspend_attachment|suspend_attachment]]
| 
| false
| false
|- 
| [[#report_locale|report_locale]]
| 
| false
| de
|- 
| [[#any additional parameters|any additional parameters]]
| 
| false
| 
|}


 
====Parameter <span id="settings_filename">settings_filename</span>: ====
----
 
<div>This parameter specifies the path and name of a configuration file for database connection settings. If such a file is specified then its database connection settings are used for the report query, otherwise the Job Scheduler database connection is used.</div>
 
Data-Type : 
 


 
====Parameter <span id="report_filename">report_filename</span>: ====
----
 
<div>This parameter specifies the path and name of a file containing the report configuration. The source code of a configuration files is organized as xml document and is usually stored with the extension<code> .jrxml </code>. You should assign to this parameter the compiled configuration file name that is usually stored with the extension<code> .jasper </code>.</div>
 
Data-Type : 
 
This parameter is mandatory.
 


 
====Parameter <span id="query_filename">query_filename</span>: ====
----
 
<div>This parameter specifies the path and name of an input file with sql statements. If this parameter is assigend a file name then the query given in this file will be used for the report insted of the query that has been given in the report configuration file, see<code> report_filename </code>.</div>
 
Data-Type : 
 


 
====Parameter <span id="query_statement">query_statement</span>: ====
----
 
<div>The value of this parameter is a sql statement encoded with base64. This value will be decoded and used for the report query.

The parameters<i>query_filename</i>and<i>query_statement</i>are mutually exclusive, as sql statements can be used from one of these sources only.</div>
 
Data-Type : 
 


 
====Parameter <span id="parameter_query_filename">parameter_query_filename</span>: ====
----
 
<div>This parameter specifieds the name of a file with sql statements. Should a filename be assigned to this parameter then the query will be executed and the result set will be handed to JasperReports as parameters.</div>
 
Data-Type : 
 


 
====Parameter <span id="output_type">output_type</span>: ====
----
 
<div>This parameter specifies the output type of the report:

* PDFThe report will be created as pdf file. 
 
* HTMThe report will be created as HTML file preferably for browsers. This format is not perfectly suitable for printing as no separate pages are created. 
 
* RTFThe report is created in Rich Text Format for word processors as MS Office, OpenOffice etc. 
 
* XMLThe report is created as xml document. 
 
* XLSThe report is created for MS Excel. 
 

 

The output type is independent from the file name given for the report file, you should choose a suitable file name and extension for the parameter<code> output_filename </code>.</div>
 
Data-Type : 
 
The default value for this parameter is  '''pdf'''.
 


 
====Parameter <span id="output_filename">output_filename</span>: ====
----
 
<div>This parameter specifies the path and name of the report file that is created by this job.</div>
 
Data-Type : 
 
This parameter is mandatory.
 


 
====Parameter <span id="printer_name">printer_name</span>: ====
----
 
<div>Should a value be assigned to this parameter then the generated report will be printed to a printer with this name. If the printer name contains the prefix<i>factory:</i>then the printer will not be looked up in the operating system, but will be matched to the name of a print queue and corresponding printer name in the Document Factory.</div>
 
Data-Type : 
 


 
====Parameter <span id="printer_copies">printer_copies</span>: ====
----
 
<div>The number of copies to be printed. The value of this parameter has to contain digits with a value greater 0. This parameter is considered if a printer name has been specified, see parameter<i>printer_name</i>.</div>
 
Data-Type : 
 
The default value for this parameter is  '''1'''.
 


 
====Parameter <span id="mail_it">mail_it</span>: ====
----
 
<div>Should this parameter be assigned the value<code> true </code>, then reports will by sent by mail with the built-in mail function of the Job Scheduler.

Additional parameters are considered as<i>mail_to</i>,<i>mail_cc</i>,<i>mail_bcc</i>,<i>mail_subject</i>and<i>mail_body</i>that specify the recipients and the format of mails. Should these additional parameters be missing then the values are used from the respective settings in the configuration file<i>factory.ini</i>.

Should the value<code> false </code>be assigned to this parameter then mails will be sent with the java class<code> SOSMailOrder </code>, if one of the parameters<i>mail_to</i>,<i>mail_cc</i>,<i>mail_bcc</i>,<i>mail_subject</i>or<i>mail_body</i>has been specified. Prerequisites for the use of<code> SOSMailOrder </code>are:

* 1. Database connection (of the Job Scheduler) 
 
* 2. TableSETTINGS 
 
* 3. Entries for mail forwarding in tableSETTINGS 
 

 
These requirements are met if the component<i>Managed Jobs</i>has been selected during installation of the Job Scheduler.

Recipients, subject and body of mails are always applied from job parameters, not from settings.</div>
 
Data-Type : 
 
The default value for this parameter is  '''false'''.
 


 
====Parameter <span id="mail_to">mail_to</span>: ====
----
 
<div>One or more mail addresses of recipients of a report. Multiple addresses are separated by commas. Should this setting be left empty, then no reports will be sent by mail. The reports will however be generated and saved to disk.</div>
 
Data-Type : 
 


 
====Parameter <span id="mail_cc">mail_cc</span>: ====
----
 
<div>One or more mail addresses of recipients of carbon copies of a report. Multiple addresses are separated by commas.</div>
 
Data-Type : 
 


 
====Parameter <span id="mail_bcc">mail_bcc</span>: ====
----
 
<div>One or more mail addresses of recipients of blind carbon copies of a report. Multiple addresses are to be separated by commas.</div>
 
Data-Type : 
 


 
====Parameter <span id="mail_subject">mail_subject</span>: ====
----
 
<div>This parameter specifies the subject of mails that is used to send reports. This parameter is mandatory should reports be sent by mail.

Automated substitutions in the parameter value are optionally specified using one of the following prefixes:

* factory: 
 
* factory_file: 
 
* plain: 
 
* plain_file: 
 

 
<p>Should no prefix be specified then the value of this parameter is used without changes. Should a prefix be specified then the value may contain placeholders that are automatically substituted at run time. As a prerequisite of the prefixes<code> factory: </code>and<code> factory_file: </code>the Document Factory product has to be installed.</p>The following placeholders can be used, surrounded by square brackets<code> [] </code>:

* [date] - the current date 
 
* [datetime] - the current date and time 
 
* [orderid] - the order ID 
 
* [jobname] - the job name 
 
* [taskid] - the task ID 
 

 
</div>
 
Data-Type : 
 
The default value for this parameter is  '''config/default.xslt'''.
 


 
====Parameter <span id="mail_body">mail_body</span>: ====
----
 
<div>This parameter specifies the report body of mails that is used to send reports. This parameter is mandatory should reports be sent by mail.

Automated substitutions in the parameter value are optionally specified using one of the following prefixes:

* factory: 
 
* factory_file: 
 
* plain: 
 
* plain_file: 
 

 
<p>Should no prefix be specified then the value of this parameter is used without changes. Should a prefix be specified then the value may contain placeholders that are automatically substituted at run time. As as rerequisite of the prefixes<code> factory: </code>and<code> factory_file: </code>the Document Factory product has to be installed.</p>The following placeholders can be used, surrounded by square brackets<code> [] </code>:

* [date] - the current date 
 
* [datetime] - the current date and time 
 
* [orderid] - the order ID 
 
* [jobname] - the job name 
 
* [taskid] - the task ID 
 
* [sql] - SQL query for which the report has been generated 
 
* [xml] - xml format of the query result before any transformation is applied 
 

 
<p>Note that the value of this parameter will be ignored, should the parameter<i>scheduler_order_report_asbody</i>be set to<code> true </code>: in this case the content of the report is used as mail body.</p></div>
 
Data-Type : 
 


 
====Parameter <span id="suspend_attachment">suspend_attachment</span>: ====
----
 
<div>Prevents reports from being sent as mail attachments if the value<code> true </code>is specified.</div>
 
Data-Type : 
 
The default value for this parameter is  '''false'''.
 


 
====Parameter <span id="report_locale">report_locale</span>: ====
----
 
<div>This parameter is used to dynamically assign language files to reports that support multiple languages. Such language files are created per report and have to be located in the same directory as the report definition. Language file names follow this schema:

<code> &lt;report file&gt;_&lt;language&gt;.properties </code>

An example:

A report<code> summary.jasper </code>could use the following language files:

* summary.properties(default language file) 
 
* summary_en.properties(english language file) 
 
* summary_de.properties(german langauge file) 
 

 

Should no language files be specified then the default language file will be used. The name of the default language file is<code> summary.properties </code>. Language files contain pairs of<code> key=value </code>, e.g.

* text.orders_from=orders dated from 
 
* text.to=to 
 

 

Please translate the right side of this assignment into the target language. The left side contains the name of the variable that is used in the report definition and that is substituted when the report is generated. The German version of this example could be:

* text.orders_from=Bestellungen von 
 
* text.to=bis 
 

 
</div>
 
Data-Type : 
 
The default value for this parameter is  '''de'''.
 


 
====Parameter <span id="any additional parameters">any additional parameters</span>: ====
----
 
<div>Any additional job parameters may be specified that are automatically handed to JasperReports and will be substituted in a report.</div>
 
Data-Type : 
 

 
This article was last modified on (mm/dd/yyyy)  {{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}.
 
[[File:Wiki-rabbit-left.jpg]] &lt;&lt; [[JobScheduler_FAQ| back to all FAQs]]</text>
      </revision>
   </page>
</mediawiki>