Skip to main content

Pentaho+ documentation has moved!

The new product documentation portal is here. Check it out now at docs.hitachivantara.com

 

Hitachi Vantara Lumada and Pentaho Documentation

Embed Pentaho Server functionality into web applications

The following samples use various development techniques to demonstrate how to embed Pentaho Server functionality and content into another web application.

Parent article

These samples are for developers with HTML and JavaScript experience. We assume also you have a correctly installed and configured the Pentaho Server running locally on your machine along with knowing how to start and stop the server if necessary.

Get started with the embedded samples

To download and deploy the samples to your Pentaho Server, perform the following steps:

Procedure

  1. On the Customer Portal home page, sign in using the Pentaho support user name and password provided in your Pentaho Welcome Packet.

  2. Click Downloads, then navigate to the Pentaho GA Release page, which matches your version of the software.

  3. On the bottom of the Pentaho GA Release page, in the Box widget, click the SDK folder and download the pentaho-sdk- 9.3.0.zip file.

    The readme file contains the information for deployment.

  4. Stop the Pentaho Server.

  5. Run SDK Installer.bat (or the corresponding script for your OS) to uncompress these two folders to your selected location: integration-examples and platform-plugins.

  6. Copy the integration-examples directory to your pentaho-server/tomcat/webapps directory.

  7. Open the platform-plugins directory and copy these two folders: example-visualization and oem-tools.

  8. Paste them into the pentaho-server/pentaho-solutions/system directory.

  9. Restart the Pentaho Server.

Results

The samples are deployed and can be accessed by opening a web browser and navigating to http://localhost:8080/integration-examples. If you want to access the OEM tools, browse to http://localhost:8080/pentaho/conten...web/index.html. If you want to access the example-visualization, look under the Charts menu in Analyzer. It will be listed as Example KPI.

Next steps

To deliver content as well as expose various services, we use a REST web interface. These sections comment on the various samples and how they use the REST URLs. For the full reference of the Pentaho REST API, please refer to http://javadoc.pentaho.com.
NoteThe REST APIs often allow interaction with repository files. The REST API expects references to repository files to be specified using the : character as file separator.

Report Designer samples

The following samples show how to render Report Designer reports in various web applications.

Execute a report from a HTML form (POSTing parameters)

This sample renders a Report Designer (PRPT) report by posting the report parameters to the report REST URL:

http://localhost:8080/pentaho/api/repos/<path>/generatedContent

The POST request contains all parameters the report expects, plus the additional rendering parameter output-target, which controls the rendering format (HTML, PDF, XLS, etc.)

The following output formats are supported:

OptionPurpose
table/html;page-mode=streamHTML as a single page, all report pagebreaks are ignored.
table/html;page-mode=pageHTML as a sequence of physical pages, manual and automatic pagebreaks are active.
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;page-mode=flowExcel 2007 XLSX Workbook
table/excel;page-mode=flowExcel 97 Workbook
table/csv;page-mode=streamCSV output
table/rtf;page-mode=flowRich text format
pageable/pdfPDF output
pageable/textPlain text
pageable/xmlPageable layouted XML
table/xmlTable-XML output
pageable/X-AWT-Graphics;image-type=pngA single report page as PNG.
mime-message/text/htmlMIME email with HTML as body text and all style and images as inline attachments.

Render a report in an IFRAME

This sample renders a PRPT report using a regular GET request, by populating an HTML IFRAME with the report REST URL:

http://localhost:8080/pentaho/api/repos/<path>/generatedContent?<parameters>

The request contains all parameters as part of the URL.

Render report viewer with available parameters and executed report

The sample renders the Pentaho Report Viewer IU by populating an HTML IFRAME with the report REST URL:

http://localhost:8080/pentaho/api/repos/<path>/viewer?<parameters>

The request contains the initial report parameters as part of the URL.

Publish a file to the Pentaho Server

Follow this process if you want to publish a file to the Pentaho Server:

Click the link that publishes a file to the Pentaho Server: http://localhost:8080/api/repo/publish/publishfile. This publishes the file to the provided path in the repository. Note that the file will be overwritten if the overwrite flag is set to true.

Parameters
NameDescriptionTypeDefault
pathId(colon separated path for the repository file)formdatafalse
fileContents(input stream containing the data)formdatafalse
overwriteFile(flag to determine whether to overwrite the existing file in the repository or not)formdatafalse
fileInfo(information about the file being imported)formdatafalse

Sample code for reference purposes can be found at Github for Pentaho. Look for the file called PublishRestUtil.java under the pentaho-reporting repostitory.

The file is now published to the Pentaho Server and is available to users.

Analyzer samples

The following samples show how to embed Analyzer reports into other web applications.

Display a report in viewer mode

This sample renders a display using a regular GET request, by populating an HTML IFRAME with the report REST URL:

http://localhost:8080/pentaho/api/repos/<path>/viewer

The viewer has limited possibilities for interaction and does not allow changing the report.

Display a report in editor mode

The sample renders a full Analyzer IU by populating an HTML IFRAME with the report REST URL:

http://localhost:8080/pentaho/api/repos/<path>/editor

The IFRAME now renders the full Analyzer user interface, allowing users to interact with the data.

Create a new Analyzer report

The sample prepares a new Analyzer report by populating an HTML IFRAME with the report REST URL:

http://localhost:8080/pentaho/api/repos/xanalyzer/editor?catalog=<Schema>&cube=<CubeName>

The mandatory catalog and cube parameters specify the analysis schema and cube to use for the new report.

Integrate into a custom web application via an IFRAME

The sample opens a new page that mimics a parent application that integrates Analyzer using an IFrame. The parent application has a set of buttons interacting with the Analyzer UI in the embedded IFRAME. Studying this page is a good starting point, if you are trying to deeply integrate analyzer into your own web application.

Specify the select schema service

The sample is opened with a specified data service.

http://localhost:8080/pentaho/api/repos/xanalyzer/service/selectSchema

After a data service is selected, the sample opens and shows an unsaved Analyzer report using that data service.

Interactive Reports samples

The following samples show how to embed Interactive Reports into other web applications.

Display Interactive Reports

This sample renders a PRPTI report using a regular GET request, by populating an HTML IFRAME with the report REST URL. The viewer has limited possibilities for interaction and cannot edit the report. The example below shows how to do this by replacing the path within the <> with the URL for the report that you want to view.

http://localhost:8080/pentaho/api/repos/<%3Ayour%3Apath%3Agoes%3Ahere.prpti>/prpti.view

You can use the prpti.edit end-point instead, to allow more user interaction with the report.

http://localhost:8080/pentaho/api/repos/<%3Ayour%3Apath%3Agoes%3Ahere.prpti>/prpti.edit

Create new Interactive Reports

The sample prepares a new report by populating an HTML IFRAME with the report REST URL.

http://localhost:8080/pentaho/api/repos/pentaho-interactive-reporting/prpti.new

In order to show the toolbar buttons so that users can create, open, or save Interactive reports, add the following to the end of the URL.

?showRepositoryButtons=true

Users will be prompted to select the data source they want to work with.

Integrate into a custom web application via an IFRAME

The sample opens a new page that mimics a parent application that integrates the Interactive Reports editor using an IFrame. The parent application has a set of buttons interacting with the Interactive Reporting UI in the embedded IFRAME. Studying this page is a good starting point, if you are trying to deeply integrate Interactive Reports into your own web application.

Action sequence samples

The following samples show how to embed an action sequence into other web applications.

Run an action sequence to generate a report

This sample renders an XACTION report using a regular GET request, by populating an HTML IFRAME with the report REST URL:

http://localhost:8080/pentaho/api/repos/<path>/generatedContent?<parameters>

The parameters for the xaction are passed as simple GET parameters on the URL.

Run an action sequence to generate a report with prompts

The sample prepares a form to collect parameters and POSTs them to the xaction REST URL:

http://localhost:8080/pentaho/api/repos/<path>/generatedContent

The XACTION now retrieves its parameters from the POST request body.

Configure the proxy trusting filter

If you have set the Pentaho Server to run on a specific IP address or hostname other than the default 127.0.0.1, you must modify the trusted proxy to match that address or hostname for Pentaho plugins to run as expected. Additionally, if you have applications that access Pentaho Server resources, such as REST APIs, you must add that application's IP address so that the Pentaho Server will accept those requests.

Procedure

  1. Stop the Pentaho Server.

  2. Open pentaho-server/tomcat/webapps/pentaho/WEB-INF/web.xml and search for TrustedIpAddrs.

    NoteThe param-value immediately below TrustedIpAddrs is a comma-separated list of IP addresses that should be trusted.
  3. Add the IP address of the host machine.

    <filter>
        <filter-name>Proxy Trusting Filter</filter-name>
        <filter-class>org.pentaho.platform.web.http.filters.ProxyTrustingFilter</filter-class>
            <init-param>
                <param-name>TrustedIpAddrs</param-name>
                <param-value>127.0.0.1</param-value>
                <description>Comma separated list of IP addresses of a trusted hosts.</description>
            </init-param>
    </filter>
  4. Start the Pentaho Server.

Developer support

The examples in this section are simple and easy to follow, but with more complex requirements come more advanced programs. While reading the source code comments can help quite a bit, you may still need help to develop an application within a reasonable time-frame. Should you need personal assistance, you can have direct access to the most knowledgeable support resources through a Pentaho Enterprise Edition software vendor annual subscription:

ISV/OEM support options

If phone and email support are not enough, Pentaho can also arrange for an on-site consulting engagement:

Consultative support options

License information

Most of the software comprising Pentaho Business Analytics is open source, licensed under the GNU General Public License version 2. Business Analytics also contains a large volume of third-party open source libraries that are registered under a number of different licenses. Most of this software is freely redistributable, with the notable exceptions of the following Pentaho-authored programs:

  • Dashboard Designer
  • Analyzer
  • Interactive Reports
  • Various individual BI Platform JARs

If you already have regular Pentaho licenses for the BI Platform, Dashboard Designer, Interactive Reports, and Analyzer, then no further licenses are required to integrate Pentaho Business Analytics functionality into a third-party application. If you wish to embed pieces of the Pentaho Server into an application that you intend to sell or distribute, you must familiarize yourself with the licenses of all of the pieces you are including in order to make sure you are complying properly. Proprietary Pentaho software may not be redistributed under any circumstances.

This section is not intended for redistribution. However, the example code and example application that accompany this document may be freely modified or reused.