Creating Action Sequences
Creating Action Sequences
This document is copyright © 2010 Pentaho Corporation. No part may be reprinted without written
permission from Pentaho Corporation. All trademarks are the property of their respective owners.
Trademarks
Pentaho (TM) and the Pentaho logo are registered trademarks of Pentaho Corporation. All
other trademarks are the property of their respective owners. Trademarked names may appear
throughout this document. Rather than list the names and entities that own the trademarks or insert
a trademark symbol with each mention of the trademarked name, Pentaho states that it is using the
names for editorial purposes only and to the benefit of the trademark owner, with no intention of
infringing upon that trademark.
Company Information
Pentaho Corporation
Citadel International, Suite 340
5950 Hazeltine National Drive
Orlando, FL 32822
Phone: +1 407 812-OPEN (6736)
Fax: +1 407 517-4575
http://www.pentaho.com
E-mail: [email protected]
Sales Inquiries: [email protected]
Documentation Suggestions: [email protected]
Sign-up for our newsletter: http://community.pentaho.com/newsletter/
Contents
Introduction............................................................................................................... 5
What is an Action Sequence?.................................................................................................. 5
What is a Solution?.................................................................................................................. 5
Requirements and Recommendations..................................................................................... 5
Using Design Studio................................................................................................. 7
Initial Design Studio Configuration........................................................................................... 7
The Design Studio Interface.....................................................................................................8
Creating Design Studio Templates...........................................................................................9
Creating a Solution Directory..................................................................................10
Your First Action Sequence.................................................................................... 11
Anatomy of an Action Sequence............................................................................ 13
Output Types..........................................................................................................................14
Input Types.............................................................................................................................16
Resources.............................................................................................................................. 16
Parameter Data Types........................................................................................................... 17
Action Definition Reference.................................................................................... 18
ContentRepositoryCleaner..................................................................................................... 18
EmailComponent....................................................................................................................19
PrintComponent..................................................................................................................... 21
SecureFilterComponent......................................................................................................... 23
SubActionComponent............................................................................................................ 26
TemplateComponent (Message Template)............................................................................28
JavascriptRule........................................................................................................................28
SimpleReportingComponent.................................................................................................. 29
JFreeReportComponent.........................................................................................................33
Charting..................................................................................................................................36
JFreeChart (ChartComponent)....................................................................................36
Pentaho ChartBeans (ChartBeansComponent).......................................................... 36
OpenFlashChart (OpenFlashChartComponent)..........................................................36
Editing Existing Action Sequences......................................................................... 57
Internationalization Guidelines................................................................................58
Basic Action Sequence Tips and Tricks................................................................. 60
Emailing a Report...................................................................................................................60
Advanced Action Sequence Tips and Tricks.......................................................... 63
Using Java Virtual Machine Input Parameters....................................................................... 63
Using Action Sequence Variables in Kettle/PDI..................................................................... 63
Sharing Result Sets in Action Sequences..............................................................................66
Creating Custom Action Sequence Error Messages..............................................................67
In-Depth Action Sequence Tutorials....................................................................... 69
Creating a Bar Chart Using the Flash Chart Component....................................................... 69
Configuring Design Studio...........................................................................................69
| TOC | 3
Creating the Chart Definition....................................................................................... 70
Creating the Action Sequence.....................................................................................72
Viewing your Chart in the BI Platform..........................................................................76
Finding More Information.............................................................................................76
Using the Result Set Burst Component..................................................................................77
How the Burst Component Works............................................................................... 77
Input and Output..........................................................................................................79
Prerequisites................................................................................................................79
Implementing the Burst Component............................................................................ 79
Troubleshooting...........................................................................................................81
4 | | TOC
Introduction
Action sequences are a unique and powerful feature of the Pentaho BI Platform; they enable BI developers
and business users to perform advanced tasks that cannot easily be accomplished through Pentaho's
design tools and user interface functions, including interaction with third-party software frameworks. This
guide is designed to help experienced BI Platform users learn to create and edit action sequences using
the Action Sequence Editor built into Pentaho Design Studio.
Note: This guide is not yet finished. It is being published early because it contains a great deal of
useful information, and the extended delay caused by completing the component reference and
action sequence examples would unreasonably prevent it from reaching BI Suite Enterprise Edition
customers in an acceptable timeframe. Please do let your Pentaho sales or support representative
know if there are unfinished or missing sections that you would like to read.
What is a Solution?
A collection of action sequences that fit a common theme or purpose is called a solution, and each
solution is typically in its own directory. By default, all solutions are in subdirectories in the /pentaho/
server/biserver-ee/pentaho-solutions/ directory, which is mirrored in the solution repository
database. Mirroring the solutions directory allows the BI Platform to have fine-grained control of user and
role access to each file and subdirectory.
| Introduction | 5
Design Studio is included with a standard BI Suite Enterprise Edition workstation deployment. If it is not
installed on your system, you can either re-run the BI Suite installation utility, or you can download an
individual Design Studio package from the Pentaho Enterprise Edition FTP site, or the Knowledge Base. If
you are on a supported 64-bit operating system, you will have to install the Eclipse integrated development
environment for your platform on your own, then download and install the Pentaho Action Sequence
Editor Eclipse plugins. Instructions for this process are included in the Pentaho BI Suite Archive-Based
Installation Guide, which is available in the Pentaho Knowledge Base.
In order to test and publish your action sequences, you will have to either install Design Studio on
the same machine as your BI Server, or you will have to install a standalone BI Server instance for
action sequence development on your workstation. Once you've developed and tested your new action
sequence, you can copy it over to your production server to deploy it.
6 | | Introduction
Using Design Studio
This section explains how to use the basic functionality of the Action Sequence Editor in Pentaho Design
Studio.
Design Studio starts by default in a specialized view that limits its interface options to the actions defined
in the template. You can switch to Generic Component Mode, which shows all possible component
parameters, by clicking the toggle button to the right of Process Inputs, shown in the graphic below
underneath the untitled1.xaction tab:
The following example shows the JFree_Quad.xaction in the Define Process tab with some defined
process inputs, process actions, and process outputs. The focus is on the REGION process input, so the
right pane shows the options for defining this specific input.
Before you begin creating action sequences, it makes sense to create a directory to store them in. In
theory, this directory will contain a collection of action sequences that fit a common purpose or theme
-- a solution, which would make this a solution directory. You should create a new directory for every
solution you develop.
You now have a new solution directory. It will show up in all file dialogues in the Pentaho User Console as
well as the Solution Browser in the left pane.
Every time you add or edit an action sequence to your solution directory, you must refresh the repository
cache as explained above. Each user currently logged into the Pentaho User Console must also refresh
their session cache; this is best done by re-logging into the Pentaho User Console.
Follow the directions below to create the simplest kind of functional action sequence with Design Studio.
1. In Design Studio, go to the File menu, then select New, and click on Other... in the sub-menu.
The New window will appear.
2. In the New window, click the triangle next to Pentaho, select New Action Sequence Wizard, then click
Next.
3. In the File name field, type hello_world.xaction.
4. Select Hello World from the Template drop-down box, then click Finish.
The wizard will generate the new file and bring you back to the workbench.
5. Click on HelloWorldComponent in the Process Actions section on the left.
The right side of the screen will change to show the options available for this action: Name and
Message. The Name field controls the name of the component in the Process Actions list on the left;
it doesn't do anything else of note. The Message field contains the text that will appear on the screen
when the action sequence is run. It is pre-populated with %quote, which is a token that represents
a quote message in a nonexistent properties file. Pentaho used to provide properties files for each
example, but they have been removed from the standard BI Suite distribution.
6. Replace the %quote with a sufficiently inspiring message.
Alternatively, you could create a hello_world.properties file and populate it with the appropriate
messages and tokens, but that has no advantage unless you intend to internationalize this action
sequence.
7. Save the file.
You now have a working action sequence that prints a short text message: "Hello, World." plus whatever
you typed into the Message field. The first part of the message is determined by a message bundle
packaged with the Pentaho Web application archive.
In the below example action sequence, an email is generated and sent to either Joe or Suzy, depending
on which region the user selects. There are four inputs: region, from, subject, and message-plain. The
region input type is defined as a string, and it has a default value of Central. Region may come from one
of two sources: request or session. When the RuntimeContext resolves the region input at runtime, it
will first look in the request (most likely an HTTP request). If it doesn't find it in the request, it will look in the
session (most likely the HTTP session). If it is not available in the session, the default value will be used.
The order that the sources are specified in the XML document is the order that they will be searched. The
default is always used as a last resort.
The other three inputs only specify a default value. This is analogous to hard-coding the parameters to a
constant value. Since the output of this action sequence is an email message, no output parameters will be
set.
There are two action-definition nodes for this sequence. The first invokes the JavascriptRule component
and takes a region parameter as input; it will create a new parameter called rule_result as output. This
new parameter will be made available to other action-definition nodes in the sequence.
The JavaScript defined in the component-definition will be executed and will set the value of rule_result
to the appropriate email address, based on the value of region.
When the first action-definition completes, the second, which defines an interaction with
EmailComponent, will execute. EmailComponent requires four action-inputs: to, from, subject, and
message-plain.
You may have noticed that some of the action-inputs (from, subject and message-plain) are also specified
in the inputs section of the action sequence header. The RuntimeContext will take the values from there
and pass them to EmailComponent just as it passed region to the JavascriptRule. The source of the action-
input is indirectly defined with the mapping attribute, which tells the RuntimeContext to use the value from
rule_result that was generated by the JavascriptRule action and use it as the component's to input.
<action-sequence>
<name>Example1.xaction</name>
<documentation>
<author>Chuck Norris</author>
<description>Email to selected user</description>
<help>There is no help when Chuck Norris emails you</help>
</documentation>
<inputs>
<region type="string">
<default-value>Central</default-value>
<sources>
<request>REGION</request>
<session>aRegion</session>
</sources>
</region>
<from type="string">
<default-value>[email protected]</default-value>
</from>
<subject type="string">
<default-value>Pentaho Example1</default-value>
</subject>
<message-plain type="string">
<default-value>
This is an email from the Pentaho BI Platform - Example1
<outputs/>
<resources/>
<actions>
<action-definition>
<action-inputs>
<region type="string"/>
</action-inputs>
<action-outputs>
<rule_result type="string"/>
</action-outputs>
<component-name>JavascriptRule</component-name>
<component-definition>
<script>
<![CDATA[
if ( "Central".equals( region ) ) {
rule_result = "[email protected]";
}
else {
rule_result = "[email protected]";
}
]]>
</script>
</component-definition>
</action-definition>
<action-definition>
<action-inputs>
<to type="string" mapping="rule_result"/>
<from type="string"/>
<subject type="string"/>
<message-plain type="string"/>
</action-inputs>
<component-name>EmailComponent</component-name>
<component-definition/>
</action-definition>
</actions>
</action-sequence>
Output Types
Component-specific action-outputs are defined on an individual basis and can vary; however, global output
handlers are static.
The output variable data types are defined in Design Studio, and are reasonably self-explanatory. For the
majority of action sequences, you will only be using string and content (binary file) data types. All output
types can be parameterized by using {curly braces}.
response
This directs previously generated content to whatever agent made the request (usually a Web browser).
If you want to save the content for later use, you should use the file output handler (explained below)
instead.
file
This is direct output to a file. The path to the file is defined through a platform-specific URI. The default
location is the BI Server's working directory. If the location you specify does not exist, the BI Platform will
attempt to create it. If the file name you specify is already in use, the existing file will be replaced with the
new one you are generating.
<outputs>
<myReport type="content">
<destinations>
<file>file:invoice_{orderkey}.pdf</file>
</destinations>
</myReport>
</outputs>
Apache VFS
This directs output to the Apache Commons Virtual Filesystem. Currently, only the FTP destination type is
supported.
<outputs>
<content type="content">
<destinations>
<vfs-ftp>vfs-ftp://ftp.example.org|bsmith:[email protected]/
mytest.txt</vfs-ftp>
</destinations>
</content>
</outputs>
Input Types
Inputs are typically small, dynamic data sources that are available globally for all actions in an action
sequence. Each is declared as a variable with a static data type, one or more methods of retrieving the
data, and a default value in case no data is retrieved.
Note: If you declare a default-value without assigning a value, the user running the action
sequence will be prompted for a value, if possible.
Resources
Resources define unique input sources that have a specific MIME type and a path. Usually you would use
a resource instead of an input when you're referring to large or unusual data sources.
file
The full path to a local file (or a file accessible through a local directory), including the file name.
<file>
<location>/home/pentaho/samples/reporting/myReport.prpt</location>
<mime-type>text/xml</mime-type>
</file>
url
A link to a remote file accessible via HTTP.
<url>
<location>http://www.example.com/logo.png</location>
<mime-type>image/png</mime-type>
</url>
string
An inline block of text in CDATA tags, as opposed to an external text file.
<string>
<location><![CDATA[This is a text string.]]></location>
<mime-type>text/plain</mime-type>
</string>
xml
Inline XML, as opposed to an external XML file.
<xml>
<location><node type="primary">An example</node></location>
<mime-type>text/xml</mime-type>
</xml>
All of the possible BI Platform action definitions -- the entirety of what you can do with an action sequence
-- are defined in sufficient detail below. Some components have templates in Design Studio, and some do
not. When you can't use a template, you will have to switch to Generic Component Mode, or create the
action sequence with raw XML.
Note: All XML tags are case-sensitive. Some are all lowercase, some are all uppercase, and some
are camel-cased. Pay close attention to case-sensitivity when working in Generic Component Mode
and with raw XML.
ContentRepositoryCleaner
The ContentRepositoryCleaner action removes files and metadata from the Pentaho content repository,
which stores generated reports and other BI Platform output. This is particularly useful in two situations:
Removing data that is so old that it is no longer valid, and removing orphaned content artifacts created or
scheduled by inactive or deleted BI Platform user accounts.
<inputs>
<days-back type="string">
<default-value>180</default-value>
</days-back>
</inputs>
<outputs>
<delete-count>
<type>string</type>
</delete-count>
</outputs>
<actions>
<action-definition>
<component-
name>org.pentaho.plugin.core.ContentRepositoryCleaner</component-
name>
<action-type>rule</action-type>
<action-inputs>
<days-back type="string"/>
</action-inputs>
<action-outputs>
<delete-count type="string"/>
</action-outputs>
<component-definition/>
</action-definition>
</actions>
</action-sequence>
EmailComponent
The EmailComponent enables you to send email messages from the BI Platform. Most of the inputs are
standard email parameters and need little explanation. The message-plain and message-html values are
meant to be used in an either-or scenario; you would use one or the other, but not both.
Attachments are not defined as inputs, but as resources of type file with the text/plain mime-type. The
attachment resource is then called in the component definition as an attachment-ref, shown in the
example action sequence below.
Action Input Data Type Definition
message-plain String The email message body in
plain text
message-html String The email message body in
HTML format
subject String The email subject
to String The email address of
the message recipient.
You may specify multiple
addresses by using a
comma to separate each
cc String The email address of a
secondary (carbon copy)
message recipient. You
may specify multiple
addresses by using a
comma to separate each
bcc String The email address of a
blind carbon copy message
recipient, who will not be
able to see the recipients
specified in the to, cc, or
bcc fields. You may specify
<inputs>
<to type="string">
<default-value/>
<sources>
<request>to</request>
</sources>
</to>
<from type="string">
<default-value>[email protected]</default-value>
</from>
<subject type="string">
<default-value>%subject</default-value>
<sources>
<request>email-subject</request>
</sources>
</subject>
<message-plain type="string">
<default-value>%message</default-value>
</message-plain>
</inputs>
<outputs/>
<resources>
<attach_resource_1>
<file>
<location>/home/bobs/pentaho/server/biserver-ee/pentaho-
solutions/initech/analysis/tps_latest.analysisview.xaction</
location>
<mime-type>text/plain</mime-type>
</file>
<actions>
<action-definition>
<component-name>org.pentaho.component.EmailComponent</
component-name>
<action-type>The Bobs Consulting</action-type>
<action-inputs/>
<action-resources>
<attach_resource_1 type="resource"/>
</action-resources>
<component-definition>
<attachment-ref name-param="attach_name_1" resource-
param="attach_resource_1"/>
<attach_name_1><![CDATA[folder2.png]]></attach_name_1>
<to><![CDATA[[email protected],[email protected]]]></
to>
<cc><![CDATA[[email protected]]]></cc>
<from><![CDATA[[email protected]]]></from>
<bcc><![CDATA[[email protected]]]></bcc>
<subject><![CDATA[Analysis view of effects of new cover
sheets for TPS reports]]></subject>
<message-plain><![CDATA[I'll go ahead and send you
the latest statistics on TPS report cover sheet changes.]]></
message-plain>
</component-definition>
</action-definition>
</actions>
</action-sequence>
PrintComponent
PrintComponent sends a PDF or HTML file to a printer that is accessible from the BI Platform server. If no
printer is specified statically, you will be presented with a list of detected printers to select from at runtime.
If you want to use the system default printer, set printer-name to PENTAHO_DEFAULT_PRINTER.
The content to print can be specified in one of two ways: By specifying the file as a print-file resource or
component setting, or by having a previous action in the sequence pipe its output to the report-output
parameter. Currently, the JFreeComponent, BIRTComponent, and JasperComponent all have the ability
to generate content suitable for the report-output parameter. If no content to print is specified, the action
sequence will fail.
<inputs>
<output-type type="string">
<default-value>html</default-value>
<sources>
<request>type</request>
</sources>
</output-type>
<printer-name type="string">
<default-value/>
<sources>
<request>printer</request>
</sources>
</printer-name>
<default-printer type="string">
<default-value/>
<sources>
<session>printer</session>
</sources>
</default-printer>
</inputs>
<outputs>
<default-printer type="string">
<destinations>
<session>printer</session>
</destinations>
</default-printer>
</outputs>
<resources>
<!-- use this section to identify any files that the
component needs to execute the report -->
<report-definition>
<solution-file>
<location>JFreeQuadForRegion.xml</location>
<mime-type>text/xml</mime-type>
</solution-file>
</report-definition>
</resources>
<actions>
<action-definition>
<component-name>PrintComponent</component-name>
<action-type>print</action-type>
<action-inputs>
<action-definition>
<component-name>JFreeReportComponent</component-name>
<action-type>report</action-type>
<action-inputs>
<output-type type="string"/>
<printer-name type="string"/>
</action-inputs>
<action-resources>
<report-definition type="resource"/>
</action-resources>
<component-definition>
<source>sql</source>
<live>true</live>
<jndi>SampleData</jndi>
<query><![CDATA[select QUADRANT_ACTUALS.REGION,
QUADRANT_ACTUALS.DEPARTMENT, QUADRANT_ACTUALS.POSITIONTITLE,
QUADRANT_ACTUALS.ACTUAL, QUADRANT_ACTUALS.BUDGET,
QUADRANT_ACTUALS.VARIANCE from QUADRANT_ACTUALS order by
QUADRANT_ACTUALS.REGION, QUADRANT_ACTUALS.DEPARTMENT]]></query>
</component-definition>
</action-definition>
</actions>
</action-sequence>
SecureFilterComponent
The SecureFilterComponent has two separate but related functions: It allows you to customize the default
prompting mechanism, and can verify that only valid selections are returned.
The action inputs are custom variables that define each selection and its data source, as defined in the
selections section of the component definition. Each input may have the following attributes:
Input Attribute Data Type Definition
optional Boolean Specifies whether the
parameter is required or
not. If required, the user
must fill in the value before
continuing
style String Defines the style of control
that will be presented to
the user. Possible values
are: text-box, radio, select,
list, list-multi, check-multi,
check-multi-scroll, check-
multi-scroll-2-column,
<inputs>
<output-type type="string">
<default-value>html</default-value>
<sources>
<request>type</request>
</sources>
</output-type>
<REGION type="string">
<default-value/>
<sources>
<request>REGION</request>
</sources>
</REGION>
<REGION_FILTER type="result-set">
<sources>
<session>REGION_FILTER</session>
</sources>
<default-value/>
</REGION_FILTER>
<DEPARTMENT_FILTER type="property-map-list">
<default-value type="property-map-list">
<outputs>
<result type="content">
<destinations>
<response>content</response>
</destinations>
</result>
</outputs>
<resources>
<report-definition1>
<solution-file>
<location>JFreeQuadForRegion.xml</location>
<mime-type>text/plain</mime-type>
</solution-file>
</report-definition1>
</resources>
<actions>
<actions>
<condition><![CDATA[REGION_FILTER]]></condition>
<action-definition>
<component-name>SecureFilterComponent</component-name>
<action-type>Prompt For Region and Dept</action-type>
<action-inputs>
<REGION type="string"/>
<REGION_FILTER type="result-set"/>
<DEPARTMENT type="string"/>
<DEPARTMENT_FILTER type="property-map-list"/>
</action-inputs>
<action-outputs/>
<component-definition>
<selections>
<!-- for now ignore the column names -->
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>Get Data from Relational</action-type>
<action-inputs>
<REGION type="string"/>
<DEPARTMENT type="string"/>
</action-inputs>
<action-outputs>
<query-result type="result-set"/>
</action-outputs>
<component-definition>
<jndi>SampleData</jndi>
<query><![CDATA[select QUADRANT_ACTUALS.REGION,
QUADRANT_ACTUALS.DEPARTMENT, QUADRANT_ACTUALS.POSITIONTITLE,
QUADRANT_ACTUALS.ACTUAL, QUADRANT_ACTUALS.BUDGET,
QUADRANT_ACTUALS.VARIANCE from QUADRANT_ACTUALS
where QUADRANT_ACTUALS.REGION={PREPARE:REGION} and
QUADRANT_ACTUALS.DEPARTMENT={PREPARE:DEPARTMENT} order by
QUADRANT_ACTUALS.REGION, QUADRANT_ACTUALS.DEPARTMENT]]></query>
</component-definition>
</action-definition>
<action-definition>
<component-name>JFreeReportComponent</component-name>
<action-type>Pentaho Report</action-type>
<action-inputs>
<data type="result-set" mapping="query-result"/>
</action-inputs>
<action-resources>
<report-definition type="resource" mapping="report-
definition1"/>
</action-resources>
<component-definition>
<output-type>html</output-type>
</component-definition>
</action-definition>
</actions>
</actions>
</action-sequence>
SubActionComponent
Each output needs to have a specific name that the parent action will reference as the subaction result.
JavascriptRule
This component executes the specified block of JavaScript, typically as a way of interacting with BI
Platform functions that are not available through other components. Parameters specified as inputs will
be available to the script for use. The JavascriptRule can have one or more outputs. You can also define
library elements in the component definition. Each specified library file must exist in the solution directory,
and will be prepended to the script that's specified in the component definition. In this way, you can create
a library of commonly used JavaScript code, and include it at runtime execution.
Danger: The JavascriptRule component does not contain any limitations or provide any security
checks for the JavaScript you specify. Only the technical validity of the JavaScript code is verified.
This means that anything you can do with JavaScript will be executed when this action sequence
is run. If you are using this component to make any changes to files, databases, or users and
permissions -- or anything else that can potentially be destructive and cannot be undone -- you
should carefully verify that it won't do any harm before testing and deploying it.
You should only use this component if you're familiar with the BI Platform's capabilities and have a good
understanding of what you want to do with this action sequence. Consult the BI Platform Javadoc for
further guidance on how to interact with it: http://javadoc.pentaho.com/bi_platform/.
Required Elements Data Type Definition
script String The JavaScript to be
executed. This code block
In the example below, the function region is called but not assigned to a variable. It is
the only function specified, so upon completion of the component execution, rule-result
will contain the value "Central".
<?xml version="1.0" encoding="UTF-8"?>
<action-definition>
<component-name>org.pentaho.component.JavascriptRule</
component-name>
<action-outputs>
<rule-result type="string"/>
</action-outputs>
<action-type>rule</action-type>
<component-definition>
<script><![CDATA[
function region() {
return "Central";
}
region();
]]>
</script>
</component-definition>
</action-definition>
SimpleReportingComponent
This is the preferred method of generating and manipulating reports programmatically in the BI Suite
version 3.5.0-GA and later. Versions prior to that should use JFreeReportComponent on page 33
instead. In order to use SimpleReportingComponent, you need to have generated a PRPT report file with
Report Designer version 3.5.0 or later.
There is only one "input" for an action sequence involving this component, and it is defined as a resource
in the inputs section of the action sequence, not in the component definition. There are two output
attributes defined in the global input section as well. Essentially you're going to point to your PRPT file,
then define the file name and content type that you want to generate.
There is only one output, defined in either the global outputs section or the SimpleReportingComponent's
action-outputs section:
There are many report options, all of which are technically component inputs, and are positioned in the
action-inputs section. Most of these options are rarely used because most report functionality is determined
when you initially create the report.
<inputs>
<outputType type="string">
<default-value>text/html</default-value>
<sources>
<request>outputType</request>
</sources>
</outputType>
<outputTypeList type="property-map-list">
<sources>
<runtime>outputTypeList</runtime>
</sources>
<default-value type="property-map-list">
<property-map>
<entry key="report-output-desc">PDF</entry>
<entry key="report-output-type-id">application/
pdf</entry>
</property-map>
<property-map>
</inputs>
<outputs>
<myReport type="content">
<destinations>
<response>content</response>
</destinations>
</myReport>
</outputs>
<resources>
<reportDefinition>
<solution-file>
<location>incomestatement_external.prpt</location>
<mime-type>application/zip</mime-type>
</solution-file>
</reportDefinition>
</resources>
<actions>
<action-definition>
<component-name>SecureFilterComponent</component-name>
<action-type>Prompt for Product Line and Report Format</
action-type>
<action-inputs>
<outputTypeList type="property-map-list"/>
<outputType type="string"/>
</action-inputs>
<component-definition>
<selections>
<outputType style="radio">
<title>Select Report Format</title>
<filter value-col-name="report-output-type-id"
display-col-name="report-output-desc">outputTypeList</filter>
</outputType>
</selections>
</component-definition>
</action-definition>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>SQL Query For Report Data</action-type>
<action-outputs>
<query-result type="result-set"/>
</action-outputs>
<component-definition>
<jndi>SampleData</jndi>
<live>true</live>
<query><![CDATA[SELECT * FROM TRIAL_BALANCE]]></query>
</component-definition>
</action-definition>
</actions>
</action-sequence>
JFreeReportComponent
This is the deprecated method of generating and manipulating reports programmatically in the BI
Suite version 3.5.0-GA and later, though it is the only way of working with old, non-PRPT, action
sequence-based reports created with Report Designer or Report Design Wizard prior to version 3.5.0.
If you are working with a PRPT report file generated with Report Designer version 3.5.0 or later, use
SimpleReportingComponent on page 29 instead. In order to use the JFreeReportComponent, you need
to have generated an XML report file with Report Designer or Report Design Wizard prior to version 3.5.0.
There is only one "input" for an action sequence involving this component, and it is defined as a resource.
Essentially you're going to point to your simple or extended .xml file. However, there are many other
parameters that go in the inputs section beyond that:
<inputs/>
<outputs/>
<resources>
<report-definition>
<solution-file>
<location>JFreeQuadForRegion.xml</location>
<mime-type>text/xml</mime-type>
</solution-file>
</report-definition>
</resources>
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>SQL Query For Report Data</action-type>
<action-outputs>
<query-result type="result-set"/>
<action-definition>
<component-name>JFreeReportComponent</component-name>
<action-type>Create Report Using Query Results</action-
type>
<action-inputs>
<data type="result-set" mapping="query-result"/>
</action-inputs>
<action-resources>
<report-definition type="resource"/>
</action-resources>
<component-definition>
<output-type>html</output-type>
</component-definition>
</action-definition>
</actions>
</action-sequence>
Charting
There are three components related to charting in the Pentaho BI Platform, each of which uses a different
chart engine:
1. ChartComponent: Uses the JFreeChart engine; this is the default chart engine in the BI Platform.
2. ChartBeansComponent: Uses the Pentaho ChartBeans engine; this is the newest chart engine in the
BI Platform, and will someday replace JFreeChart.
3. OpenFlashChartComponent: Uses the OpenFlashChart engine; this is a small, limited, but visually
impressive chart engine.
Each component has its own reference section below.
JFreeChart (ChartComponent)
JFreeChart is the default charting engine in the BI Platform.
Note: This section is not yet complete.
OpenFlashChart (OpenFlashChartComponent)
OpenFlashChart is for visually appealing, Adobe Flash-based charts.
<inputs>
<chart_width type="string">
<sources>
<request>chart_width</request>
</sources>
<default-value><![CDATA[650]]></default-value>
</chart_width>
<chart_height type="string">
<sources>
<request>chart_height</request>
</sources>
<default-value><![CDATA[400]]></default-value>
</chart_height>
</inputs>
<outputs>
<image-tag type="string"/>
</outputs>
<resources>
<!-- use this section to identify any files that the component needs to
execute the report -->
<bar>
<solution-file>
<location>flash_barchart.xml</location>
<mime-type>text/xml</mime-type>
</solution-file>
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>Chart Data Query</action-type>
<action-outputs>
<query-result type="result-set" mapping="query_result"/>
</action-outputs>
<component-definition>
<jndi><![CDATA[SampleData]]></jndi>
<live><![CDATA[true]]></live>
<query><![CDATA[SELECT PRODUCTS.PRODUCTLINE AS LINE,
SUM(CASE ORDERFACT.YEAR_ID WHEN '2003' THEN (ORDERFACT.TOTALPRICE)
ELSE 0 END) AS "2003",
SUM(CASE ORDERFACT.YEAR_ID WHEN '2004' THEN (ORDERFACT.TOTALPRICE)
ELSE 0 END) AS "2004",
SUM(CASE ORDERFACT.YEAR_ID WHEN '2005' THEN (ORDERFACT.TOTALPRICE)
ELSE 0 END) AS "2005"
FROM
PRODUCTS INNER JOIN ORDERFACT ON PRODUCTS.PRODUCTCODE =
ORDERFACT.PRODUCTCODE
INNER JOIN CUSTOMER_W_TER ON ORDERFACT.CUSTOMERNUMBER =
CUSTOMER_W_TER.CUSTOMERNUMBER GROUP BY
LINE
ORDER BY
2 DESC]]></query>
</component-definition>
</action-definition>
<action-definition>
<component-name>OpenFlashChartComponent</component-name>
<action-type>Open Flash Chart</action-type>
<action-inputs>
<chart-data type="string" mapping="query_result"/>
<width type="string" mapping="chart_width"/>
<height type="string" mapping="chart_height"/>
</action-inputs>
<action-resources>
<chart-attributes type="resource" mapping="bar"/>
</action-resources>
<action-outputs>
<image-tag type="string"/>
</action-outputs>
<component-definition/>
</action-definition>
</actions>
</action-sequence>
Testing the Action Sequence
Follow the instructions below to test this the sample action sequence in your Pentaho deployment
1. Download the attached action sequence simple_chart.xaction and chart xml document
flash_barchart.xml.
2. Place the files in a valid location in your solution repository (for example, ...\biserver-ce
\pentaho-solutions\steel-wheels\charts)
3. Log on to the Pentaho User Console as joe/password.
4. Refresh your repository cache by selecting Tools -> Refresh Repository Cache.
5. Navigate to the location you saved the files and open the Simple Bar Chart Example action sequence.
The bar chart appears in the Pentaho User Console.
ofc_url
Provides the ability to override the default location of the Open Flash Chart .swf file.
Required Inputs
chart-data
Bar Chart
The bar chart plots a set of values as bars for each series in the given dataset.
Dataset Guidelines
This chart expects its data as a categorical dataset.
Required Properties
The only property a bar chart requires is the appropriate chart-type
<chart-type>BarChart</chart-type>
Example
The example below contains the full set of additional supported properties with comments on its purpose
and valid values. It is recommended that new users start with this example as a starting place for building
their first flash chart. The following chart definition will produce the chart shown directly below it.
<chart>
</chart>
Simple Chart
Line Chart
The line chart plots a set of values on a line for each series in the given dataset.
Dataset Guidelines
This chart expects its data as a categorical dataset.
Required Properties
The only property a line chart requires is the appropriate chart-type.
<chart-type>LineChart</chart-type>
</chart>
Flash Line Chart
Dataset Guidelines
This chart expects its data as a categorical dataset.
Required Properties
The following properties are required:
• chart-type
<chart-type>BarLineChart</chart-type>
• bar-series — Add one series element per series that should be plotted as bars.
<bar-series>
<series>actual</series>
<series>budget</series>
</bar-series>
• line-series — Add one series element per series that should be plotted as lines.
<line-series>
<series>variance</series>
</chart>
Bar/Line Combination Chart
Department Actuals
Sales 11,168,773
Executive Management 6,299,022
Finance 12,224,220
Human Resource 13,075,463
Marketing and Communication 13,910,753
Product Development 10,644,102
Professional Services 76,317,649
Required Properties
The only property a pie chart requires is the appropriate chart-type.
Example
The example below contains the full set of additional supported properties with comments on its purpose
and valid values. It is recommended that new users start with this example as a starting place for building
their first flash chart. The following chart definition will produce the chart shown directly below it.
<chart>
</chart>
Pie Chart
</chart>
Flash Area Chart
</chart>
XY Dot Chart
</chart>
Bubble Chart
If you used Design Studio to create an action sequence in a previous version of the Pentaho BI Suite, the
same basic rules and practices apply to later releases. While very little has changed with the core set of
components, there are some new plugins available to you like the PojoComponent, the result set burst
component, and the Flash chart component.
Reports published by Pentaho Report Designer prior to version 3.5 were in fact machine-generated action
sequences. This has changed as of Report Designer 3.5; published reports are now in the PRPT format,
which is an OpenDocument-compliant file archive. Report Designer has been entirely overhauled in an
attempt to eliminate the need to hand-edit reports with Design Studio, but in previous versions, there were
some functions (such as adding user-interactive parameters) that required hand-editing.
If you have already used Design Studio to customize a published report, it is likely that you will continue
to have to follow that process if you want to make changes to the report. Alternatively you could re-create
the report in the new Report Designer and republish it to the BI Platform as a PRPT, or you could open the
old Report Designer .report file with the new Report Designer, use its new and more powerful feature set to
add in the custom changes that you formerly used Design Studio for, and publish it to the BI Platform.
Report Designer 3.6 does not yet have equivalent functionality to the SecureFilterComponent, so if you
need to put strict limits on user parameters, you will have to generate the report by hand with Design
Studio.
If you need to internationalize your action sequence, you can abstract all of your text content to language-
specific message bundles. For each language you want to translate to, create a properties file with the
same name as the action sequence, plus the two-letter ISO language code. Optionally, you can also
append a two-letter ISO country code if you want to discriminate among different dialects. For instance,
using the previously created hello_world.xaction example, you would internationalize it by creating
properties files like these:
• hello_world.properties: The default version of the message bundle
• hello_world_fr.properties: French language version
• hello_world_de.properties: German language version
• hello_world_fr_CA.properties: French Canadian version of the messages file
It does not matter what the original xaction filename is when it comes to specifying the language and
country code. For instance if the original file were called hello_world_fr_CA.xaction, the resulting
properties file hello_world_fr_CA.properties would be the default browser language (usually English), not
French Canadian. To specify a French Canadian message bundle, you would create a second file called
hello_world_fr_CA_fr_CA.properties.
Each string is replaced by a token (indicated by a percent symbol) in the action sequence, and matches up
with content in the properties file. Considering this, the original, unmodified hello_world example created
from the Design Studio template should make more sense now:
<?xml version="1.0" encoding="UTF-8"?>
<action-sequence>
<title>Hello World</title>
<version>1</version>
<logging-level>DEBUG</logging-level>
<documentation>
<author>Joe Pentaho</author>
<description>The most simple Action Sequence</description>
<help>%help</help>
<result-type>rule</result-type>
<icon>HelloWorld.png</icon>
</documentation>
<inputs/>
<outputs/>
<resources/>
<actions>
<action-definition>
<action-name>Hello World Action</action-name>
<action-inputs/>
<action-outputs/>
<logging-level>DEBUG</logging-level>
<component-name>org.pentaho.component.HelloWorldComponent</component-
name>
<component-definition>
<quote>%quote</quote>
</component-definition>
</action-definition>
</actions>
</action-sequence>
The help and quote tags are, by default, abstracted to a properties file. As previously mentioned, Pentaho
no longer ships the BI Suite with properties files for the sample action sequences. So if you want to see
58 | | Internationalization Guidelines
this work, you will have to create a file called hello_world.properties in your solution directory (on the
same level as hello_world.xaction), and copy the following content to it:
help=Hello World demonstrates the most basic action sequence document. It
uses the Hello World component.
quote=Greetings from the Pentaho BI Platform.
Based on the above action sequence and properties file, the output of hello_world.xaction will be:
Hello World. Greetings from the Pentaho BI Platform.
The first part of the message is still pulled in from the global messages.properties file for the BI Platform.
This file can also be changed to internationalize the entirety of the Pentaho User Console and Pentaho
Enterprise Console, but that task is beyond the scope of this guide.
| Internationalization Guidelines | 59
Basic Action Sequence Tips and Tricks
This section contains commonly used or frequently requested action sequence tips and tricks. Only
the basic, common tasks are covered here; the next section contains advanced, highly technical action
sequence notes.
Emailing a Report
To email a report, you must match the output of SimpleReportingComponent (reportOutput in the
example below) to the EmailComponent's input. The action sequence shown below will execute an SQL
query with a user-defined parameter, then use that to generate a report and email it to the specified email
address. The PRPT referenced here is included with the Pentaho sample data, in the /bi-developers/
reporting/unified-file-format/ directory.
<?xml version="1.0" encoding="UTF-8"?>
<action-sequence>
<title>E-mail Inventory Report in Message</title>
<version>1</version>
<logging-level>ERROR</logging-level>
<documentation>
<author>Kurtis Cruzada</author>
<description>Send email with report in the Message</description>
<help/>
<result-type>report</result-type>
</documentation>
<inputs>
<sendto type="string">
<sources>
<request>sendto</request>
</sources>
<default-value><![CDATA[[email protected]]]></default-value>
</sendto>
<productline type="string">
<sources>
<request>productline</request>
</sources>
<default-value>Classic Cars</default-value>
</productline>
</inputs>
<outputs>
<reportOutput type="content">
<destinations>
<contentrepo>reportOutput</contentrepo>
</destinations>
</reportOutput>
</outputs>
<resources>
<report-definition>
<solution-file>
<location>inventory.prpt</location>
<mime-type>application/zip</mime-type>
</solution-file>
</report-definition>
</resources>
<actions>
<action-definition>
<component-name>SecureFilterComponent</component-name>
<action-type>Prompt for Line and Email Address</action-type>
<action-inputs>
<sendto type="string"/>
<productline type="string"/>
<productLineList type="result-set"/>
</action-inputs>
<component-definition>
<selections>
<productline style="list-multi">
<title>Select Product Line</title>
<filter value-col-name="productline" display-col-
name="productline">productLineList</filter>
</productline>
<sendto filter="none" style="text-box">
<title>Email To</title>
</sendto>
</selections>
</component-definition>
</action-definition>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>SQL Query For Report Data</action-type>
<action-inputs>
<productline type="string"/>
</action-inputs>
<action-outputs>
<query-result type="result-set" mapping="queryData"/>
</action-outputs>
<component-definition>
<jndi>SampleData</jndi>
<live>true</live>
<query><![CDATA[SELECT PRODUCTS.PRODUCTLINE, PRODUCTS.PRODUCTVENDOR,
PRODUCTS.PRODUCTCODE, PRODUCTS.PRODUCTNAME, PRODUCTS.PRODUCTSCALE,
PRODUCTS.PRODUCTDESCRIPTION, PRODUCTS.QUANTITYINSTOCK, PRODUCTS.BUYPRICE,
PRODUCTS.MSRP FROM PRODUCTS WHERE PRODUCTS.PRODUCTLINE IN
({PREPARE:productline}) ORDER BY PRODUCTLINE ASC, PRODUCTVENDOR ASC,
PRODUCTCODE ASC]]></query>
</component-definition>
</action-definition>
<action-definition>
<component-name>SimpleReportingComponent</component-name>
<action-type>Pentaho Report</action-type>
<action-inputs>
<queryData type="result-set"/>
</action-inputs>
<action-resources>
<report-definition type="resource"/>
<action-definition>
<component-name>EmailComponent</component-name>
<action-type>E-Mail HTML</action-type>
<action-inputs>
<to type="string" mapping="sendto"/>
<message-html type="string" mapping="reportOutput"/>
</action-inputs>
<component-definition>
<message-plain><![CDATA[Please see the report attached.]]></message-
plain>
<subject><![CDATA[Income Statement HTML]]></subject>
</component-definition>
</action-definition>
</actions>
</action-sequence>
The tips and tricks in this section apply to rare or specific cases; they highlight unusual and interesting
ways to use action sequences to automate complex tasks.
<step>
<name>Process Parameters</name>
<type>ScriptValueMod</type>
<description/>
<distribute>Y</distribute>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<compatible>Y</compatible>
<jsScripts> <jsScript> <jsScript_type>0</jsScript_type>
<jsScript_name>Script 1</jsScript_name>
<jsScript_script>
// get the start and end date strings from the previous step
// these are formatted like 'Dec 31, 2008'
var startDateStr = start_date_str.getString();
var endDateStr = end_date_str.getString();
// convert the start and end date strings into Date objects
var startDate = str2date( startDateStr,"MMM d,
yyyy","EN");
var endDate = str2date( endDateStr,"MMM d, yyyy","EN");
// convert the start and end date objects into strings formatted like
'2008-12-31'
startDateStr = date2str(startDate,"yyyy-MM-dd");
endDateStr = date2str(endDate,"yyyy-MM-dd");
setVariable("START_DATE",startDateStr,"r");
setVariable("END_DATE",endDateStr,"r");
setVariable("YEAR",yearStr,"r");
<step_error_handling>
</step_error_handling>
<slave-step-copy-partition-distribution>
</slave-step-copy-partition-distribution>
<slave_transformation>N</slave_transformation>
</transformation>
Modifying your action sequence
In the action sequence, you must map the action-inputs to numbered parameters that match what the
command line arguments would be, as shown in the snippet below:
<action-inputs>
<start_date/>
<end_date/>
</action-inputs>
<component-definition>
<parameter1>start_date</parameter1>
<parameter2>end_date</parameter2>
</component-definition>
<!-- MAKE SURE THIS IS SET TO FALSE OR YOU WILL RECIEVE A NULLPOINTEREXCEPTION
-->
<live><![CDATA[false]]></live>
</component-definition>
</action-definition>
<action-definition>
<component-name>SecureFilterComponent</component-name>
<action-type>Prompt/Secure Filter</action-type>
<action-inputs>
<PaymentMethodList type="result-set"/>
</action-inputs>
<component-definition>
<selections>
<CarSales style="list-multi">
<title>Select payment method for car sales:</title>
<filter value-col-name="paymentMethod_id" display-col-
name="method">paymentMethodList</filter>
</CarSales>
<BikeSales style="list-multi">
<title>Select payment method for bike sales:</title>
<filter value-col-name="paymentMethod_id" display-col-
name="method">paymentMethodList</filter>
</BikeSales>
</selections>
</component-definition>
</action-definition>
Essentially, if you are using a live result set (live = true), then once you use the result-set, and iterate
through it, the result-set has been used, and it is no longer available. Hence, the NPE. If you use an in-
memory result-set (live = false), the result-set is stored in memory for later use.
This section contains lengthy tutorials that were originally designed as standalone documents.
1. Start the Design Studio and click (Close) to exit the Welcome Page.
2. In the menu bar, click New -> Project.
3. In the New Project wizard, select General -> Project and click Next.
5. Click Browse to located your pentaho-solutions directory as shown in the sample image above.
6. Click Finish.
</chart>
Defining Processes
Follow the instructions below to define the process actions in Design Studio:
4. Under Process Action, click (Add New Action) to add a relational query component. Click Get Data
From -> Relational.
<inputs/>
<outputs>
<image-tag type="content">
<destinations>
<response>content</response>
</destinations>
</image-tag>
</outputs>
<resources>
<chart_definition>
<solution-file>
<location>sales_barchart.xml</location>
<mime-type/>
</solution-file>
</chart_definition>
</resources>
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>Relational</action-type>
<action-outputs>
<query-result type="result-set" mapping="query_result"/>
</action-outputs>
<component-definition>
<jndi><![CDATA[SampleData]]></jndi>
<query><![CDATA[SELECT
PRODUCTS.PRODUCTLINE AS LINE,
SUM(CASE ORDERFACT.YEAR_ID WHEN '2003' THEN (ORDERFACT.TOTALPRICE) ELSE 0
END) AS "2003",
SUM(CASE ORDERFACT.YEAR_ID WHEN '2004' THEN (ORDERFACT.TOTALPRICE) ELSE 0
END) AS "2004",
SUM(CASE ORDERFACT.YEAR_ID WHEN '2005' THEN (ORDERFACT.TOTALPRICE) ELSE 0
END) AS "2005"
FROM
PRODUCTS INNER JOIN ORDERFACT ON PRODUCTS.PRODUCTCODE =
ORDERFACT.PRODUCTCODE
INNER JOIN CUSTOMER_W_TER ON ORDERFACT.CUSTOMERNUMBER =
CUSTOMER_W_TER.CUSTOMERNUMBER
GROUP BY
LINE
ORDER BY
2 DESC]]></query>
<live><![CDATA[true]]></live>
</component-definition>
</action-definition>
</actions>
</action-sequence>
The query component in the diagram can be any component that generates an IPentahoResultSet object:
for example SQL component, MDX component, or MQL component. The result set can also be passed to
the action sequence or generated using a custom component.
This pattern can be used for many bursting-style processes:
• Perform any parameter checking or chaining
Prerequisites
The burst component needs the action sequence loop to use the peek-only attribute. If peek-only is not
used, each output result set will be missing its first row.
Multiple queries and multiple burst components (one per query) can be used in an action sequence as long
as it is guaranteed that the results of each query can be divided into the same number, and same order,
of related subsets. That is to say that the data from each query must include the same odometer columns,
that the count of distinct values in those columns is the same, and that the rows are ordered appropriately
in each case.
When the burst component creates one of the result subsets, it stores the data in memory. Since the burst
component works inside of a loop, only one subset is stored in memory at a time.
If the burst component is used with the JMS component, the output result sets can be sent to a message
queue and a pool of listeners can handle the content generation steps.
To get the best performance from the burst component, the input result set should be a 'live' one where
possible. This means that the source of the input result provides a cursor into the data set, and it is not
read into memory.
The burst component reads through the data from top to bottom as it creates the subsets. Each subset is
stored in memory and the other components in the loop do any iterating or random access into this data.
For this reason you will get better performance using a forward-only option on the input result set if it is
supported by the provider.
The burst component definitions cannot be created using Design Studio yet. In order to use the burst
component, you must use an XML editor.
Below is an example of an action sequence XML that uses the burst component.
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-outputs>
<query-results type="mdx-query"
mapping="inputdata"/>
</action-outputs>
<component-definition>
<query><![CDATA[select...]]></query>
</component-definition>
</action-definition>
<!-- loop on 'inputdata' and only peek at the data in the
result set, don't pull it out -->
<actions loop-on="details_all" peek-only="true">
<!-- use the burst component to break out the next subset
of data from the 'inputdata' result set -->
<action-definition>
<component-
name>com.pentaho.platform.plugin.action.burst.ResultSetBurstComponent</
component-name>
<action-inputs>
<!-- pass in the 'inputdata' result set
-->
<InputResultSet mapping="inputdata"/>
</action-inputs>
<action-outputs>
<!-- pull out result sets into
'burstdata' -->
<OutputResultSet type="list"
mapping="burstdata"/>
<Country type="string"/>
<Product type="string"/>
</action-outputs>
<component-definition>
<!-- specify that we want to break the
input result set based on the Country and Product columns -->
<ColumnNames>Country;Product</
ColumnNames>
</component-definition>
<action-name>Burst Component</action-name>
<logging-level>DEBUG</logging-level>
</action-definition>
Troubleshooting
The burst component will not work if:
• A Community Edition server is used instead of an Enterprise Edition
• The input result set is not provided
• The input result set is not peekable (IPeekable)
• The odometer column(s) are not defined
• One or more of the odometer columns do not exist in the input result set
If the peek-only attribute has not been set on the action sequence loop, the output of the components that
are consuming the burst result sets will be missing the first row of data.