Beruflich Dokumente
Kultur Dokumente
0
Technical Training
Lab Workbook
Scenario
In this course, reports display information stored in a database. The query needs a data source against
which it executes. Define a JDBC Connection in iReport, then develop reports that use queries.
Note: These labs require JasperReports Server Professional 5.0, and the sample data and reports.
Time
5 minutes
Instructions
#
1.
2.
b. Click the New button at the top right of the Connections / Datasources window
c. In the Datasource window, select Database JDBC connection
d. Click Next
3.
a. Name: foodmart (foodmart is the name of the sample database used during this class)
b. JDBC Driver: PostgreSQL (org.postgresql.Driver)
c. JDBC URL: jdbc:postgresql://localhost:5432/foodmart
o Make sure the URL ends with the name foodmart
d. Username: jasperdb
e. Password: password
f. Check the Save password check box
Note: Replace localhost with the database URL if the database
is not hosted locally
4.
5.
a. Click Save
Question 1.1
Note: The database name appears in the Connections / Datasources window
Where can you access this new
connection?
b. Click the Close button
End
Create a report that serves as the foundation for labs that follow. Explore elements that make up a
dataset.
Scenario
Define a query, register database fields, and begin designing the report. Create a new report template
that is fleshed out out in succeeding labs. Explore parameters and variables, then delete items from the
dataset to see its effect on the report design.
Notes:
Time
$F{} represents fields, which map to the columns in the data source.
$P{} represents parameters. Users often pass in values for parameters via input control(s) when
they run the report.
10 minutes
Instructions
#
1.
Steps
a. On the desktop, create a folder named labWork (unless its already there).
o During this class, save all iReport lab files in this folder
2.
a. From the main menu, select File > New to open the New file selector
b. Confirm that Report is selected at the left and Blank A4 in the center
o Scroll and view some of the other options available
c. Click the Open this Template button at the bottom of the panel
d. Name the report department_report and save it in the labWork folder
Best Practice: For best performance, save reports locally.
e. Click Next and Finish
3.
o Scroll down the list of tables and double-click the department table name, or
drag and drop the table name into the empty pane at the right
Note two things:
1. All field names in a table are selected by default
2. The query is automatically built in the top-left pane
a. Near the bottom of the Report query window, notice the two registered field
namesthese represent the two field names that were checked in the table
Question 2.1
How is the type of a field
determined?
b. Using keyboard and cursor, up in the main query pane change the
department_department_id alias name in the Select clause to department_id
IMPORTANT: do not change the department_department_description alias.
5.
#
1.
c. Notice near the page bottom how the registered field name updates to
department_id
d. Click OK to close the Report query window
a. Find the Report Inspector panel (usually located on either side of iReport)
If you dont see it, select Window > Report Inspector from the main menu
b. In the Report Inspector, click to expand the Fields list
c. The alias name for both fields is present here
#
1.
2.
Task 3: Add some report elements to the report and preview it.
Action
Steps
Add elements to the report
a. From the Report Inspector drag the following elements into the report:
o Drag the title parameter to the top center of the Title band
o From Fields drag the department_department_description to the Detail 1
band (usually called the Detail band)
o Notice the column header text box added automatically above.
Double-click it and change the column header to Dept Name
o From Variables drag the department_count variable into
the Summary band
Result: A text field is created each time a field, parameter,
or variable is moved into the report
Test the report
d. Use the left and right triangle arrows at the top center of the preview window
to navigate through all three report pages. The total number of
departments is printed in the summary band at the bottom of the final page
o The report displays gaps between records. That is fixed soon.
#
1.
3.
Scenario
View the mock-up PDF file to see how the finished report might look. Consider page numbers, headers,
and the title, because their location in the mock-up indicates which bands to use.
Time
10 minutes
Instructions
#
1.
2.
Open
department_report.jrxml and
hide unnecessary bands
a. In the Report Inspector, right-click on the Page Header band name and select
Delete Band
b. Likewise delete the Column Footer and Summary bands
Note: When you need a missing band, right-click its name in the Report Inspector and
select Add Band.
3.
4.
10
5.
6.
a. Its not part of the lab, but to add a watermark to reports (viewable only in PDF):
o In the Report Inspector select the Background band and set its height to
802 (report height of 842 less top and bottom margins of 20 each)
o The content of all other bands overlays what is placed in the
Background band when the report fills
b. To display a message when the query returns no records from the database
o Add the No Data bandright-click on it and select Add Band
o In the Properties panel set its height to 50 pixels
o From the Palette drag a Static Text field to the No Data band, double-click
on it, and insert the message The report returned no records.
Note: Double quotation marks are not needed in a Static Text field
End
o At the top of the Report Inspector, select the name of the report
o Scroll to near the bottom of the Properties panel and set
When No Data = No Data Section
11
Scenario
Reports contain text. Text comes from the database, is defined statically, or is perhaps added
dynamically when the report runs. In this lab you manipulate text in a report and employ frames for
managing borders and background colors.
Time
15 minutes
At the end of this lab, the top of the department_report resembles this screen shot:
12
Instructions
#
1.
2.
In the Palette, scroll down if necessary and click n drag a Text Field into the
reports Title band. You want Text Field, not Static Text
3.
a. Select Window > Formatting Tools from the main menu bar to make the
Formatting Tools panel visible
b. Select the new text field in the Title band to highlight it
c. Scroll down the Formatting Tools panel and select
Adapt to parent width (not Adapt to parent)
o This option is available only after you select an element in the Designer view
Question 4.1
How are Static Text and Text
Field different?
Note: Do not select Adapt to parent, as this causes the Text Field to assume
the bands width and heightnot the correct choice this time.
The Formatting Tools panel offers many handy tools for sizing and aligning
elements. Scroll through and become familiar with it.
You can also click and drag the border of a Text Field to resize the field
4.
13
a. Scroll down farther in the Properties panel. Increase the titles font Size to 20.
Note: Do not edit the title any further; it is styled in a later lab. If you style or
color the title now, the styles lab will fail.
b. Scroll up to the top of the Properties panel and increase the text fields
Height to 26. This makes the title text visible again in the Title band
c. Scroll down the Properties panel again and center the text horizontally by
setting the Horizontal Alignment property to Center
o Alternatively, click the center text icon in the Designer Tool Bar, but on
smaller monitors these text-edit icons are often hidden from view
Note: In any band, blank space below the lowest element is displayed as blank
space in the report. To remove extra space, place the cursor on the bottom
border of the band (so you see up-and-down arrows) and double-click. This zips
the band up to the bottom of the lowest element.
6.
Add a frame
a. From the Report Elements section of the Palette, click and drag a Frame
element into the Column Header band
14
Note: A frame is a container for b. Select the frame, either by clicking its rectangle in the Design window or
elements when they need a
clicking it in the Report Inspector, under Column Header)
common background or border.
The first two numbers represent the horizontal and
vertical orientation of the frame relative to the upper-left
corner of the band when you first released the frame, and
the next two represent the frames length and height.
c. In the Formatting Tools panel, scroll down and click Adapt to parent.
This stretches the frame to match its bands length and height
d. With the frame still selected, in the Properties panel give it a Backcolor of
gray. Open the editor () to use the color picker
e. Check the Opaque check box to make the background color visible when the
report runs
7.
15
8.
9.
16
Scenario
Many reports display a logo or picture. This lab adds an image to the department_report.
Time
5 minutes
At the end of this lab, the top of the department_report resembles this screen shot:
17
Instructions
#
1.
Steps
a. Make sure the application server (Tomcat) is running
b. Point a browser to http://localhost:8080/
c. Right-click on the Tomcat logo at the top left of the page and Copy Image
Location of the image: http://localhost:8080/tomcat.gif
2.
a. Resize the title text box to make room at the left for the tomcat logo
Refer to the DepartmentReport_Mockup.pdf file if necessary
3.
a. From the Palette panel, drag and drop an Image element into the report in the
area to the left of the title (where you just made some space)
b. When the File Browser window appears, click its Cancel button
c. An image field appears in the Title band
Note: To use an image that resides on the file system, browse in that dialog to
find it.
d. Size the image field to properly fit in the band
4.
18
5.
6.
7.
a. Return to Image Expression and edit the image expression to an invalid URL
b. Preview the report again and note what image appears
Result: The report displays a generic image icon instead of an error message
c. Return the image expression to its original and accurate value
End
19
Embed one report in another so that the content is combined into a single output.
Scenario
The report currently displays department name and ID number. Configure a subreport that displays
employee information, and include the subreport in the department_report. Include an input control that
lets users specify the department for which they want to view information.
Time
30 minutes
At the end of this lab, the top of the department_report resembles this screen shot:
20
Instructions
#
1.
2.
Configure bands
3.
a. Click the Report query button to open the Report query window (even if the
icon appears to be grayed out)
b. Click the Query designer button
c. Click the left-most drop-down and select the public schema
d. Scroll and double-click the employee table to load it into the designer
e. Click the tables name, and from the menu click deselect all
f. Select these four fields from employee:
o full_name
hire_date
salary
gender
a.
b.
c.
d.
Steps
From the main menu select File > New
Select Report and Blank A4
Save the file as employee_report in the labWork folder
Click Next and then Finish
21
Note: When the four field names appear in the lower pane, there are no errors
i.
4.
Add a frame
5.
a. From the Report Inspector, drag the four fields into the Detail 1 band
Refer to the report mock-up PDF for layout direction
o Notice that iReport automatically adds column headers to the band above
b. Edit each column header to reflect a user-friendly column name
o Do not style or format the column headers
If you format them now, then Lab 10c will fail
c. Preview the report to ensure it runs and there are no errors
6.
22
7.
Spend a moment previewing the report and improving the layout and length of the
line (refer to the mock up PDF file if necessary)
8.
a. Click to select the text field that writes the hire date
b. In the Properties panel find Pattern and click the edit button ()
c. In the Pattern property, select Date and the pattern yyyy/MM/dd
o It might reflect todays date
d. Do the same for the text field that writes out the salaries, but specify the
Currency pattern with zero decimal places
9.
Add a parameter
This parameter lets report
users specify the department
ID of the department for which
they want to see information
23
c. Click the OK button to save the query and close the window
11. Preview the report
#
1.
2.
From the Palette, drag a Subreport element into the Detail 1 band below the two
text fields already there
Result: The Subreport wizard opens
3.
a. In the first window, click Use an existing report and browse to the location of
the employee report (select the .jrxml file, not .jasper)
b. Click Open, then Next
c. In the Connection exp window: leave Use the same connection used to fill
the master report selected, and click Next
d. In the Parameters window, click in the empty Expression drop-down field,
scroll down to select department_id, then click Next
e. In the Subreport exp window, select Use a static absolute path reference
f. Click Finish
24
4.
a. Reduce the subreport elements size so that it fits into the band and is wide
enough to the right
o Make sure the subreport element is below the two text fields
b. When the subreport element contains employee info, it dynamically expands in
height, so set its Height to a very small value (1 pixel)
c. In the Report Inspector, the Subreport element is under the
Detail 1 band and represented this way,
though your path is likely different from this one
5.
6.
7.
25
Scenario
You need a report that displays both personal and company information about employees
Time
20 minutes
Instructions
#
1.
Task 1: Create a new report and configure a dataset the Table element uses.
Action
Steps
Create a new report named
a. Close the department and employee reports
Company_Information.jrxml
b. Create a new report named Company_Information.jrxml
o From the main menu , select File > New to open the New file selector
o Confirm that Report is selected on the left and Blank A4 in the center
o Click the Open this Template button at the bottom of the panel
o Name the report Company_Information
o Save the report in the labWork folder or with the other reports
o Click Next and Finish
26
2.
a.
b.
c.
d.
e.
f.
g.
h. Near the top of the table that appears at the right, click the table name button
and, from the menu, select deselect all to deselect the field names
i. Select six field names: first_name, last_name, position_title, hire_date,
salary and education_level
j. Click OK and Next to save changes and exit the query designer
k. In the Fields window, click the double-arrow button to move all six field names
into the selection pane, then click Next
l. Grouping is not required, so click the Finish button to exit the dataset wizard
Note: The new dataset appears in the Report Inspector
27
3.
Note: The order of field names in the dataset represents the order in which the
fields appear in the report after the Table element is configured. This order
places the three personal information fields together and the three company
information fields together.
c. Click to collapse the Table Dataset
28
#
1.
Note: While the Table element uses the query provided by its assigned dataset,
the main report also needs a query defined, even if it returns no values
c. At the lower right, click the OK button to save the query and exit the designer
2.
a. In the Report Inspector, delete all bands but Title and Summary
o Right-click on each band name and select Delete Band
3.
a. If the Palette is not visible, select Window > Palette from the main menu
b. Drag a Table element from the Palette into the Summary band to open the
Table wizard
c. In the first step of the Table wizard, make sure the new dataset is selected in
29
i.
Click the Finish button to save the table configuration and exit the wizard
30
4.
a. Double-click the six column headers and edit them to match the following:
o First
Last
Education
Title
Hired Salary
5.
b. Expand Table Header and control-click to select the first three Column names
31
d. Expand the new Columns 1-3 list and control-click to select the column names
e. Right-click on Column 1 and select Delete cell from the context menu
f. Right-click the Column 1 (Empty Group Header) and select Add cell
Note: A single empty header now spans the first three columns.
32
6.
a. Repeat step 5 to add a group column header over the remaining three columns
o Control-click to select Column 4, Column 5 and Column 6
o Right-click on Column 4 and select Group selected columns
o Click to expand Columns 4-6
o Control-click to select Column 4, Column 5 and Column 6
o Right-click on Column 4 and select Delete cell
o Right-click on Column 4 (Empty Group Header) and select Add cell
Note: One empty group header is now positioned above the three personal
information columns, and another is positioned above the three company info
columns.
7.
a.
b.
c.
d.
Drag a Static Text element from the Palette into the first group column header
Double-click to select the default text and enter the label Personal
Drag a Static Text element into the second group column header
Change the default text to the label Company
8.
33
9.
a. Use the Pattern property to format the hire date and salary text fields
o Click to select the hire date text field, beneath the Hired column label
o Select Date at the left, and any type at the right (short is better than long)
o Click the OK button to assign that date format; it displays when you preview
the report later
o Repeat for the salary text field, but select Currency and specify zero
decimal places
10. Add a title to the Title band
a. Near the lower left of the Designer pane, click the Main report tab to view the
report bands
b. Drag a Static Text element into the Title band
34
c. Double-click the text in it and enter the title Current Company Information
d. Stretch the text field so the title displays, and format the title to your liking
o Consider centering, color, font size 20, etc
11. Position the Table element in
the Summary band
35
To add a simple bar chart to a report and configure its look and feel
Scenario
Create a bar chart that displays the number of people of each gender in each department.
In doing so you gain experience configuring variables and using the ternary operator
Time
15 minutes
At the end of this lab, the department_report displays a chart for each department, like this:
36
Instructions
#
1.
2.
Task 1: Define two variables to count males and females, and then create the bar chart that uses those variables.
Action
Steps
Open employee_report.jrxml
Open employee_report.jrxml (not department_report.jrxml)
Define two variables: one to
count males and one to count
females in each department
i.
Click the OK button to save the expression and close the editor
37
3.
a. From the Palette drag a Chart element (not Charts Pro or HTML5 Charts) to the
Summary band
b. Select the Bar 3D chart and click OK
c. In the Category Chart Wizard window, click Cancel
4.
a. Select the Chart element, then right-click it and select Chart Data
b. In the Chart details window, click the Details tab
o Click Add:
Series expression: M (Yes, the double quotation marks are important.)
Category expression: Employees
Value expression: $V{maleCount}
o Click OK
o Again click Add:
Series expression: F
Category expression: Employees
Value expression: $V{femaleCount}
o Click OK, then Close
5.
With the Bar Chart element still selected, scroll half way down the Properties panel
and set Orientation to Horizontal
6.
38
7.
a. Open department_report.jrxml and run it to see how the chart looks when it
runs in a subreport
b. Adjust your formatting and element placement as required
o In the employee report, stretch the chart element to your liking
c. If no reports display the chart, or only some reports display it, then reduce the
size of the chart and see if that helps
d. The chart and other elements are displaying properly when you preview the
department_report and the first part of file looks similar to this
<snip>
End
39
Scenario
Sometimes reports need to combine data from database tables that have no relation. In iReport, a report
can reference only one query. Charts (and a few other elements in the Palette) let you query a table
separate from the tables named in the reports main query.
Time
10 minutes
In this lab, define a dataset and pie chart to represent the number of employees in Canada, the U.S. and Mexico.
Instructions
40
Task 1: Create a subdataset and a pie chart to display the number of store employees in three countries
#
Action
Steps
1. Open the department_report
Open department_report.jrxml and make sure its in Designer mode
2.
Create a dataset
In the Report Inspector right-click on the root level and select Add Dataset
3.
a.
b.
c.
d.
e.
f.
g.
h.
41
q. Click Next
r. On the Fields page, click the double caret >> to select store_store_country
and num_employees
s. Click Next
t. On the Group by page, set Group 1 to store_store_country
u. Click Finish
4.
5.
Add a chart
a. From the Palette drag a Chart (not Charts Pro or HTML5 Charts) into
the Summary band
b. In the chart type window, select Pie chart and click OK
6.
a. In the Pie Wizard window, select the country dataset from the drop-down and
42
wizard
click Next
b. On the Keys and values page, set these two values:
o unique identifier: the field $F{store_store_country}
o numeric value: the field $F{num_employees}
c. Click Next and Finish
7.
8.
Preview the report again and check the last page to view the pie chart
End
43
To gain some practice working with expressions and the Print When Expression in particular
Scenario
Display the department_ID alongside the department name. Modify the chart so that if the male or female
count is zero, a message displays instead of the chart.
Time
10 minutes
At the end of this lab, the bar chart displays only for departments that employ males and females.
44
Instructions
#
1.
2.
c. Click OK
3.
In Designer view, delete the department_id element from the Detail 1 bandit is
now redundant and no longer needed
4.
45
Steps
2.
3.
4.
5.
Back in Designer view, from the Palette drag a Text Field into the report and
place it directly on top of the chart
6.
Note: You can select Variables in the left column and double-click the variable
names in the center column, then add the necessary text
b. Click OK
c. Click OK
46
Note: When dealing with items d. In the Properties panel, find the Print When Expression for the Text Field
that overlap, select them from
and add the following expression (its in copyAndPaste):
the Report Inspector.
$V{maleCount} == 0 || $V{femaleCount} == 0
Display the new text message if e. Click OK
the department has no males
f. Center the text, increase font size, and edit the font color to your liking
or no females
7.
a. Preview the report to ensure the message and chart appear when appropriate,
and that the message is correct
b. Also test it in the department_report
47
Scenario
Create a stand-alone report that demonstrates query manipulation options that are available through the
JasperReports API.
Time
15 minutes
Configure two parameters that let report users specify the product brand names they want to omit from the report, and by
what field they want the records ordered
48
Instructions
#
1.
Steps
Create a new report using steps you know and name it query_param
2.
3.
4.
5.
a.
b.
c.
d.
Click the Report query button, then the Query designer button
Bring the product table over to the design area
Click the table name and deselect all
From the product table select these four fields:
o brand_name
product_name
sku
gross_weight
49
a. On the line following FROM public.product product enter this line (its in
copyAndPaste): WHERE $X{NOTIN, brand_name, brands}
b. Add to the end of the query: $P!{order_clause}
The bottom portion of the query should now look something like this:
c. Look carefully for typosmake sure the four fields appear in the bottom pane
then click OK to save the query
7.
a. In Report Inspector delete all bands but Column Header and Detail 1
b. Make both 30 pixels high
8.
Add text
a. In the Report Inspector, expand Fields and drag all four fields into Detail 1
b. In the Column Header band, edit the four labels so each says something
appropriate, like in this screen shot:
9.
50
a.
b.
c.
d.
a.
b.
c.
d.
a.
b.
c.
d.
End
51
To learn to create variables, pass them from a subreport to a main report, and specify evaluation time
Scenario
Create two variables that sum data in the subreport and pass the data to the main report for display.
Specify the correct variable evaluation time.
Time
20 minutes
At the end of this lab, the report displays employee count and total salary, as illustrated here.
52
Instructions
#
1.
Task 1: Create a variable that sums employee salaries for each department.
Action
Steps
Open employee_report.jrxml
Open the employee report
2.
3.
4.
Task 2: Configure an identical variable in the department_report so the first variables value can be passed to it.
Action
Steps
1.
Open department_report.jrxml
2.
53
3.
b. Scroll to the bottom of the Properties panel and click the edit button for
Return Values
c. Click Add
d. Enter the following (type it) into the Add/modify variable window
o Subreport variable: type totalSalary in the text field
o Local destination variable: totalSalary
o Calculation type: Nothing
o Click OK and OK
4.
From the Report Inspector drag the totalSalary variable into the Detail 1 band
and align it under the Total Salary label
54
5.
6.
#
1.
2.
Task 3: Create a variable in both reports to count and display the number of employees in each department
Action
Steps
Create the Total Employees
a. In employee_report.jrxml, create the Total Employees variable:
variable in the employee report
o Name: totalEmployees
o Variable Class: java.lang.Integer
o Calculation: Count
o Variable Expression: $F{employee_full_name}
b. Save the report
Call the Total Employees
variable in the
department_report
55
c. Scroll to the bottom of the Properties panel and edit Return Values
d. Click Add and enter the following
o Subreport variable: totalEmployees
o Local destination variable: totalEmployees
e. Click OK and OK
f. From the Report Inspector drag the totalEmployees variable into the Detail 1
band and drop it under the Employee Count label
g. Set the Evaluation Time of this new text field to Band
3.
#
1.
End
Steps
In department_report.jrxml, from the Palette drag the Page X of Y element into
the Page Footer
Note: This creates two text fields. Take a moment to look at the
Text Field Expression and Evaluation Time of both.
56
Scenario
Use iReport groups to improve the layout and readability of the report.
Time
15 minutes
Group records by department name and configure the group header so each departments info starts on a new page.
57
Instructions
#
1.
2.
3.
a.
b.
c.
d.
e.
f.
58
4.
5.
6.
59
Optional Task 2: Gain more group practice by working with the query_param report. This task is purely optional.
#
1.
Action
Steps
2.
c. Click OK when the query is error free (when the field names appear below)
3.
4.
60
5.
6.
7.
8.
Preview the report and note the changesHigh Top now begins on a new page
9.
a. Drag a Chart element (not Charts Pro) from the Palette onto the Summary
band
b. Pick Pie 3D, press OK and then Cancel when the wizard window opens
c. Select the chart icon and size it to fill the band
61
a.
b.
c.
d.
e.
End
62
Scenario
Create an alternating-color background for the rows of content that appear in the employee report.
Display all salaries greater than $35,000 in red.
Time
10 minutes
At the end of this lab, salaries greater than a certain value appear in colored text, and employee
names display on alternating row background colors.
63
Instructions
#
1.
2.
Add a style
In the Report Inspector right-click on Styles and select Add > Style
3.
4.
Create a condition
Question 10.1
What does this condition do?
a. In the Report Inspector expand Detail 1 and select the Frame element
5.
Steps
64
6.
7.
a. Back in Designer view, right-click on the table style and add a second
conditional style
b. The Condition Expression: $F{employee_salary} > 35000
c. Set the Forecolor to Red
8.
a. Apply the style to the text field that writes out Salary
o In the Report Inspector expand Detail 1 and the frame, select the
employee_salary Text Field, and set its Style property to table
b. Ensure this text field has no Forecolor set; reset to default (black)
9.
a. Preview employee_report.jrxml
b. Preview department_report.jrxml to view it with the redesigned subreport
65
Scenario
Create a theme for charts that is applied to a suite of reports. Applying a theme to charts greatly reduces
the time required to edit the look and feel of reports.
Time
15 minutes
This lab demonstrates how to color charts with a chart theme.
66
Instructions
1.
Task 1: Create and apply a chart theme using the steps below.
#
Action
Open employee_report.jrxml
Open employee_report.jrxml
2.
a.
b.
c.
d.
3.
a. In the drop-down selector at the top of the Chart Designer change the chart type
to Bar 3D Chart
Steps
4.
a. Right-click the Chart element near the top of the Template Inspector and
select Properties
67
b. In the Chart - Properties window click the Background Paint edit button
a. Right-click the Plot element in the Template Inspector and select Properties
b. In the Plot - Properties window select the edit button for Background Paint:
o Paint: Color
o Color: Click the Edit button; Hex Value tab; enter #CCFFFF
c. Click OK and OK, and notice the color change behind the bars of the graph
d. Click the edit button for Series Colors; these are the bar colors
o Click Add; Hex Value tab; enter #0066CC
o Click OK
o Repeat to add Hex color value: #FF66FF
o Click OK, then the Close button, and notice the pink and blue chart bars
68
o Ignore the third red bars; your chart displays only two bars
o Click the Save button to save file updates
6.
c.
d.
e.
f.
7.
69
8.
9.
a. The new chart looks best when viewed as a PDF file, so configure iReport to
find a PDF viewer
b. From the main menu, click Tools > Options and select the Viewers tab
o This is where you configure many different viewers to display reports
c. In the PDF Viewer line, browse to find the Adobe Reader executable file, often
found at C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe
End
70
Scenario
The team is developing a suite of several reports. You need to change fonts, colors and text size
simultaneously across all reports. External style sheets simplify this task.
Time
15 minutes
At the end of this lab, reports are styled by an external style sheet.
71
Instructions
#
1.
2.
a.
b.
c.
d.
3.
Steps
72
4.
In the Template Inspector right-click on the top-level Styles element and select
Add > Style
5.
6.
73
a. In the employee report, select the static text field Full Name in the
Column Header band
b. In the Properties panel set the Style to header (reference)
c. Repeat for the other three column headers
d. Save the report
8.
a.
b.
c.
d.
9.
In the menu, click Preview > Internal Preview to disable the PDF viewer, then
preview the reports and see how the base and header/title styles affect their look
End
74
Scenario
Time
5 minutes
Instructions
#
1.
2.
From the menu select Preview > XHTML Preview to enable browser view
3.
4.
Click the Preview button to view the report in the application you configured
Note: If youre already in Preview, click Refresh
to execute the report
a. From the menu select Tools > Options and the Export options tab
b. Take a moment to review the options; each exporter has a set of properties
that are configured here
End
75
Scenario
You need to display a comma-separated list of all departments at the top of the report. Employ a
scriptlet to save the department names in a variable and write them to the report.
Time
10 minutes
Configure a variable and use a scriptlet to display all the department names at the top of the report.
76
Instructions
#
1.
2.
3.
The following is a copy of the source code of the scriptlet used in this lab.
Review the code if it interests you; otherwise skip ahead to step 4.
The three pieces of bold text are the items the scriptlet code is expecting.
77
78
a.
b.
c.
d.
e.
From the main menu select Tools > Options and the Classpath tab
Click the Add JAR button
Browse to the Samples folder and select the TrainingScriptlet.jar file
Click Open and then OK to close the Options window
Click the Compile button to make sure the Scriptlet JAR file is now included in
the report (check in the XML if you like)
a. From the Report Inspector drag the Departments variable into the Title band
and drop it at the left just below the image or Title text field
b. Stretch the variables text field to fill the extra space below the title
79
7.
8.
a. In Designer View select the variables text field in the Title band
a. Preview the report again; You may have to adjust the size of the text field to
see all twelve department names
b. Adjust the height/position of the Title bands items as necessary
80
Scenario
Human Resources want to view the Company Information report created in Lab 4d.
Time
5 minutes
Instructions
#
1.
Task 1: Deploy the Company Information report to the JasperReports Server repository.
Action
Steps
Configure a connection to the
a. Click the Window menu and select JasperReports Server Repository to open
repository
the Repository Navigator panel
b. In the panel, click the Add new server button
81
2.
a.
b.
c.
d.
e. Click Next
f. In the second window, click the Get source from current opened report
button and click Next
g. On the final window, select the radio button labeled From the repository
h. Click the triangular drop-down arrow and select
/analysis/datasources/FoodmartDataSourceJNDI
i.
Click the Finish button to exit the wizard and deploy the report to the
JasperReports Server repository
Note: In the following lab exercise, you log into JasperReports Server and
explore the personalization features of the report.
End
82
Log into JasperReports Server, personalize the report, and save two copies of it.
Scenario
Report users want to view the report and save copies that display only the information they need to see.
Time
20 minutes
Instructions
#
1.
2.
Task 1: Hide one column and format two others, and format the column header labels.
Action
Steps
Log into JasperReports
a. Log into JasperReports Server as joeuser / joeuser
Server and open the
b. Click the View Reports button on the home page
Company Information report
c. Click the Company Information report title to execute the report
a. Click anywhere on the Title column to select it
Remove the Title column from b. Point to the Format menu and select Hide Column
the report
83
3.
report
a.
b.
c.
d.
e.
f.
g.
h.
4.
84
Note: The column header label is changed and the date values reflect the
selected pattern.
5.
#
1.
Note: This step is optional. Proceed to the next task if you wish.
a. One at a time, format the column header labels to your liking:
o This may take a few minutes: In each columns Format column window,
change the heading text, font, size, style, alignment, and color
Task 2: Relocate and resize columns, examine the Redo and Undo buttons, and save the report.
Action
Steps
Move the Salary column to
a. Click the Salary column to select it
the left of Hire Date
b. Click and hold down the mouse button and slowly drag to the left of Hire Date
85
c. Click and drag the dotted-line column edge a little bit to the right, then release
the mouse button to increase separation between two columns
d. Increase the width of the Title column so lengthy titles display properly
e. Reduce the width of the first name, last name, and other columns to your liking
o Ideally, all column spaces are similar across the report
86
3.
a. Click the Undo button to move one step back in the report edit history
b. Click the Redo button to return the report to the state it was in before you
clicked the Undo button
Important: DO NOT click the Undo All button, as all edits are lost.
4.
Save this version of the report Note: The name of the report currently open is displayed near the top left of the
formatted to your
browser window, along with the date and time it was last refreshed.
specifications
87
b. In the window, add v1 to the end of the report name to signify version 1
#
1.
Task 3: Filter and sort to segment the report and view specific information.
Action
Steps
Create filters on the
Display records of all employees with a Bachelors Degree
Education and Title columns
a. Click in the Education column to select it
to identify store managers
b. In the column menu, click the Filter button
who have earned a Bachelors
Degree
88
Note: In the Filter column window, select the Show all rows radio button to
delete a filter, or the Show only rows where radio button to create a filter.
c. Click the Show only rows where radio button
Create a filter that returns all
records whose Education field d. Click the filter operators drop-down and select Contains
contain the word Bachelors
e. Enter the word Bachelors in the filter text field and click OK to add the filter
Note: The star icon adjacent to a column header indicates that a filter is set
2.
a.
b.
c.
d.
3.
4.
a. Open the Education columns filter window and change the operator to Equals
b. Edit the filter text to Partial College and click the OK button
Note: The report describes store managers with a partial college education.
Note: Both filters are removed and the report displays all records.
89
5.
a. Click the Salary column and select the Sort ascending button
Note: The ascending sort icon is adjacent to the header label and
report records are sorted in order of increasing salary
c. Examine employees named Thompson and determine which were hired at the
same time
d. Remove the sort on Hire Date
Note: The report remains sorted on last name ascending
7.
a. Configure a filter on the Education column that contains the word College
b. Create a new filter for the Hire Date column
o In the operator drop-down select Is before
o Click in the filter text field to open the calendar tool
90
before 1995
Note: Click through the calendar to select a date, or enter a date manually into
the text field.
c. Enter the date 1995-01-01 into the text field and click the OK button
Note: The report displays records of employees with a partial college education
who were hired before 1995. Records are sorted alphabetically by last name.
8.
End
91
Scenario
You need to add a French translation for the title of the department_report.
Time
10 minutes
Instructions
#
1.
2.
a.
b.
c.
d.
e.
f.
3.
Specify favorites
92
4.
Add a locale
a.
b.
c.
d.
e.
93
5.
a. If the default language file is still open for editing in Design View,
it should look similar to this:
a. Return to department_report.jrxml
b. In Designer View select the text field that displays the report title
c. Scroll the Properties panel and click the edit button for Text Field Expression
d. Change the expression to $R{title} and click OK
94
e. In the Report Inspector right-click the root level and select Properties
f. In the Properties window, click the edit button for Resource bundle
8.
a. From the main menu select Tools > Options and the
Compilation and execution tab
b. Near the bottom change the Report Locale to French (France)
c. Click OK and OK
9.
End
95
Scenario
You need to deploy the department_report and all its dependencies to the repository.
Time
20 minutes
Instructions
Task 1: Deploy the department_report.
#
Action
Steps
1. Create a report unit
a. In iReport, open only department_report.jrxml in Designer mode
Note: Plugin is another name
b. Ensure the Repository Navigator panel is available. If it is not, select
for Repository Navigator. The
Window > JasperReports Server Repository
names are interchangeable
c. In the Repository Navigator, expand Local Server
o If it does not expand, right-click on the server icon and select Refresh
d. Right-click the Public folder and select Add > JasperServer Report
96
97
2. Configure resources
a. In the Repository Navigator expand the Public folder and the new Department
Report folder
Important:
When deploying external file
resources, make the ID value
the same as the full file name
(see step b. for an example).
98
99
g. Back in the Repository Navigator, under the Department Report folder, rightclick on Main jrxml and select Open in editor to open a copy of the repository
version of the department_report in Designer View
h. In the Report Inspector expand Styles and select
Template (TrainingStyle.jrtx)
i. In the Properties panel, confirm that its Source Expression is
"repo:TrainingStyle.jrtx"
j. Check for typos, then click OK to close the window and save changes
a. In the Report Inspector, expand the Detail 1 band and select the
subreport element
b. In the Properties panel, confirm that the Subreport Expression is
repo:employee_report.jrxml
Note: Be very sure the expression ends with .jrxml, not .jasper
c. Check for typos, then click OK and Save the report
d. Make sure you save the report
e. In the Repository Navigator, right-click on Main jrxml and select
Replace with current document
100
a. Click the Log Out link at the top right of the page
b. On the login page click the Show locale & time zone link
c. Select Locale: fr French
End
101
To add a single-select input control to the deployed report from the Repository Navigator
Scenario
Users want to be able to specify a single department name for which they want to see information.
Time
20 minutes
At the end of this lab, you will have created an input control that lets JasperReports Server users specify the department
for which they want to view employee information in the department_report.
102
Instructions
#
1.
2.
Task 1: Add an input control to the report so the user can select a specific department.
Action
Steps
Update the local copy of
a. Back in iReport, close all open reports
department_report.jrxml with b. Because youre soon going to overwrite department_report.jrxml with the
the repository copy
repository version of that file, you should create a backup copy of
department_report.jrxml so you dont lose the only working copy of it
Note:
o Open department_report.jrxml
The JasperReports Server
o Select File > Save As and save a copy as department_report_good.jrxml
plugin updated the Subreport
o Close that copy so no reports are open
Expression so the report would
run on JasperReports Server.
c. In the Repository Navigator expand the Public folder and the Department
You want to make sure the
Report folder
local copy reflects this change. d. Right-click on Main jrxml and select Open In editor
o This opens a copy of the report stored in the repository, not a local copy
e. From the main menu select File > Save As
f. Navigate to the directory in which you keep all reports
g. Click on department_report.jrxml to select it
h. Click Save to overwrite the local copy of department_report.jrxml
o Select Yes when the prompt appears warning about the overwrite
o The local copy of the report now matches the copy in the repository
Add a Parameter to let the
report user specify the
department name
103
b. Add this WHERE clause to the bottom of the query, after the FROM clause
(or copy it from the copyAndPaste file):
WHERE department.department_description = $P{department}
If you dont see the two field names at the bottom, find and fix the typo(s)
c. Click OK to apply the changes and close the Report query window
4.
a.
b.
c.
d.
e.
104
f. Set Value to {0} Report with a space before the word Report
g. Click OK and Close to save the changes and close the Properties window
h. In Designer view, up in the Title band, stretch the $R{title} text field to the right
so it displays the longer department names plus the word Report
5.
a. In the Report Inspector select the text field that writes out the title
b. In the Properties panel, edit the Text Field Expression (or copyAndPaste) :
msg($R{title}, $P{department})
Note: the parentheses wrap the $R and $P expressions together
c. Click OK, then save the report before proceeding
6.
105
7.
106
o General tab:
ID: query
Name: query
o
Query tab
Query Language: SQL
Query: (this is in copyAndPaste):
SELECT department_description AS name FROM department
Check carefully for typos. Use the copyAndPaste file if necessary
f.
g.
h.
i.
j.
k.
Click Save
Click the Value and Visible Columns tab near the middle of the window
Enter name in the Value Column field
Click the Add button and enter name in the dialogue that appears
Click OK
Click Save to save the input control
107
l.
i.
End of Labs
You learned to publish a complex report to the repository, where users log in and
view the report. You also gained valuable experience adding an input control to a
deployed report.
108
Scenario
Time
15 minutes
In this lab you create a crosstab report that resembles this screen shot:
109
Instructions
#
1.
2.
3.
a. Click the Report query button, then the Query designer button
b. Bring in the following tables:
o store
o sales_fact_1998
o time_by_day
c. Join store to sales_fact_1998 on store_id (see Notes to the left)
d. Join sales_fact_1998 to time_by_day on time_id
e. Click each table name and choose deselect all
Note:
To join two tables in the Query
designer, click the field name
on one table and drag over to
the same field name on the
table you wish to join
When you see a small plus
sign, release the left button to
complete the join
Steps
a. Create a new report named CostSummary (File > New )
b. Save it in the same directory with the other reports
110
i.
j.
Click OK.
After the five field names appear in the bottom pane, click OK to close the
Report query
4.
From the Palette, drag a Crosstab element into the Summary band to open the
Crosstab wizard
5.
111
6.
a. To format them properly, Ctrl-click the six right-most $V cells and, in the
Properties Panel, set their pattern to Currency with zero decimal places
112
Scenario
You need to design an animated chart that displays products by product category and product family.
Time
15 minutes
At the end of this lab you will have configured a Flash-driven chart that looks similar to this:
113
Instructions
#
1.
2.
a. Set the Title band Height to 25 and the Summary band Height to 500
b. Right-click all other bands and delete them
3.
a.
b.
c.
d.
e.
f.
g.
4.
If the Formatting Tools panel is closed, click the Windows menu and open it
From the Palette drag a Static Text element into the Title band
In the Formatting Tools panel scroll down and select Adapt to Parent
In the Designer View double-click the Static Text element
Enter the text: Product by Category
Format the title text to your liking using the Properties panel
Press Enter to apply the text change
114
i.
j.
a. Add an alias to the product count: (add the bold text below)
o count(product.`product_id`) AS product_count
b. Click the Read Fields button to ensure the field name is updated
c. Click OK to close the Report query window
6.
Add an element
a. Drag and drop the Charts Pro element (not Chart) from the Palette to the
115
Summary band
b. Select Bar3D from the Chart Types selection dialogue and click Ok
c. Back in Designer View select the chart element to highlight it
d. In the Formatting Tools panel click Adapt to parent to set its size
a. Right-click the chart and select Edit Chart Properties
b. Under the Chart Configuration tab, and Chart Titles and
Axis Names, input the following:
o X Axis Name: Category
o Y Axis Name: Product Count
c. Click the Chart Data tab, then the Dataset Items tab
d. Select the entry Change Me and click the Modify button
e. In the Dataset Item window, set the following (delete any text you see)
o Series Expression: Open the Expression Editor
o In the lower-left pane select Fields, and in the lower-center pane doubleclick product_class_product_family
o Click Apply
o Category Expression: Repeat that process, this time selecting
product_class_product_category
o Value Expression: Repeat again, this time selecting product_count
116
o The Dataset Item window should look like this when you finish
9.
117
#
1.
c. The chart should look something like thisthere are no trend lines yet
118
Variable 2:
o Name: minCount
o Variable Class: java.lang.Integer
o Calculation: Lowest
o Variable Expression: $F{product_count}
Variable 3:
o Name: avgCount
o Variable Class: java.lang.Integer
o Calculation: Average
o Variable Expression: $F{product_count}
2.
c. In the Report Inspector expand the Summary band, right-click the Charts Pro
element and select Edit Chart Properties
d. Select the Trend Lines tab and click Add
e. In the Trend Line window set the following:
o Color: blue
o Label Expression: Min-to-Max Trend (yes, double quotation marks)
o Start Value Expression: $V{minCount}
o End Value Expression: $V{maxCount}
f. Click OK
g. Click Add again and set the following:
o Color: red
o Label Expressions: Average
o Start Value Expression: $V{avgCount}
o End Value Expression: $V{avgCount}
h. Click OK and Close
119
3.
4.
End
120
Scenario
You need to design a North America Map report that allows users to view sales by country.
Time
20 minutes
At the end of this lab you will have created a Flash-powered colored map of North America that resembles this:
121
Instructions
#
1.
2.
a.
b.
c.
d.
From the main menu select Tools > Options and the Classpath tab
Click the Add JAR button
Browse to the Samples folder and select the entityVer5.jar file
Click Open, then OK to close the Options window
3.
4.
a.
b.
c.
a.
b.
c.
d.
5.
a. Click the Report query button and then the Query designer button
o Bring in the sales_fact_1998 and store tables
o Click both table names and deselect all
122
a. From the Report Inspector, drag the fields store_store_country and totalsales
into the Detail 1 band
b. In the Column Header band, edit the boxes to read Country and Sales
c. Adjust all four elements size, alignment and location to your liking
d. Select the totalsales text field in the Detail 1 band and, in the Properties panel,
assign a Pattern of Currency with no decimal places
123
7.
a. From the Palette, drag the Maps Pro element into the Summary band
b. Select the Maps Pro element and, in the Properties Palette, set its
Width to 400 and Height to 450
c. Make certain the element sits entirely in the Summary band
8.
a. Right-click the Maps Pro element and select Edit Map Properties
b. Near the top right of the window, click the Select a map name button
c. Under Map categories select All maps
Note:
To take the value of
store_store_country coming
from the DB and look up the
ID that Fusion Maps expects,
use the following call to
external Java code:
com.jaspersoft.training.fusion
maps.EntityCodes.findId($F{st
ore_store_country},"na")
Be careful:
If you click to use the
Expression Editor, it
automatically inserts a closing
parenthesis or curly brace
when you open one.
124
Label Expression
Poor
Fair
Good
Excellent
125
Create a country map report to which you drill down and view from the North America map
Scenario
You need to design a country map report that users view by clicking on a specific area of the North
America map.
Time
20 minutes
At the end of this lab, you will have designed a North American map with three clickable countries.
126
Instructions
#
1.
2.
Task 1: Create and design a map report using the steps below.
Action
Steps
Create a new report
a. Select File > New > Blank A4 > Open this Template
o Report Name: CountryMap
o Location: With the other reports
b. Click Next and Finish
Add the JAR to the classpath
If you did Lab 18a, Create a
North America Map then skip
this step
a. From the main menu select Tools > Options and the Classpath tab
b. If entityVer5.jar is already in the Classpath, then skip to step 3.
Otherwise, if you do not see a line in the Path pane that ends with
entityVer5.jar, click the Add JAR button, browse to the Samples folder, and
select the entityVer5.jar file. Click Open and OK
3.
4.
127
5.
a. From the Palette drag a Text Field (not static) element to the Title band
b. Adjust its size, alignment and location
c. Right-click the Text Field element in either the Report Inspector or in Designer
view and select Edit expression
d. Delete anything there and enter this expression (its in copyAndPaste):
Sales by State + $P{country}
e. Click Apply
6.
a. Click the Report query button, then the Query designer button
b. Bring over the sales_fact_1998 and store tables to bring them into the query
design area
c. Click each table name and deselect all
d. Join the two tables on the store_id field (see Notes at left)
e. In the store table select the store_state column
f. In the sales_fact_1998 table right-click on the store_sales field and select
add expression
g. Select sum from the drop-down box, then click OK
h. In the top-left pane, right-click store.store_state AS store_store_state and
select add to group-by
i. Right-click again and select add to order-by
Note:
To join two tables in the query
designer, click and drag from
the field name in one table and
drop it on top of the field name
in the table you wish to join.
When you see a small square
with a plus (+) inside, release
the left button to complete the
join.
j.
128
m. Right-click the word WHERE at the upper-left and select add condition
o In the top pane enter store.store_country
o Make sure = is selected in the middle
o In the bottom pane enter $P{country}
o Click ok
n. Click OK to exit the query designer, and OK again to save the query
7.
8.
a. From the Palette drag a Maps Pro element into the Summary band
b. Select the Maps Pro element and in the Properties panel set Width to 500
and Height to 225
129
9.
a. Right-click the map element in the Report Inspector or in the Design window
and select Edit Map Properties
b. Under the Map Configuration tab, set the Map Name Expression to:
$P{country}
o Type it or use the expression editor
c. Select the Map Data tab, then the Entities tab
d. Select the entry Change me! and click the Modify button
e. Select the Data tab and set the following (please use copyAndPaste):
o Id Expression: $P{country}=="USA"? $F{store_store_state} :
com.jaspersoft.training.fusionmaps.EntityCodes.findId($F{store_store_state
},"state")
o Value Expression: $F{totalsales}
o Label Expression: $F{store_store_state}
f. Click OK to return to the Map Properties page
g. Click the Color Ranges tab and the Add button
h. Add four color ranges, each according to a row in this table:
(the back-slash in the Label Expression helps print the dollar sign)
Color
Red
Orange
Yellow
Green
i.
Label Expression
Poor \$(0-10k)
Fair \$(10k-50k)
Good \$(50k-100k)
Excellent \$(>= 100k)
Min Value
0
10000
50000
100000
Max Value
9999
49999
99999
999999
130
131
d. Go to the directory to which you save reports and rename the output file
CountryMap.html to CountryMap_USA.html
e. Re-run the report
, enter Canada for country, and rename the new
CountryMap.html output file to CountryMap_Canada.html
f. Re-run the report, enter Mexico for country, and rename that new
CountryMap.html output file to CountryMap_Mexico.html
132
End
133
Answer 2.1
Answer 4.1
134
Answer 4.2
Answer 5.1
Answer 10.1
Answer
18a.1
What are the USAs sales and its color on the map?
550,808 and Green
Answer
18a.2
135
Action
2.
3.
Select the template you want to use, and enter the report name and location to which you want to save it.
Action
2.
Click a table field (a small square with a plus sign displays) and drag to the top of the table field to which you
want to join.
3.
136
137
2.
Note: a ternary expression performs a test and outputs one of two values depending on whether the test returns
true or false. In the example below, you test if the field sales_fact_1998_store_sales is greater than 100. If it is,
the value to the left of the colon is returned. If not, the value to the right of the colon is returned.
138
139
Useful for storing larger decimal values (e.g. dollar figures). Elements of type BigDecimal offer
methods for adding, subtracting, dividing and comparing to other BigDecimals. BigDecimal is
more accurate when doing calculations that require precision.
java.lang.Integer
java.lang.Double
java.lang.Float
Used to store decimal values, but with less precision than that offered by a Double
140
To open the Report query window, click the icon to the right of the Preview tab
2.
Inside the Report query window, manually edit the query, load a query from a *.txt file or *.sql file on your local
machine, or click the Query designer button to launch the query designer.
141
Note:
When you click the Read Fields button iReport runs the query, returns the list of columns from the database,
and creates matching fields for each column. The SQL statement takes the form SELECT <expression> AS
alias and the alias name is used as the field name in the report.
You also access JasperReports Filters and Sort options from this screen.
SQL Basics
The following summarizes some of the SELECT skills utilized in the labs. Create all of these with the Query designer or
manually create them. This section is not a substitution for a proper SQL reference; rather it is a short reference for some
of the syntax used when selecting data.
Command
Simple Select
Use
SELECT FirstName, LastName FROM Customer;
This query retrieves the columns FirstName and LastName from the Customer table, so
iReport registers a $F{FirstName} and $F{LastName} field in the report.
Use aliases to change the names of columns, which in turn changes the field name.
The query below shows how to change the first column name to GivenName:
SELECT FirstName AS GivenName, LastName FROM Customer;
142
Aggregations and
Group By
Databases can aggregate and perform other operations for us (the operations available depend
on the database). For example, to sum the salaries:
SELECT sum(salary_paid) AS sumSalaries FROM salary
If you want each departments salaries, add group by to the query:
SELECT sum(salary_paid) AS sumSalaries, department_id AS id FROM
salary GROUP BY department_id
Every field name that does not appear in an aggregate function (like 'sum' or 'avg') must
appear in the GROUP BY clause.
Joining Tables
To list department names rather than IDs, add a join to the SQL statement. The salary table
has a department_id column but no department_description (the departments name), and
the department table contains no salary information. Join the tables and retrieve all records
from the department table that have a matching department_id value in the salary table:
SELECT sum(s.salary_paid) AS salary, d.department_description AS
department
FROM salary s
INNER JOIN department d ON s.department_id = d.department_id
GROUP BY d.department_description
143
WHERE clause
Use a WHERE clause to find a specific record. This query retrieves the record for which the
department_id is 1:
SELECT sum(salary_paid) AS salary, department_id AS id FROM salary
WHERE department_id = 1
Strings used in a query must be surrounded by single quotation marks:
SELECT sum(s.salary_paid) AS salary, d.department_description AS
departmentName
FROM salary s
INNER JOIN department d ON s.department_id = d.department_id
WHERE d.department_description LIKE '%HQ%'
That query also uses a wild card. Use those sparingly to minimize performance issues.
NOTE: If you use $P{} to insert a value into a query, do not put quotation marks around string
values, as the system does this for you.
ORDER BU Clause
Use the ORDER BY clause to make the database sort the result set:
SELECT sum(s.salary_paid) AS salary, d.department_description AS
departmentName
FROM salary s
INNER JOIN department d ON s.department_id = d.department_id
GROUP BY d.department_id
ORDER BY salary
144
145
146
Scenario
You are a report developer. Your user community has asked for a simple way to create reports
displaying product information. Satisfy the requirements by creating a Topic in iReport.
Time
15 minutes
Instructions
Task 1: Design the query and deploy the JRXML file to the repository.
#
Action
Steps
1. Create a JRXML template
a. Open iReport Designer
file in iReport
b. Select File > New and click the Open this Template button at the page bottom
o Report name: Product Info
o Location: your labWork folder or elsewhere
c. Click Next and Finish
2.
147
3.
148
o
o
o
o
4.
a.
b.
c.
d.
2.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
149
a. Drag in or double-click fields and measures to add them to the Ad Hoc view
b. Select Full Data in the Data Mode drop-down to view the entire dataset
4.
End Lab
150
To design and create a Domain based on a single database table with no calculated fields. Test
the Domain by creating a table Ad Hoc view, saving it as a report, and exploring report
personalization.
Scenario
Business users need to analyze the foodmart employee data. You created and deployed a
similar report using the iReport Designer. Create this report directly in JasperReports Server.
Time
15 minutes
Instructions
Task 1: Use the Domain Designer to design the Employee Domain based on the foodmart public_employee table
#
1.
2.
Action
Steps
Log into
JasperReports Server
a.
b.
c.
d.
e.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
151
3.
4.
a. Scroll down and drag (or double-click) the public_employee table into the Selected
Tables panel
c. (Optional) Expand the public_employee set to confirm the items in it match those in the
public_employee table
d. Click the OK button at the lower left to return to the Edit Domain page
5.
6.
152
Task 2 Create a table Ad Hoc view from the Employee Domain and save it as a report.
#
1.
2.
Action
Start the Ad Hoc Editor
Steps
3.
a. In the Source panel, double-click public_employee to move the table into the Selected
Fields panel
4.
a. Click the Table button at the bottom of the window to open the Ad Hoc Editor
b. In the Fields panel, expand the public_employee dataset
c. Click and drag these six fields to the Columns box in the Layout Band
first_name
last_name education_level
marital_status position_title hire_date
d. Similarly, from the Measures panel drag the salary measure to the columns box
5.
153
c. Select Full Data from the Data Mode drop-down to return the whole dataset
d. Select Sample Data to view only the default 15 records
e. (Optional) Click the Change Source icon at the left to select a different Topic or Domain,
or if you want to add additional fields from the current data source
6.
a. Mouse over the Save menu and choose Save Ad Hoc View and Create Report
b. At the top of the window, in the Data View Name field, enter
Employee Domain Ad Hoc View
c. In the middle of the window, in the Report Name field, enter
Employee Domain Ad Hoc View Report
d. Below, select the Organization > Training folder
e. Click the Save button
7.
8.
a.
b.
c.
d.
End Lab
154
To design and create a Domain with several tables, a derived table, inner joins, and a calculated
field. Design a crosstab view to test the Domain and save it as a Topic
Scenario
Business users need to report and analyze sales by product category and store.
Time
30 minutes
Instructions
Task 1: Use the Domain Designer to design the Training Domain.
#
1.
2.
Action
Steps
Log into
JasperReports Server
a.
b.
c.
d.
3.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
155
public_store
4.
a. Click the Derived Tables tab at the top of the Domain Designer
b. In the Query ID field, enter productnew
c. In the Query field, enter
SELECT * FROM product WHERE brand_name = Club OR brand_name = Token
(or copy it from the copyAndPaste file)
Query result:
o product_class_id
o product_id
d. Check carefully for typos, then scroll down and click the Run Query button
e. Scroll a bit more and view the query results. Ctrl-click to select only two fields:
o product_class_id
o product_id
f. Click the Save Table button
g. Notice the different icon representing the derived table at the top of the
Available objects panel
5.
Field: product_class_id
Tables:
o product
o product_class
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
156
6.
Field: product_class_id
Tables:
o product_class
o productnew
Field: product_id
Tables:
o productnew
o sales_fact_1998
Field: store_id
Tables:
o sales_fact_1998
o store
e. In a similar fashion complete these three inner joins on the following tables:
o Left: public_product_class and Right: productnew on the product_class_id field
o Left: productnew and Right: public_sales_fact_1998 on the product_id field
o Left: public_sales_fact_1998 and Right: public_store on the store_id field
a. Click the Calculated Fields tab at the top of the Domain Designer
b. Enter a Field Name of store_profit
c. The type is BigDecimal
d. In the Available Fields panel, expand JoinTree_1 and public_sales_fact_1998
e. Double-click the field name store_sales to move it to the Calculated Field panel
f. In the Expression field, enter a minus sign (hyphen) after the store_sales field
g. Double-click store_cost at the left to move it to the Expression: panel
157
7.
a.
b.
c.
d.
f. Click OK
8.
a.
b.
c.
d.
e.
f.
g.
158
h. Select Demo Set 1 again, then also add the product_name field to Demo Set 1
i.
j.
k. Click to highlight Demo Set 1, then again click the Add to Selected Set button to move
l.
o. Repeat steps a-c to create a second set, and label it Demo Set 2
p. From the public_store table, add these four fields to Demo Set 2:
o store_city store_country store_name store_state
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
159
q. From the public_sales_fact_1998 table, add these two fields to Demo Set 2:
o customer_id store_profit
Result: Configuration of the new Domain is complete
9.
a.
b.
c.
d.
Task 2 Create a crosstab Ad Hoc view from the Training Domain and save it as a Topic.
#
1.
Action
Start the Ad Hoc Editor
Steps
2.
160
4.
a.
b.
c.
d.
e. At the right, view the Change | Remove links so you know they are there
5.
Save as Topic
6.
a.
b.
c.
d.
e.
f.
Click the Crosstab button at the bottom of the window to open the Ad Hoc Editor
Expand the Demo Set 1 set
Click and drag the product_family and product_category fields into the Columns box
Expand Demo Set 2 and drag the store_name field to the Rows box
Under Measures, expand Demo Set 2
Click and drag the store_profit measure to the Rows box
7.
a.
b.
c.
d.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
161
8.
a. Save the view as <Your Name> Crosstab Ad Hoc View from Training Domain Topic
in the Organization > Training folder
162
To observe the SQL queries involved with creating a Domain-based Ad Hoc view by using the
View Query command and by inspecting the JasperReports Server log file
Scenario
The Ad Hoc data policies govern how the JasperReports Server handles database queries and
in-memory processing for Domain-based Ad Hoc views
Time
20 minutes
Instructions
Task 1: Change the log settings and the Ad Hoc settings.
#
1.
2.
Action
Access the logging settings
page
Set Domain-related log
settings to DEBUG
Steps
3.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
163
4.
Task 2: Create a Domain-based Ad Hoc view and inspect log file entries.
#
1.
Action
Open the log file
Steps
2.
Create a Domainbased Ad
Hoc view using the Simple
Domain
3.
a. In the Source panel, double-click on Accounts to move it to the Selected Fields panel
b. Click the Table button at the lower left to begin building the Ad Hoc view
Result: The Ad Hoc Editor appears
164
4.
5.
Add a filter
165
6.
Result: The View Query window displays the same SQL query you saw previously
7.
a. From the Fields panel, drag the Account Name and Account State fields into the
Columns box in the Layout Band
Result: With rows retrieved from the database, the Account Name and Account State
columns appear
8.
9.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
166
* Optional steps
a. Add another filter of your choosing, and/or change selected filter values
b. Add the Opportunities dataset from the Domain (see instruction at left)
o Add Amount from the Opportunities data set to the view
o Right-click on the Amount column header and add a summary
o Run the report again, then view the latest log entries
End Lab
167
Scenario
The business requirements include making the Domain available in another language
Time
10 minutes
Instructions
Action
Download the bundle stub
from the Domain
The bundle stub is an empty
name-value pair file that
associates all your Domains
field names with the text you
want. Youll add names and
descriptions for each field
name in both your Domain
sets
Steps
a.
b.
c.
d.
e.
f. In the Export Bundle window, select both check boxes and click OK
g. Save the file to the desktop as Training_Domain.properties, or rename the file after you
save it
Note: The properties file name must match the Domains Resource ID value; make
sure the file is named Training_Domain.properties
168
a. After you save the Training_Domain.properties file, create a duplicate file by saving it
as Training_Domain_ro.properties
b. Edit the following values to create a Romanian (_ro) translation file:
NEWSET1.LABEL=Eticheta
NEWSET1.DESCR=Descriere
NEWSET1.PRODUCT_CATEGORY.LABEL=Categorie produs
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
169
NEWSET1.PRODUCT_FAMILY.LABEL=Familie produs
NEWSET1.PRODUCT_SUBCATEGORY.LABEL=Subcategorie produs
NEWSET1.BRAND_NAME.LABEL=Nume marca
NEWSET1.PRODUCT_NAME.LABEL=Nume produs
c. Save the file. Make sure it is named Training_Domain_ro.properties
d. Press the OK button at the bottom left to return to the Edit Domain page
5
a.
b.
c.
d.
e.
At the right of the Edit Domain page, click Add Locale Bundle
In the pop-up, click Browse and select the Training_Domain.properties file
Click the Select button to upload the default locale file
Repeat steps a-c to upload the Training_Domain_ro.properties file
Click the Submit button at the lower left to save the Domain changes
a.
b.
c.
d.
170
171
Scenario
Business requirements specify that users with a given role running reports based on this Domain
should see data only of a single specific brand
Time
20 minutes
Instructions
Action
Examine the security and Domain
design files
Steps
a. Open Notepad++, drill through the samples folder, and open the files called
role-row-security.xml and schema.xml
Note: For Live Online students, the samples folder is on the training desktop.
Otherwise ask the instructor where it is.
2.
172
3.
4.
a.
b.
c.
d.
On the login page make sure that the default locale is selected
Log into JasperReports Server as jasperadmin / jasperadmin
From the menu select View > Repository and open the Training folder
Right-click the Training Domain name and select Edit
Result: The Edit Domain window appears
e.
f.
g.
h.
5.
a. Create an Ad Hoc view using the Training Domain that you just secured
b. Expand Products and select the Brand field
c. Click the Table button at the lower left
Result: The Ad Hoc Editor window appears
d. In the Fields panel, expand Products and drag the Brand field into the Columns box
e. Point to the Save menu and select Save Ad Hoc View and Create Report
f. To the Training folder, save the view as Security View and the report as Security
Report
173
6.
7.
a. View the more recent entries in the log file. The following lines are of interest:
o JdbcBaseDataSet: the query being run against the database
o CommonDomainDataStrategy: the Domain query
o GroovyGenerator: the in-memory filter info
End Lab
174
Scenario
Management wants a report that lists all the stores and managers in one or more states of a country.
Because there are many stores, you need to filter results by country and state. The report needs two
input controlsone to select a country and one to choose one or more states or territories in that country.
Time
30 minutes
Instructions
#
1.
2.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
175
3.
a. Click the query button and then the Query designer button
b. Click the left-most drop-down and select the public schema
c.
d.
e.
f.
g.
176
4.
i.
j.
c. Select the state_list parameter and set the Default Value Expression to ["CA","WA"]
Result: A parse error occurs.
a. In the Report Inspector delete all bands except Title, Column Header, and Detail 1
d.
b.
c.
e.
f.
6.
Note: Ctrl-click to select the other bands and delete them simultaneously
From the Palette drag a Text Field element (not static text) to the Title band
Double-click the Text Field and edit it to: Store List Report
Note: dont forget the double quotation marks
Add all five fields to the Detail 1 band so they appear left to right in this order:
o store_name, store_manager, store_city, store_state, and store_country
Change the column header labels to Store, Manager, City, State, and Country
Style the title and column headers to your liking (bold, bigger, centered, etc)
Click the Preview button to test the report, selecting Use default for each parameter
177
#
1.
2.
Steps
Question:
Does the report have to be in
Designer mode before you
deploy it?
Answer:
Yesthe Repository Navigator
will not recognize the JRXML
file unless it is so.
c.
d.
e.
f.
g.
h.
i.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
178
3.
Answer:
We configured our parameters
with default values
a. Click the Add Input Control link to first add the country input control
b. Select Define an Input Control in the next step and click Next
c. Fill in the form as follows:
o Type: Single-select Query
o Prompt Text: Country
o Parameter Name: country (lower case; Parameter Name is case sensitive)
o Mandatory: check this box
d. Click Next to define the query
e. Leave Define a Query in the next step selected and click Next
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
179
f. Name: country_query
g. Click Next to link to the data source
This query retrieves all the
unique country names found in
the records of the store table.
There are three countries:
Canada, Mexico and USA
h. Choose Select data source from repository and click the Browse button
i. Select Organization > Analysis Components > Analysis Data Sources >
j.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
180
e.
f.
g.
h.
i.
Leave Define a Query in the next step selected and click Next
Name: state_query
Click Next to link to the data source
Choose Select data source from repository and click the Browse button
Select Organization > Analysis Components > Analysis Data Sources > Foodmart Data
Source JNDI
j. Click Next to define the query
k. Fill in the form as follows:
o Query language: SQL
o Query String (copy from the copyAndPaste file): SELECT DISTINCT store_state
FROM store WHERE store_country = $P{country} ORDER BY store_state
l. Click Save to move to the Set Parameter Values page
m. Enter the following text:
o Value Column: store_state
o Visible Columns: store_state
important: click the Add link at the right to save the Visible Columns text
#
1.
2.
Steps
a. Click the report title to run the report with your default parameter values
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
181
d. Click Apply to run the report and ensure the results are only for BC, Canada
e. Try these two examples to ensure the input controls work as intended
a. Country: Mexico State: Ctrl-click to select both Jalisco and Veracruz
b. Country: USA
State: select none and see what happens
End Lab
182
Scenario
You need to brand the layout of JasperReports Server following custom requirements:
40 minutes
Instructions
Task 1: Replace the Jaspersoft logo with a Jaspersoft University logo.
1.
#
Use Firefox for this
lab.
Upload a new logo
image to the server
Action
a.
b.
c.
d.
e.
f.
Steps
Make certain you use the Firefox browser with Firebug for this lab
Log into JasperReports Server as superuser
Expand the root of the repository and find the Themes folder near the bottom
Right-click the folder name Themes and select Add Folder
Assign any name you like to the new theme folder
Right-click the new theme folder and again select Add Folder
183
j.
Back in the Add File window, down in the Resource ID text box,
enter the string training_logo.png
k. Above, in the Name field, enter Training Logo
Open Firebug
a. From the Firefox Tools menu select Web Developer > Firebug > Open Firebug
Firebug opens at the bottom of the browser
Note: Firebug is a web development utility that helps you find the files
and style rules you edit to update the user interface
3.
a. Near the far left of the Firebug menu, click the Element Inspect button
b. Move the cursor slowly over the different regions of the login page. Notice that Firebug instantly
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
184
Determine the style rule a. At the top left of the login page, move the cursor onto the very bottom border of the Jaspersoft
that governs the logo
logo image until the blue selection rectangle surrounds the logo, then click the mouse
image.
b. In the lower-right panel of Firebug, drag to select the #logo style rule
Copy and paste it into a
blank text file called
overrides_custom.css
5.
a. In the overrides_custom.css file, perform the following edits to the #logo style rule:
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
185
b. Make sure all declaration lines end with a semi-colon, like in this screen shot:
c. Save the file (keep Notepad++ open because youll edit the file again soon)
6.
a.
b.
c.
d.
e.
7.
a. Right-click your theme folder name and select Set as Active Theme
Result: Your new logo appears at the top of the page as shown below
Notice that the other user interface elements in the banner automatically shifted to the right to
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
186
b. Log out and view the logo on the login page, too
8.
e. Copy this CSS rule and paste it into the overrides_custom.css file, below the #logo rule
f. Increase the value of the height attribute to 35px
187
9.
d. Copy and paste the #frame CSS rule below the .banner rule in the overrides_custom.css file
e. Increase the value of the top attribute to 40px
f. Save the overrides_custom.css file
10 Upload the updated
CSS file
a.
b.
c.
d.
e.
f.
188
Action
1. Open the file
login.jsp
Steps
Note: Take a moment to glance up and down this file and notice that the code= syntax is used often to
reference strings of text you edit when you modify the user interface
a. Navigate to the WEB-INF/ bundles directory and open the file jasperserver_messages.properties
b. Use Ctrl-F to find the line with LOGIN_WELCOME_OS
c. Edit the right side of the equals sign to Welcome to Jaspersoft University
d. Save and close this file, and close the login.jsp file if its still open
3. Stop and start the a. Log out of JasperReports Server
server to view the b. Stop and restart the server wait a few seconds between stopping and restarting
updated page
189
Add another
style rule to the
CSS file
c. Move the cursor up to the Welcome message until the blue rectangle surrounds the text, then click
d. In the lower-right pane, click and drag to select this elements style rule
e. Copy the style rule and paste it below the other CSS rules in overrides_custom.css
f. Edit the rule as follows:
o font-size: 28px;
o font-weight: bold;
o add a fifth line at the bottom that says color: #EF9C00; (two zeros at the end)
g. The second style rule should now look like this:
190
g. Press the Submit button to save your work and return to repository view
h. Log out and view your updated orange-colored login page welcome message
191
Task 3: Hide all of the items beneath the login pages big graphic.
Action
Steps
192
d. In the lower-right panel, notice the corresponding style rule shown below, which pertains to
the primary class and the secondary class. It controls both columns
e. In the lower-right panel, click and drag to highlight this style rule
f. Copy and paste the rule after the other rules in the CSS file
g. Add a line at the bottom of the rule that reads display: none;
Note: display:none hides an element from view, and this will hide both columns
a.
b.
c.
d.
e.
f.
g.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
193
Action
1. Remove the languages that
Jaspersoft University will not
support
Steps
d. Check carefully for typos, then Save and close the file
Note: Youll view this change after completing Task 5 below
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
194
Action
1. We have to edit three text
files to add a submenu item
to a menu
Steps
f. Typos may cause the lab to fail, so check everything very carefully, then Save the file
2. The second file is
WEB-INF / bundles /
jasperserver_messages.propertie
s
d. A typo may cause the lab to fail, so double check and then Save this file
a. Open the third file, at
jasperserver-pro/ scripts/ actionModel.primaryNavigation.js
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
195
actionModel.
primaryNavigation.js
b. The first twenty lines are comments. Use the cursor to create a few more empty lines between
the closing comment tag and the var primaryNavModule line
c. In that space, add this line of JavaScript code (copy it from the copyAndPaste file)
var customMenuHandler = function(url) {window.location.href = url ; } ;
a. Stop and restart the server; wait a few seconds between stopping and restarting
b. Refresh the browser to view the new login page and the reduced number of languages
available in the Locale list
c. Log in as any user to examine the modified View menu
End of Labs
196
Scenario
Your company stores customer data on multiple systems. In anticipation of the various ETL tasks you
expect to be assigned, you create a project. Within your projects repository, you create connection
metadata for two table schemas and one generic schema.
Time
10 minutes
Note: JasperReports Server must be running.
Instructions
Task 1: Open and configure a new Jaspersoft ETL project.
#
Action
Steps
1. Open Jaspersoft ETL
a. Make sure the server is running
b. Start Jaspersoft ETL
o Live Online (remote) students can double-click their desktop shortcut
o Classroom students, navigate to C:\JETLPlus-r78327-V5.0.2 and
double-click on JETLPlus-win32-x86
197
Note: When you need additional connections (not now), click the Add button
198
a. In the Action section select Create a new local project and click Go!
b. In the New project window enter the following values:
o Project name: training
c. Click Finish to return to the start window
a. Ensure training java is selected in the Project drop-down box, and click Open
Note: The window title reflects the project name and the connection name.
Result: Over the next minute or two you may see a Generation Engine
Initialization in progress dialog in front
b. Click the Start now! button near the bottom of the window
199
a. From the main menu select File > Edit Project properties
b. Expand Designer and select Palette Settings
Question 1.1
Which FTP commands
does Jaspersoft ETL
support?
c. Remove the following components from the Show pane (we dont use them when
creating a job)
o Business Intelligence
o Business
o Talend MDM
Note: To remove components, select them in the right pane and click the left-arrow
button to move them to the left (you can hold down the Ctrl key to multi-select)
d. Click OK to save your changes and exit that window
#
1
200
|
g. Click the Check button to test your connection
h. If the test fails, look carefully for typos
i. Click OK and Finish
2
Question 1.3
The database type BIT is
mapped to which Java
type?
201
d. Click Next and Finish to accept the auto-detected schema for both tables
3 Create a generic schema and a. Again under the Repository tab and Metadata, right-click Generic schemas and
define the six columns to
select Create generic schema
which you will load the data
b. In the Create new generic schema window, add the following information:
in lab 2.
o Name: customerList
o Click Next
o Name: delete any text already there and enter customerList
c. Click Add (the green plus sign) six (6) times so you can define six columns
o Enter these six column names and lengths; change nothing else
d. Click Finish
Result: customerList appears under Generic schemas
End Lab
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
202
Your company stores customer data in multiple systems. For US-only mailing events your marketing
department requested a quarterly up-to-date list of customers who purchased fewer than 200 units and
opportunities that were successfully closed as new business.
The mailing is outsourced to three different providers with different requirements:
Goal
Design an ETL job that extracts data from the foodmart database, transforms the data, and loads it into
the required output formats.
Time
40 minutes
203
Instructions
#
1.
2.
d. Click OK
e. Repeat steps b-d for the customer_sales table
f. In the search box at the top of the Palette pane, enter tMap and click the flashlight
S-l-o-w-l-y double-click row1 (Main) in the center of the flow arrow and change the
name to customer
Drag and drop another Main data flow from customer_sales to the tMap component
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
204
l. Search the Palette for tLogRow, and drag that component onto the designer
m. Double-click the tLogRow_1 component
Result: The Basic settings section of the Component tab is activated down below
n. In the Schema drop-down box, select Repository
205
q.
r.
s.
t.
Click OK
Right-click tMap_1, select Row > *New Output* (Main), and connect to tLogRow_1
In the window, enter the name customerList and click OK
Select Yes in the second window that concerns getting the schema of the target
3.
206
i.
j.
To connect the other columns, drag and drop these customer fields to the
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
207
o
o
o
o
o
k. Click Ok to close the map componentsay Yes if you see the propagate window
4.
208
5.
c. On the customerList bar at the right, click the expression filter button
d. From the sales_data table at the left, drag and drop the store_sales column into the
customerList expression box
o An orange connect arrow appears to help you visualize the condition
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
209
e. Click the edit button to open the expression editor and complete the expression so
that sales_data.store_sales < 200, and click Ok
o or you can enter the text < 200 directly in the window
f. At the left, expand the customer table so you can view all the Column names
6.
Because the tMap_1 component is now filtering on two criteria, the result set is
reduced to about 4,800
210
7.
a. In the Palette search field, enter the word sort and hit your Enter key to search
b. Drag and drop the tSortRow component where tLogRow used to be
c. To direct the main data output to the tSortRow_1 component, right-click tMap_1 and
select Row > customerList, and connect it to the tSortRow_1 component
d. Double-click tSortRow_1 to activate the Component tab in the properties panel
e. In the Schema drop-down box select Repository
f. Once again click the edit button
8.
a. Drag a new tMap component from the Palette to the job design (search for tMap)
b. Right-click and drag a main data row from tSortRow_1 to tMap_2
c. Double-click and rename the data row customers
211
9.
a. Drag and drop the tFileOutputExcel component from the Palette to the job design
(search for it)
b. Double-click tFileOutputExcel_1 to activate the Component tab down below
c. In the Basic settings section, enter these values (or copy from copyAndPaste.txt):
o File Name: "C:/JETLPlus-r78327-V5.0.2/workspace/CA.xls"
(include double quotation marks and use forward slashes)
o Sheet name: customers (include double quotation marks; all lower case)
o Include header: (checked)
o Scroll to the bottom and specify Schema: Repository
o Click the Schema edit button , expand Generic schemas > customerList 0.1
o select customerList and click OK
o Leave everything else at their default values
d. Right-click tMap_2, select Row > *New output* (Main), and connect to
tFileOutputExcel_1
e. In the window, enter CA_customers
f. Click OK, then Yes to the schema window
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
212
c. In the Basic settings section enter these values (or copy from copyAndPaste.txt):
o File Name: "C:/JETLPlus-r78327-V5.0.2/workspace/WA.xls"
(include double quotation marks)
o Sheet name: WA (include double quotation marks)
o Include header: (checked)
o Append existing file: (checked)
o Schema: Repository
o Click the button and drill down to
Generic schemas > customerList 0.1 > customerList
o Leave everything else at their default values
d. Right-click tMap_2, select Row > *New output* (Main) and connect to
tFileOutputExcel_2
e. In the window, enter WA_customers
f. Click OK, then Yes to the schema window
11. Configure the CSV output
for all other customers
213
c. At the upper right, if the title band of the CA_customers table is not yellow
(indicating its the active table), then click its title band to select CA_customers
d. At the upper-right, click the
display the condition editor
214
Answer: The tLogRow component echoes output to the Run window. That
component was in the job, but is no longer part of the job.
End Labs
215
Which commands can be executed via FTP using Jaspersoft ETL standard components?
Connect, Delete, FileExists, FileList, FileProperties, Get, Put, Rename, Truncate
Navigate to Project Settings > Designer > Palette Settings. On the left side navigate to Internet >
FTP. You use some other components in the next labs.
Answer 1.2
Answer 1.3
216
Scenario
You need to explore a sample view written for the Foodmart sample data.
Time
10 minutes
Instructions
Steps
a. Log into JasperReports Server as jasperadmin / jasperadmin
a. In the search field at the upper right, enter Foodmart Sample and search on it
b. Click the title of Foodmart Sample Analysis View to open the view
3.
a. Examine the filter message displayed at the lower left of the view
o The default view displays information only for December of 2006
Question 1.1
What filter is shown?
217
Steps
a. Click to expand All Media
Question 1.2
Which columns are from
the fact table? Which are
dimensions?
2. Expand All Products
a. Expand the top All Products (adjacent to the top All Media)
218
Steps
a.
b.
c.
d.
e.
From the icon list at the left, select the Change Data icon
Click the Measures link (under Columns) to view available measures
Select or deselect a measure or two
Press the OK button, then the OK button again to save and view changes
Log out of JasperReports Server and close the browser
End
219
Scenario
You need to create and manipulate an OLAP schema that contains one cube with three dimensions
Time
20 minutes
Instructions
Task 1: Create two dimensionsstore name and customer location.
#
Action
Steps
1. Open Jasper Workbench
a. Double-click the Jaspersoft OLAP Workbench shortcut on the desktop
o The Jaspersoft image appears in the window after the Workbench starts.
The tool is open and ready to use.
2.
Connection to Foodmart db
3.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
220
5.
a. In the left panel click New Schema 1 to highlight it (the name may vary)
b. In the main panel assign the name: FoodMart_Schema1
6.
Question 2.1:
After this step, why do you
receive an error?
Look at the error at the
bottom of the screen.
7.
h. In the right panel click the primaryKey drop-down and select store_id
i. click the allMemberName value field and type All Stores
a. Left panel: Right-click on default and select Add Level
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
221
in the hierarchy
b.
c.
d.
e.
Right panel: Click the name value field and replace New Level 0 with store
Press the Enter key
Right panel: Click the column drop-down and select store_name
Right panel: Check the uniqueMembers check box
(Note: that should make most of the red Xs at the left vanish)
8.
9.
Question 2.2:
Why click the top-level
Schema tree item before
creating this dimension?
222
i.
j.
10. Add a level for Country to
the hierarchy
a. Left panel: Right-click on the Customer Location default and select Add Level
b. Right panel: Change the name value to State-Province
c. Right panel: Click the column drop-down and select state_province
d. Right panel: Check the uniqueMembers check box
e. Right panel: Assign a type of String
a. Left panel: Right-click on Customer Location default and select Add Level
b. Right panel: Update the name value to City
c. Right panel: Click the column drop-down and select city
d. Right panel: Assign the type of String
e. From the main menu, select File > Save to save work so far
223
Scenario
The cube needs three dimensions, including a special type called a Time dimension.
Time
10 minutes
Instructions
#
1.
2.
c.
d.
e.
f.
g.
h.
i.
a.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
224
3.
hierarchy
b. Right panel:
o Change the name to Year
o Set the column value to the_year
o Check the uniqueMembers check box
o Set the type to Numeric
o Set levelType to TimeYears
Question 3.1:
What is the difference
between ordinalColumn
and nameColumn?
4.
Save schema
5.
a.
b.
c.
d.
End
225
Define a cube that includes the three dimensions and one fact table
Scenario
The pieces are in place; now assemble a cube that includes the three dimensions and a fact table
Time
25 minutes
Instructions
#
1.
Task 1: Assemble a cube from the three dimensions and a fact table.
Action
Steps
Create a cube under the
a. At the top of the left panel, click to select FoodMart_Schema1
schema
b. Toolbar: Click the Add cube button
2.
Add a Dimension Usage for a. Left panel: Right-click on Customer_Cube and select Add Dimension Usage
Store Name to the hierarchy b. Right panel: Set the name to Store Name
c. Right panel: set foreignKey to store_id
d. Right panel: Set source to Store Name
Question 4.1: What is a
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
226
dimension usage?
Question 4.2: Does the
source value need to match
the name value?
3.
4.
5.
6.
Save schema
7.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
227
8.
item
9.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
228
Question 4.4
What did this MDX query
return?
229
Scenario
The cube is ready to go. Configure Jaspersoft OLAP and create two Views to see some data
Time
30 minutes
Instructions
Task 1: Make the cube available for OLAP analysis
#
Action
Steps
1. Log into
Log into JasperReports Server as jasperadmin / jasperadmin
JasperReports
Server
2. Make certain
a. From the main menu select View > Repository
the Foodmart
b. In folders view expand the Organization folder
Data Source is
c. Expand Analysis Components and click directly on the
working
Analysis Data Sources folder to select it
properly
d. At the right, right-click on Foodmart Data Source and select Edit
e. Scroll down to click the Test Connection button near the bottom left, and verify the
Connection passed message appears at the top of the window
230
3. Publish the
OLAP Schema
Note: Name
field CANNOT
have spaces
4. Create a
Mondrian
Connection
a. In the Analysis Components folder, right-click on the Analysis Schemas folder name and
select Add Resource > File > OLAP Schema
b. Under Path to File, browse to select the FoodMart_Schema1.xml file you created in Labs 2
4 (it may be in the My Documents folder)
c. Set the following property:
Name: Foodmart Example Schema
The Resource ID field fills automatically with Foodmart_Example_Schema
d. Click Submit
a. Back on the repository page, under Analysis Components right-click on the Analysis
Connections folder and select Add Resource > OLAP Client Connection
b. Ensure the Mondrian type is selected
c. Set the following property:
Name: Foodmart Example Connection
Resource ID fills automatically with Foodmart_Example_Connection
d. Click Next
e. Click Select a resource from the Repository, click the Browse button and select
Organization > Analysis Components > Analysis Schemas > Foodmart Example Schema
f. Click Next , and click Next again to skip the OLP Schema Resource page
g. Click Select a Data Source from the repository
h. Click the Browse button and select Organization > Analysis Components > Analysis Data
Sources > Foodmart Data Source
i. Click Next, and click Next again to skip the Locate Access Grand Definition page and save
edits, and return to repository page
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
231
Task 2: Create two Views: Foodmart Example by Store and Foodmart Example by CA Customer
#
Action
Steps
1. Create View #1: a. On the repository page, under Analysis Components, right-click on the Analysis Views
Foodmart
folder and select Add Resource > OLAP View
Example by
b. Provide the values for the properties as follows:
Store
Name: Foodmart Example by Store
c. Click Next
d. Ensure the connection type is Mondrian Connection
e. Click Select a Mondrian Client Connection from the repository, click the Browse button,
and select Organization > Analysis Components >
Analysis Connections > Foodmart Example Connection
f. Click Next
g. Enter the following MDX query (or copy it from the copyAndPaste file)
SELECT
{[Measures].[Store Cost]} ON COLUMNS,
{[Store Name].[All Stores]} ON ROWS
FROM [Customer_Cube]
h. Click Submit
i. The system alerts you of any typos in the query
2. Create View #2: a. Back in the Folders view, under Analysis Components, right-click on the Analysis Views
folder and again select Add Resource > OLAP View
Foodmart
Example by
Name the view Foodmart Example by CA Customer
CA Customer
c. Click Next
d. Ensure the connection type is Mondrian Connection
e. Click Select a Mondrian Client Connection from the repository
f. Click the Browse button and select Organization > Analysis Components >
COPYRIGHT 2013 JASPERSOFT CORP. ALL RIGHTS RESERVED.
NO PART OF THIS DOCUMENT MAY BE REPRODUCED , STORED IN A RETRIEVAL SYSTEM, OR TRANSMITTED BY ANY MEANS WITHOUT WRITTEN PERMISSION FROM JASPERSOFT.
232
Click on the Analysis Views folder to display its contents in the Repository pane
4. Examine the
views
233
c. Click the Hide Empty Rows/Columns button to hide the empty rows
d. See the result on the next page
234
End Lab
235
Scenario
You need to restrict cube data for a specific user and a role.
Time
10 minutes
Instructions
#
1.
2.
Steps
Log into JasperReports Server as jasperadmin / jasperadmin
Select View > Repository
On the repository page, expand Organization > Analysis Components
Right-click on the Analysis Schemas folder and select
Add Resource > File > Access Grant Schema
d. Under Path to File, browse to the samples folder and select the
foodmart_access_grant.xml file
e. Click Open to select the file and return to the Add File window
f. Assign the name Foodmart Access Grant Schema
g. Click Submit
Note: The access grant file is now in the repository
236
3.
Configure the Mondrian
Connection to reference the
access security file
a. On the repository page, under the Analysis Components folder, click on the
Analysis Connections folder to select it
b. In the Repository pane, right-click on Foodmart Example Connection and
select Edit
c. Click Next four times to view the Locate Access Grant Definition window
d. Click Select a resource from the Repository
e. Browse to select Organization > Analysis Components >
Analysis Schemas > Foodmart Access Grant Schema
f. Click Next and Submit to save changes and exit the editor
4.
e. Likewise, if Store Name is not already under the Filters section, then
click the Move to Filter button next to the Store Name dimension
237
f. Click the OK button to save any changes and return to the regular view
g. Expand the CA State-Province dimension and note the dozens of CA city names
o The jasperadmin has permission to view all cities
h. From the main menu select Manage > Users
i.
Click on CaliforniaUser
j.
Near the middle of the Properties panel at the right, note the Profile Attributes
assigned to this user: [State:CA], [Cities:San Francisco, Oakland, San Jose]
Click the big View Reports button to view a list of reports in the repository
In the Filters panel at left, under All types, click More choices > OLAP Views
Open the Foodmart Example By CA Customer view again
Expand the CA State-Province dimension again and see how the AGXML
security file restricts access provided to this user
238
Answer 1.1
Answer 1.2
Identify which columns are from the fact table and which are dimensions.
The columns Unit Sales, Store Cost, and Store Sales represent measures from the fact table.
The columns All Media and Products are dimensions.
Answer 1.3
Answer 1.4
What are the Unit Sales for the Excel Monthly Computer Magazine?
11
Expand All Products > Non-Consumable > Periodicals > Magazines > Computer Magazines >
Excel
239
Answer 2.1
After this step, why did you receive an error? Look at the error at the bottom of the screen.
The Workbench tells you about errors in real time. In this case, you have not yet applied a level. At least
one level is mandatory under a hierarchy.
Answer 2.2
Why click the top-level Schema tree item before creating this dimension?
To tell the workbench that you are building a new dimension at the top level of the schema, not under
any element in the schema.
Answer 2.3
Answer 3.1
Answer 4.1
240
Answer 4.2
Answer 4.3
From where is the source drop down box getting its values?
These are the dimensions you created earlier.
Answer 4.4
241