Time for action – configuration of libraries and the PRD report

We are going to copy PRD libraries into our project. We will then create a new folder within our project and copy a PRD report inside it. Finally, we will modify the connection type of this report so that it utilizes JNDI.

  1. We will copy the libraries that compose PRD's Application Programming Interface (API) into our project.
  2. Head to the lib folder in PRD_HOME], select every file in there, and copy it with Ctrl + C; then in Eclipse, select the node named prd5ch14 by going to WebContent | WEB-INF | lib and paste the copied files in there by pressing Ctrl + V.

    Note

    Many of the libraries we just copied are not really necessary for the execution of this chapter's PRD report, but we decided not to add complexity to this stage by choosing them one by one; that is why we are instructing you to copy all of them indiscriminately.

  3. From the bulk of libraries we just copied into our project, select the one named jsp-api-2.0.jar and delete it.
  4. We need to include into our project the report necessary to perform this chapter's practice example. To do so, we will select the node named WEB-INF, right-click on it, and choose New | Folder. We will call this new folder report.
  5. We will now head to the physical location on which we have saved all our PRD reports, select the report named 11_Adding_Charts.prpt, and copy it (Ctrl + C). In Eclipse, we will select the node named report by going to WEB-INF and paste the copied report in there (Ctrl + V):
    Time for action – configuration of libraries and the PRD report
  6. The report requires a modification before we can make use of it. We need to change the connection type of its data set, that is, the data set is currently of the type Native (JDBC) and we need it to be of the type JNDI so that we can use the connection pool we previously defined. To do so, we will execute PRD and open the report we just copied in the previous step; it should be located in [WORKSPACE_HOME]/prd5Ch14/WebContent/WEB-INF/report/11_Adding_Charts.prpt.
  7. At this stage, we need to take the Ratings data set and change its connection type to JNDI. We can do it as follows:
    1. Once the report is opened in PRD, we will head to the Data tab, right-click on the Ratings parent node that is on JDBC: sakila db, and select the option Edit Datasource... as shown in the following screenshot:
      Time for action – configuration of libraries and the PRD report
    2. On the Connections panel, we will click on the Time for action – configuration of libraries and the PRD report button and configure the new connection as follows:
    • Connection Name: = sakila jndi
    • Access: = JNDI
    • JNDI Name: = sakila

    The dialog will look like the following screenshot:

    Time for action – configuration of libraries and the PRD report

    In JNDI Name we will set the value sakila, but you may have noticed that in the file context.xml we used the value name jdbc/sakila. This is because the API will take care of completing the name for us by following the standard.

    We will click on OK to save the new connection.

    1. We will now assign this new connection to the ratings query. We will head to the Connections panel and select the item named sakila jndi, then we will select the Ratings item within the Available Queries panel and click on OK.
  8. At this stage, we should repeat steps 1 and 3 of step 5 for the ListYears and ListMonths data sets.
  9. Once the Ratings, ListYears, and ListMonths data sets are correctly configured, we can save the report.

    Note

    If we want to use this report from the publisher through JNDI, we need to edit the file default.properties present in the location [User_home]/.pentaho/single-jndi and add the following configuration at the end:

    sakila/type=javax.sql.DataSource

    sakila/driver=com.mysql.jdbc.Drivers

    sakila/user=root

    sakila/password=root

    sakila/url=jdbc:mysql://localhost:3306/sakila

    For more information visit http://infocenter.pentaho.com/help/index.jsp?topic=%2Freport_designer_user_guide%2Ftask_jndi_data_source.html.

What just happened?

We copied the PRD libraries placed in [PRD_HOME]/lib and pasted them into our project within the lib node located in WEB-INF. We also created a folder within the WEB-INF node, called it report, and pasted inside it the report named 11_Adding_Charts.prpt. By means of PRD, we opened the previously mentioned report and edited its data sets so that they are of the type JNDI.

Code components

Now we will create the code components that make up our application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset