轉-Pentaho技術白皮書中文版(四)--建立 dashboards

這篇文檔描述瞭如何使用 Pentaho BI 套件建立 dashboards。它描述了 Pentaho Demo 服務器提供的sample dashboard。 html

sample dashboard 以 JSP 和 PHP 形式提供。兩個 dashboards 均使用相同的內容,提供相同的功能。JSP 實例顯示瞭如何在 Pentaho UI 組件中使用 Java API,PHP 實例顯示瞭如何在 Pentaho UI 組件中使用 Web 服務。 java

Java API 實例可用於 JSPs,Servlets,或 Java 應用。Web 服務實例可用於可發佈 web 服務調用的任何技術,例如 PHP,IBM Domino 等。 git

1. Sample Dashboard web

This page last changed on Mar 01, 2007 by wgorman. sql

Sample Dashboard 位於這個 URL (假設你將 Pentaho demo 安裝於你本機的 8080 端口) 。http://localhost:8080/pentaho/jsp/SampleDashboard 數據庫

sample dashboard 首先顯示了一張餅圖,其顯示了四個區域中每一個的 headcount costs。 express

關於如何定義餅圖的更多信息請參考下面的 ‘Headcount Spending by Region Pie Chart’。 瀏覽器

關於如何得到餅圖的數據的更多信息請參考下面的 ‘Headcount Spending by Region Action Sequence’。 服務器

當用戶點擊餅圖上的一個切片時,出現了另外一張圖表,對於選中的區域的每一個部門,顯示了 headcount budget 和 actual cost 間的不一樣。 session

餅圖如何被定義的更多信息請參考下面的 ‘Headcount Variance Pie Chart’。

如何獲取餅圖的數據的更多信息請參考下面的 ‘Headcount Variance Action Sequence’。

當用戶點擊一個部門的 bar 時,dashboard 在圖表下,顯示了一個 dial 和一個數據表。dial 基於當前時間(所以它隨着時間改變) 顯示了一個值,表顯示了選中部門內的 positions 的詳細信息。

如何定義 dial 的更多信息請參考下面的 ‘動態 Dial’。

如何定義嵌入式報表的更多信息請參考下面的 ‘嵌入式報表’。

當用戶點擊表中的一個 position 的名字時,dashboard drills 到另外一個頁面,並傳送 region,department 和 position 做爲參數。

這一頁的源代碼請參考附錄 8:Drill JSP

2. 體系結構

This page last changed on Dec 04, 2006 by mdamour.

3. 內容定義

This page last changed on Dec 04, 2006 by mdamour.

動態 Dial

This page last changed on Dec 05, 2006 by mdamour.

這個 dial 的定義在 pentaho-demo/pentaho-solutions/samples/dashboard/sampledial.widget.xml

這個 XML 文件定義了:

 

設置

描述

widget/dial/units

units of dial value

$

widget/dial/plot-background/text

dial area 的 re-image 背景

/samples/portal/dial_03 .gif

widget/dial/tick-interval

gap between ticks

5

widget/dial/tick-color

ticks 的顏色

#808080

widget/dial/needle-color

Needle 的顏色

#808080

widget/dial/chart-background/texture-image

Background chart image

/samples/portal/dial_03 .gif

widget/dial/interval/label

Interval name

'under'

widget/dial/interval/minimum

Interval lower limit

-15

widget/dial/interval/maximum

Interval upper limit

0

widget/dial/interval/color

Interval background color

#FFFFFF

widget/dial/interval/text-color

Interval text and tick color

#40BB40

widget/dial/interval/stroke-width

Interval line thickness

5

 

注意在文件中定義了兩個 intervals:一個覆蓋了從 -15 到 0 的範圍,另外一個是 0 到 +15。

除了在 widget XML 文件中定義的這些設置,caller 還指定了這些設置:

 

設置

描述

title

dial 的標題

'My Dial'

value

Dial 上顯示的值

Varies over time from -10 to +15

image-width

dial image 的寬度

105

image-height

dial image 的高度

105

 

在 sample dashboard 中,基於當前時間,頁面爲 dial 建立了一個值。

嵌入式報表

This page last changed on Jan 30, 2007 by wgorman.

報表模版的定義在:pentaho-demo/pentaho-solutions/samples/dashboard/jsp/embedded_report.xml

報表模版被報表引擎(JFreeReport) 用於佈局嵌入式報表。你可以使用 Pentaho Report Wizard 設計一個報表定義。

你建立的是 HTML 的一個片斷,而不是一個完整的 HTML 頁面。你須要編輯報表定義 XML 文件以在 report/configuration 的報表配置區域添加一個屬性。

<property name="org.jfree.report.modules .output .table.html.BodyFragment">true</property>

爲將報表內容中的一個 drill link 添加進一個 URL,你須要編輯報表定義,並添加一個 URL 表達式,例如 sample dashboard 中的這個。

<expression name="URLCreateExpression"

class="org. jfree.report.function.TextFormatExpression">

<properties>

<property

name="pattern">SampleDrill? region={ 0} &amp;position={ 1} &amp; department={ 2} </property>

<property name="field[ 0] ">REGION</property>

<property name="field[ 1] ">POSITIONTITLE</property> <property name="field[ 2]">DEPARTMENT</property>

</properties>

</expression>

Headcount Spending By Region Pie Chart

This page last changed on Jan 30, 2007 by wgorman.

這張餅圖的定義在: pentaho-demo/pentaho-solutions/samples/dashboard/regions.widget.xml

這個 XML 文件定義了:

設置

描述

chart/title

圖的標題

Headcount Spending by Region

chart/title-position

圖的標題的位置(上,下,左或右)

top

chart/title-font/font-family

標題字體的名字

Ariel

chart/title-font/size

標題字體的大小

20

chart/title-font/is-bold

標題字體是粗體麼?

false

chart/title-font/is-italic

標題字體是斜體麼?

false

chart/is-3D

餅圖是 3D 的麼?

false

chart/border-visible

Does chart have a border?

false

chart/include-legend

Does chart have a legend?

false

chart/data/data-solution

solution for action sequence providing data for this chart

samples

chart/data/data-path

action sequence 的路徑

dashboard

chart/data/data-action

action sequence 的名字

regions_headcount_data.xaction

chart/data/data-output

action sequence 輸出

rule-result

chart/data/data-name

包含 pie slice 名稱的數據列

REGION

chart/data/data-value

包含 pie slice 值的數據列

ACTUAL

chart/data/data-orientation

direction in which to process data to get pie slices (rows/columns)

rows

 

除了 widget XML 中定義的這些設置,調用者還可指定這些設置:

 

設置

描述

drill-url

用於生成 drill 路徑的一個 URL 模版。URL 可有包含在 ‘{‘ and ‘}’中的可替換參數。

SampleDashboard?region={REGION}

inner-param

在 URL 中包含將被替換的值的數據列

 

REGION

chart 組件從這個文件中讀取全部的設置,而後執行指定的 action sequence 爲圖表獲取數據。sample dashboard 中的 action sequences 僅使用一個單一的組件生成數據,可是 BI 組件的任何序列可用來執行復雜的(例如 scripting 或 in-line ETL) 或遠程的(例如 Web 服務) 任務。

Headcount Variance Bar Chart

This page last changed on Jan 30, 2007 by wgorman.

這個 bar chart 的定義在:

pentaho-demo/pentaho-solutions/samples/dashboard/departments.widget.xml

這個 XML 文件定義了:

 

 

設置

描述

 

chart/type

圖的類型(BarChart, LineChart, AreaChart)

BarChart

 

chart/title

圖的標題

Headcount Variance

 

chart/title-position

圖的標題的位置(上,下,左,右)

top

 

chart/title-font/font-family

標題字體的名字

Ariel

 

chart/title-font/size

標題字體的大小

20

 

chart/title-font/is-bold

圖的標題是粗體麼?

false

 

chart/title-font/is-italic

圖的標題是斜體麼?

false

 

chart/is-3D

圖是 3D 的麼?

false

 

chart/border-visible

Does chart have a border?

false

 

chart/include-legend

Does chart have a legend?

false

 

chart/chart-background

chart image 的背景。你可定義gradients, textures,images 或flat colors

type=color #FFFFFF

 

chart/plot-background

plot area 的背景

type=color #EEEEEE

 

chart/orientation

chart 的方向(垂直或水平)

horizontal

 

chart/is-stacked

Is chart stacked?

false

 

chart/color-palette/color

color to use for first series

#336699

 

chart/color-palette/color

color to use for second series

#99CCFF

 

chart/data/data-solution

solution for action sequence providing data for this chart

Samples

 

chart/data/data-path

action sequence 的路徑

dashboard

 

chart/data/data-action

action sequence 的名字

regions_headcount_data.xaction

chart/data/data-output

action sequence 的輸出

rule-result

 

chart/data/data-name

包含 pie slice names 的數據列

REGION

 

chart/data/data-value

包含 pie slice values 的數據列

ACTUAL

 

chart/data/data-orientation

direction in which to process data to get pie slices (rows/columns)

rows

 

             

 

除了在 widget XML 文件中定義的這些設置,caller 還指定了這些設置:

設置

描述

drill-url

一個 URL 模版用於生成 drill 路徑。URL 可有包含在 ‘{‘ and ‘)’ 中的可替換的參數

SampleDashboard?region=Central&

inner-param

data column containing values to be replaced in URL

DEPARTMENT

REGION

在查詢中用來選擇數據的過濾器

Dynamically set e.g. 'Eastern'

image-width

chart image 的寬度

450

image-height

chart image 的高度

300

REGION 參數被傳送進 action sequence 用做一個查詢查詢過濾器。

4. Action Sequences

This page last changed on Dec 04, 2006 by mdamour.

嵌入式報表 Action Sequence

This page last changed on Dec 04, 2006 by mdamour.

這個報表的定義在: pentaho-demo/pentaho-solutions/samples/dashboard/jsp/embedded_report.xaction

你能夠在 Eclipse IDE 中使用 Pentaho Design Studio 編輯這個文件。這個 action sequence 包含一個 JFree Report 組件,其從 sample 數據庫獲取數據,使用一個報表模版生成一個HTML 片斷。

action sequence 帶有參數 ‘region’ 和 ‘department’,其用做查詢中的過濾器。報表組件執行這個查詢:

select QUADRANT _ACTUALS . REGION, QUADRANT _ACTUALS . DEPARTMENT, QUADRANT _ACTUALS . POSITIONTITLE,

QUADRANT _ACTUALS . ACTUAL, QUADRANT _ACTUALS . BUDGET,QUADRANT _ACTUALS.VARIANCE

from QUADRANT _ACTUALS

where QUADRANT _ACTUALS.REGION = '{region}'

and QUADRANT _ACTUALS.DEPARTMENT = '{department}'

order by QUADRANT _ACTUALS.REGION, QUADRANT_ACTUALS. DEPARTMENT

使用一個報表模板:pentaho-demo/pentaho-solutions/samples/dashboard/jsp/embedded_report.xml (參考上面的嵌入式報表)

報表組件在一個名爲 ‘report’ 的輸出中返回 HTML,action sequence 將這個輸出轉向到 response 的 output stream。

Headcount Spending by Region Action Sequence

This page last changed on Dec 04, 2006 by mdamour.

這個 action sequence 的定義在: pentaho-demo/pentaho-solutions/samples/dashboard/regions_headcount_data .xaction

你能夠在 Eclipse IDE 中使用 Pentaho Design Studio 以編輯這個文件。

這個 action sequence 包含一個 SQL Query Rule,其從 Pentaho demo 服務器提供的 sample 數據庫獲取一些數據。action sequence 不帶任何參數。

SQL Query Rule 執行這個查詢:

select REGION, sum(ACTUAL) as ACTUAL

from quadrant _actuals

group by REGION order by ACTUAL

並在一個名爲 ‘rule-result’ 的輸出中返回數據。這個數據用於生成 ‘Headcount Spending By Region’ 餅圖。

Headcount Variance Action Sequence

This page last changed on Dec 04, 2006 by mdamour.

這個 action sequence 的定義在:pentaho-demo/pentaho-solutions/samples/dashboard/department_variance_data .xaction

你能夠在 Eclipse IDE 中使用 Pentaho Design Studio 以編輯這個文件。

這個 action sequence 包含一個 SQL Query Rule,其從 Pentaho demo 服務器提供的 sample 數據庫獲取一些數據。

action sequence 帶有一個參數 REGION,其在查詢中用做過濾器,SQL Query Rule 執行這個查詢:

select department, sum(variance) from quadrant _actuals

where region='{ REGION}'

group by department

在名爲 ‘rule-result’ 的輸出中返回數據。這個數據用於生成 ‘Headcount Variance By Region’ 餅圖。

5. 定製 PCI JSP Dashboard

This page last changed on Feb 01, 2007 by wgorman.

實例 1: 將餅圖變成柱狀圖

這個實例描述了在 SampleDashboard solution 中,將一個餅圖轉換成一個柱狀圖所須要進行的修改。爲了修改,必須同時更新 widget xml 和 SampleDashboard.jsp 中的 java 代碼。

步驟 1: 更新 SampleDashboard. jsp 文件

不要調用 ChartHelper.doPieChart(),而是對 ChartHelper.doChart() 進行 java調用。方法標識是同樣的, 包括 widget xml 的位置,可定製參數,輸出要寫進的 string buffer,user session,存儲消息的 messages 對象,和一個 logger 對象(若是可用)。

修改 widget.xml 指向咱們的新 _regions.widget.xml 文件,其在下一步被建立。

柱狀圖稍不一樣於餅圖,當涉及到它們的 templated inner param 時。用 "{SERIES}" 替換 "drill-url" 參數的 "{REGIONS}" 部分,其容許圖表適當生成 outgoing 連接。

步驟 2: 建立 new_regions .widget.xml 文件

餅圖和柱狀圖 <chart> xml 文件包含用於定製的不一樣參數集合。不須要檢查全部參數,將departments .widget.xml 複製到新的 _regions.widget.xml文件,其是一個預存在的柱狀圖實例。

注意 chart-type 元素,以及各類用於定製柱狀圖的 style 元素。將 title 元素修改回 "Headcount Spending by Region",data -> data-action 元素修改回 "regions_headcount_data.xaction"。如今咱們就有一個配置好的柱狀圖了。

注意:你必須在 admin 工具中刷新 solution repository,使得對於 widget 的修改生效。

實例 2: Swapping Regions 和 Departments

這個實例描述了在 dashboard 中 swapping regions with departments。

步驟 1: 更新 SampleDashboard.jsp 文件

若是你從上面的實例 1 開始操做的,從實例中刪除對於 JSP 的修改。

替換這段代碼:

String title = "Select a region";

if( department != null ) {

title = "This is headcount spending for " + region + ", " + department;

}

else if ( region != null ) {

title = "This is headcount spending for " + region;

}

用這段代碼:

String title = "Select a department";

if( region != null ) {

title = "This is headcount spending for " + department + ", " + region;

}

else if ( department != null ) {

title = "This is headcount spending for " + department;

}

爲將 region pie chart 改爲 departments:

用 "Select a Department By Clicking on Pie Chart" 替換 "Select a Region By Clicking on Pie Chart"。

用 "SampleDashboard?department= {DEPARTMENT}" 替換 "SampleDashboard?region ={REGION}"。

替換這行:

parameters.setParameter( "inner-param", "REGION");

用:

parameters.setParameter( "inner-param", "DEPARTMENT");

用 "new_departments.widget.xml" 替換 "regions.widget.xml"。

爲將 department bar chart 改變成 regions:

替換這行:

if( region != null ) {

用:

if( department != null ) {

用 "Select a Region By Clicking on Bar Chart" 替換 "Select a Department By Clicking on Bar Chart "。

替換這行:

parameters. setParameter ( "drill-url", "SampleDashboard? region="+region+"&department={ SERIES}" );

用:

parameters. setParameter ( "drill-url",

"SampleDashboard? department="+department+"&region={ SERIES} " );

替換這行:

parameters.setParameter( "REGION", region );

用:

parameters.setParameter( "DEPARTMENT", department );

替換這行:

parameters.setParameter( "outer-params", "REGION" );

用:

parameters. setParameter ( "outer-params", "DEPARTMENT" );

替換這行:

parameters.setParameter( "inner-param", "DEPARTMENT");

用:

parameters.setParameter( "inner-param", "REGION");

用 "new_regions.widget.xml" 替換 "departments.widget.xml"。

替換包含這句的兩行:

if( department != null ) {

用:

if( region != null ) {

步驟 2: 建立 new_departments.widget.xml 文件

複製 regions.widget.xml 文件成新的 _departments.widget.xml。

用 "Headcount Spending by Department" 替換 "Headcount Spending by Region"。

用 "departments_headcount_data.xaction" 替換 "regions_headcount_data .xaction"。

替換這句:

<data-name>REGION< / data-name>

用:

<data-name> DEPARTMENT< / data-name>

步驟 3: 建立 departments_headcou nt_data.xaction 文件

複製 regions _headcount _data.xaction 文件成 departments _headcount _data.xaction。

用 "Return actual headcount costs total for each department" 替換 "Return actual headcount costs total for each region"。

替換 SQL 查詢:

select REGION, sum(ACTUAL) as ACTUAL from QUADRANT _ACTUALS group by REGION order by ACTUAL

用:

select DEPARTMENT, sum(ACTUAL) as ACTUAL from QUADRANT _ACTUALS group by DEPARTMENT order by ACTUAL

步驟 4: 建立 new_regions.widget.xml 文件

將文件 departments.widget.xml 複製成新的 _regions.widget.xml 文件。替換這句:

<data-action>department _variance _data. xaction</data-action>

用:

<data-action>region _variance _data. xaction</data-action>

步驟 5: 建立 region_variance_data.xaction 文件

複製 department _variance _data.xaction 文件成 region _variance _data.xaction。

用 "Return variance between headcount actual and budget for every region in specified department" 替換 "Return variance between headcount actual and budget for every department inspecified region"。

替換:

<inputs>

<REGION type="string">

<sources>

<request>REGION</request></ sources>

</REGION>

</inputs>

用:

<inputs>

<DEPARTMENT type="string">

<sources>

<request>DEPARTMENT< /request> </ sources>

</DEPARTMENT>

</inputs>

用 "Define an input called 'DEPARTMENT'." 替換 "Define an input called 'REGION'."。

替換

<REGION type="string"/>

用:

<DEPARTMENT type="string"/>

替換 SQL 查詢:

select department, sum(variance) from QUADRANT _ACTUALS where region in ( {PREPARE:REGION} )

group by department

用:

select region, sum(variance) from QUADRANT _ACTUALS where department in ( {PREPARE:DEPARTMENT} ) group by region

附錄01 Dashboard JSP

This page last changed on Jan 30, 2007 by wgorman.

這是 JSP Sample Dashboard 的源代碼:

<%@ page language="java"

import="java.util.ArrayList,

java.util.Date,

java.io.ByteArrayOutputStream,

org.pentaho.core.ui.SimpleUrlFactory,

org.pentaho.messages.Messages,

org.pentaho.core.system.PentahoSystem,

org.pentaho.ui.component.DashboardWidgetComponent,

org. pentaho.core. solution. HttpRequestParameterProvider, org.pentaho.core.solution.HttpSessionParameterProvider,

org.pentaho.core.session.IPentahoSession,

org.pentaho.core.util.UIUtil,

org.pentaho.util.VersionHelper,

org.pentaho.messages.util.LocaleHelper,

org.pentaho.core.solution.ActionResource,

org.pentaho.core.solution.IActionResource,

org.pentaho .core. solution. SimpleParameterProvider, org.pentaho.ui.ChartHelper,

java. io .*"

%><%

/*

*    Copyright 2006 Pentaho Corporation. All rights reserved.

*    This software was developed by Pentaho Corporation and is provided under the terms

*    of the Mozilla Public License, Version 1.1, or any later version. You may not use

*    this file except in compliance with the license. If you need a copy of the license,

*    please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho

*    BI Platform. The Initial Developer is Pentaho Corporation.

*

*    Software distributed under the Mozilla Public License is distributed on an "AS IS"

*    basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to

*    the license for the specific language governing your rights and limitations.

*

*    Created Feb 16, 2006

*    @author James Dixon

*/

/*

*    This JSP is an example of how to use Pentaho components to build a dashboard.

*    The script in this file controls the layout and content generation of the dashboard.

*    See the document 'Dashboard Builder Guide' for more details

*/

// set the character encoding e.g. UFT-8

response. setCharacterEncoding (LocaleHelper.getSystemEncoding ());

// get the current Pentaho session or create a new one if needed

IPentahoSession userSession = UIUtil.getPentahoSession( request );

%>

<html>

<head>

<title>Pentaho Sample Dashboard - JSP</title>

</head> <body>

<%

// See if we have a 'department' parameter String department = request.getParameter ("department"); // See if we have a 'region' parameter

String region = request.getParameter("region");

// Create the title for the top of the page

String title = "Select a region"; if( department != null ) {

title = "This is headcount spending for " + region + ", " + department;

}

else if ( region != null ) {

title = "This is headcount spending for " + region;

}

%>

<h1 style='font-family:Arial'><%= title %></h1>

<table>

<tr>

<td valign="top"><span style="font-family:Arial; font-weight :bold">Select a Region By Clicking on the Pie Chart</span>

<%

// Make a pie chart showing the regions // create the parameres for the pie chart

SimpleParameterProvider parameters = new SimpleParameterProvider();

// define the click url template

parameters.setParameter( "drill-url", "SampleDashboard?region={ REGION} " );

// define the slices of the pie chart

parameters. setParameter ( "inner-param", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$

// set the width and the height

parameters. setParameter ( "image-width", "450") ; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter( "image-height", "300"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content = new StringBuffer();

ArrayList messages = new ArrayList();

// call the chart helper to generate the pie chart image and to get the HTML

content

// use the chart definition in 'samples/dashboard/regions.widget.xml' ChartHelper.doPieChart ( "samples", "dashboard", "regions .widget.xml", parameters, content, userSession, messages, null );

%>

<%= content.toString() %>

</td>

<td valign="top"><span style="font-family:Arial; font-weight :bold">

<%

if( region != null ) {

// if the user has clicked on a slice of the pie chart we should have a

region to work with

%>

Select a Department By Clicking on the Bar Chart

<%

// Make a bar chart showing the department

// create the parameres for the bar chart

parameters = new SimpleParameterProvider();

// define the click url template

parameters. setParameter ( "drill-url",

"SampleDashboard? region="+region+"&amp; department={ SERIES} " );

parameters.setParameter( "REGION", region );

parameters.setParameter( "outer-params", "REGION" );

// define the category axis of the bar chart

parameters. setParameter ( "inner-param", "DEPARTMENT"); //$NON-NLS-1$

// $NON-NLS-2 $

// set the width and the height

parameters. setParameter ( "image-width", "450") ; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter( "image-height", "300"); //$NON-NLS-1$ //$NON-NLS-2$ content = new StringBuffer();

messages = new ArrayList();

// call the chart helper to generate the pie chart image and to get the

HTML content

// use the chart definition in 'samples/dashboard/regions.widget.xml'

ChartHelper.doChart ( "samples", "dashboard", "departments .widget.xml", parameters, content, userSession, messages, null );

%>

</span>

<br/>

<%= content.toString() %>

<%

}

%> </tr>

<tr>

<td colspan="2" valign="top" style="font-family:Arial; font-weight:bold"><hr

size="1"/>

</tr>

<tr>

<td valign="top"><span style="font-family:Arial; font-weight :bold">

<%

if( department != null ) {

// if the user has clicked on a bar of the bar chart we should have a region and department to work with

// create a dial and supply a value we create from the current time

Date now = new Date();

int seconds = now.getSeconds();

// create a value from -15 to +15

int dialValue = -15+seconds/2;

// create the parameres for the bar chart

parameters = new SimpleParameterProvider();

// set the value displayed on the dial

parameters. setParameter ( "value", ""+dialValue );

// set the title for the dial

parameters.setParameter( "title", "My Dial" );

// set the width and the height

parameters. setParameter ( "image-width", "105") ; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter( "image-height", "105"); //$NON-NLS-1$ //$NON-NLS-2$ content = new StringBuffer();

messages = new ArrayList();

// call the chart helper to generate the pie chart image and to get the

HTML content

// use the chart definition in 'samples/dashboard/regions.widget.xml'

ChartHelper.doDial ( "samples", "dashboard", "sampledial.widget .xml", parameters, content, userSession, messages, null );

%>

The value of this dial is based on the current time

</span>

<p/>

<%= content.toString() %>

<%

}

%>

</td>

<td valign="top" style="font-family:Arial; font-weight:bold">

<%

if( department != null ) {

// if the user has clicked on a bar of the bar chart we should have a region and department to work with

// run a report and embed the content into this page

// create the parameres for the report

parameters = new SimpleParameterProvider();

// pass the region and department to the report parameters.setParameter( "region", region );

parameters.setParameter( "department", department ); // create an output stream for the report content

ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); messages = new ArrayList();

// run the action sequence 'samples/dashboard/jsp/report.xaction'

ChartHelper.doAction ( "samples", "dashboard/jsp", "embedded_report .xaction",

"SampleDashboard", parameters, outputStream , userSession, messages, null ); // write the report content into this page

%>

Click on a position title to drill to another page </span>

<p/>

<% out.write( outputStream.toString() ); %>

<%

}

%>

</td>

</tr>

</table>

</body> </html>

附錄02 Pie Chart 定義

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!--        This file defines the pie chart that shows the actual values for each
region -->

<!-- Specify the title of the chart --> <title>Headcount Spending by Region</title> <!-- Specify the location of the title --> <title-position>none</title-position> <!-- Specify the font of the title --> <title-font>

<font-family>Ariel< /font-family> <size>20</size>

<is-bold>false</is-bold>

<is-italic>false</is-italic> </title-font>

<width> 450</width>

<height> 300</height>

<!-- Specify the 3D-ness of the bars --> <is-3D> fal s e< / is-3D>

<!-- Specify if the chart has a border and the border color -->

<border-vis ible>false</border-visible> <border-paint>#bbbbff</border-paint>

<!-- Specify is the chart legend should be shown -->

<include-legend>false</ include-legend>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples</data-solution> <data-path>dashboard</data-path>

<data-action>regions_headcount_data.xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>rule-result</data-output> <data-name>POSITIONTITLE</data-name>

<data-value>ACTUAL< /data-value>

<!-- Specify whether to get the pie series from the rows or columns --> <data-orientation>columns</data-orientation>

</data>

</chart>

附錄03 Region 數據

This page last changed on Jan 30, 2007 by wgorman.

<action-sequence>

<version> 1< /vers ion>

<title>Regions and departments</title> <logging-level>debug</logging-level> <documentation>

<author>James Dixon</author>

<description>Return the actual headcount costs total for each region</description>

<help></help>

</documentation>

<inputs/>

<!-- Define an output called 'rule-result' --> <outputs>

<rule-result>

<type> list< / type>

</rule-result>

</outputs>

<!-- This action sequence does not require any external resources --> <resources/>

<actions>

<action-definition>

<action-inputs/>

<!-- Define a local output called 'rule-result' -->

<action-outputs>

<rule-result type="list"/>

</action-outputs>

<!-- Specify the component to execute --> <component-name> SQLLookupRule< / component-name> <action-type>rule</action-type>

<!-- Define the settings for the component -->

<component-definition>

<!-- Define the datasource for the query -->

<jndi>SampleData</j ndi>

<!--                                       Define the query to execute. Note the parameter

{REGION} in the query -->

<query><![ CDATA[

select REGION, sum(ACTUAL)

from quadrant _actuals

group by REGION order by ACTUAL]]> </query>

</component-definition>

</action-definition>

</actions>

</action-sequence>

附錄04 Department Bar Chart 定義

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!--        This file defines the bar chart that shows the actual-to-budget variance
for each department -->

<!-- Define the chart type --> <chart-type>BarChart</chart-type>

<!-- Specify the title of the chart -->

<title>Headcount Variance</title>

<!-- Specify the location of the title -->

<title-position>TOP</title-position> <!-- Specify the font of the title --> <title-font>

<font-family>Ariel< /font-family>

<size>20</size>

<is-bold>false</is-bold> <is-italic>false</is-italic>

</title-font>

<chart-background-color>#FF80FF</chart-background-color>

<plot-background-color> #FFFF00< /plot-background-color>

<!-- Specify the orientation of the bars -->

<orientat ion>Ho ri z ontal< / orientation> <!-- Specify the 3D-ness of the bars -->

<is-3D> fal s e< / is-3D>

<!-- Specify if the bars are stacked -->

<is-stacked>false</is-stacked>

<!-- Specify if the chart has a border and the border color -->

<border-vis ible>true</border-visible> <border-paint>#000000</border-paint>

<!-- Specify is the chart legend should be shown --> <include-legend>true</include-legend> <!-- Specify the color palette for the chart -->

<color-palette>

<color>#336699</color> <color>#99CCFF</color> <color>#999933</color> <color>#666699</color> <color>#CC9933</color> <color>#006666</color> <color>#3399FF</color> <color>#993300</color> <color>#CCCC99</color> <color>#666666</color> <color>#FFCC66</color> <color>#6699CC</color><color>#663366</color>

</color-palette>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples</data-solution>

<data-path>dashboard</data-path> <data-action>department_variance_data.xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>rule-result</data-output>

<!-- Specify whether to get the chart series from the rows or columns --> <data-orientation>rows< /data-orientation>

</data>

</chart>

附錄05 Department Variance 數據

This page last changed on Jan 30, 2007 by wgorman.

這個 action sequence 指定一個 SQL 查詢,獲取一個指定區域的每一個部門的 headcount 的真實值和預算的差值。

action sequence 定義於:

~/pentaho-demo/pentaho-solutions/samples/dashboard/department_variance_dial .xaction.

使用 Pentaho BI Studio

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<version> 1< /vers ion>

<title>Regions and departments</title> <logging-level>debug</logging-level> <documentation>

<author>James Dixon</author>

<description>Return the variance between headcount actual and budget for every

department in the specified region</description> <help>just testing. . .</help>

</documentation>

<!-- Define an input called 'REGION'. This will be passed in when the user clicks on a slice of the pie chart -->

<inputs>

<REGION type="string">

<sources>

<request>REGION</request> </ sources>

</REGION>

</inputs>

<!-- Define an output called 'rule-result' --> <outputs>

<rule-result>

<type> list< / type>

</rule-result>

</outputs>

<!-- This action sequence does not require any external resources -->

<resources/>

<actions>

<action-definition>

<!-- Define a local input called 'REGION' -->

<action-inputs>

<REGION type="string"/> </action-inputs>

<!-- Define a local output called 'rule-result' -->

<action-outputs>

<rule-result type="list"/> </action-outputs>

<!-- Specify the component to execute -->

<component-name> SQLLookupRule</component-name> <action-type>rule</action-type> <!-- Define the settings for the component -->

<component-definition>

<!-- Define the datasource for the query -->

<jndi>SampleData</jndi>

<!--     Define the query to execute. Note the parameter

{REGION} in the query -->

</query>

</component-definition>

</action-definition>

</actions>

</action-sequence>

附錄06 Dial 定義

This page last changed on Jan 30, 2007 by wgorman.

<widget>

<dial>

<name>Gauge 1</name>

<units>$</units>

<!-- this is the background for the whole image -->

<!-- background-color>#ffffff</background-color -->

<!-- this ia the background for the dial -->

<!-- plot-background-color>#777700</plot-background-color -->

<plot-background type="texture"> <texture-image>/samples/portal/dial_03.gif</texture-image> </plot-background>

<tick-interval> 5</tick-interval> <value-color>#9 999bb</value-color> <tick-color>#808080</tick-color>

<!-- this is the color of the needle -->

<needle-color>#808080</needle-color> <chart-background type= "texture">

<texture-image>/samples/portal/dial_03.gif</texture-image> </chart-background>

<!--    intervals define ranges on the dial that are colored differently
from the dial background -->

<interval>

<label>under</label>

<!-- this is the value that the range starts at -->

<minimum>-1 5</minimum>

<!-- this is the value that the range stops at -->

<maximum> 0</maximum>

<!-- this is the color of the range -->

<color>#ffffff</color>

<!--   this is the color of the text for the range value and tick

marks -->

<text-color>#40bb40</text-color>

<stroke-width>5</stroke-width>

</interval>

<interval>

<label>over</label>

<minimum> 0</minimum>

<maximum> 15</maximum>

<color>#ffffff</color>

<text-color>#bb4040</text-color> <stroke-width>5</stroke-width> </interval>

</dial>

</widget>

附錄07 嵌入式報表模板

This page last changed on Jan 30, 2007 by wgorman.

<?xml version="1 .0" encoding="UTF-8"?>

<action-sequence>

<version> 1< /vers ion>

<title>JFreeReport HTML Example</title> <logging-level>debug</logging-level> <documentation>

<author>James Dixon</author> <description><![ CDATA[

This is an example of an HTML report produced by JFreeReport.

<p/>It shows the actual headcount cost, budgeted headcount

cost, and variance for every position in the specified

department and region ] ] ></description>

<icon>/style/icons/jfree1 .png</icon>

<help></help>

</documentation>

<!--        Define an input called 'region' and an input called 'department'. These
will be passed in when the user clicks on a bar on the bar chart -->

<inputs>

<region type="string"> <sources>

<request>region</request>

</sources>

</region>

<department type="string">
<sources>

<request>department</request>

</sources>

</department>

</inputs>

<!-- Define an output called 'report' -->

<outputs>

<report type="content"> <destinations>

<response>content</response>

</destinations> </report>

</outputs>

<!-- This action sequence uses a report definition file embedded_report.xml --> <resources>

<report-definition>

<solution-file>

<location>embedded_report.xml</location>

<mime-type> text/xml</mime-type>

</solution-file> </report-definition></resources>

<actions>

<action-definition>

<!-- Define a local inputs called 'region' and 'department' --> <action-inputs>

<region type="string"/>

<department type="string"/>

</action-inputs>

<!-- Define a local output called 'report' -->

<action-outputs>

<report type="content"/>

</action-outputs>

<!-- Specify the component to execute --> <component-name>JFreeReportComponent< /component -name> <action-type>report</action-type>

<!-- Define the settings for the component -->

<component-definition>

<live>false</live>

<!-- Define the datasource for the query -->

<jndi>SampleData</j ndi>

<source> sql</source>

<!--         Define the query to execute. Note the parameter
{region} and {department} in the query -->

</ query>

<!-- Define the content type for the report --> <output-type>html< / output-type>

</component-definition>

</action-definition>

</actions> </action-sequence>

附錄08 Drill JSP

This page last changed on Jan 30, 2007 by wgorman.

<%@ page language="java"

import="java.util.ArrayList,

java.util.Date,

java.io.ByteArrayOutput Stream,

org.pentaho.core.ui.SimpleUrlFactory,

org.pentaho.messages.Messages,

org.pentaho.core.system.PentahoSystem,

org.pentaho.ui.component.DashboardWidgetComponent,

org. pentaho .core. solution. HttpRequestParameterProvider, org. pentaho.core.solution.HttpSessionParameterProvider,org. pentaho.core.session.IPentahoSession,

org.pentaho.core.util.UIUtil,

org.pentaho.util.VersionHelper,

org.pentaho.messages.util.LocaleHelper,

org.pentaho.core.solution.ActionResource,

org.pentaho.core.solution.IActionResource,

org.pentaho .core. solution. SimpleParameterProvider, org. pentaho.ui.ChartHelper,

java. io .*"

%><%

/*

*    Copyright 2006 Pentaho Corporation. All rights reserved.

*    This software was developed by Pentaho Corporation and is provided under the terms

*    of the Mozilla Public License, Version 1.1, or any later version. You may not use

*    this file except in compliance with the license. If you need a copy of the license,

*    please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho

*    BI Platform. The Initial Developer is Pentaho Corporation.

*

*    Software distributed under the Mozilla Public License is distributed on an "AS IS"

*    basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to

*    the license for the specific language governing your rights and limitations.

*

*    Created Feb 16, 2006

*    @author James Dixon

*/

/*

This JSP page is part of the Pentaho samples that show how JSP can be

used to present and control content that is generated by the Pentaho BI Platform.

This JSP page is the page that is used after a user clicks on a link in the embedded report that is displayed in SampleDashboard.jsp.

The region, department, and job position title are passed in as parameters on the URL The url is formatted in the report definition file: ~/pentaho-demo/pentaho-solutions/samples/dashboard/j sp/embedded _report .xml

The url is set in the last function that is defined in the file. The important line is the "pattern"

<expression name="URLCreateExpression"

class="org. jfree.report . function.TextFormatExpression">

<properties> <property

name="pattern">SampleDrill? region={ 0} &amp;position={ 1} &amp; department={ 2} </property>

<property name="field[ 0] ">REGION</property>

<property name="field[ 1] ">POSITIONTITLE</property>

<property name="field[ 2] ">DEPARTMENT</property>

</properties> </ express ion>

You can change the url template to point to wherever you need it to

*/

String region = request.getParameter("region");

String department = request.getParameter("department"); String position = request.getParameter ("position");

%>

<html>

<head>

<title>Pentaho Regional Report - JSP Sample</title>

</he ad> <body>

<h1 style="font-family:Arial">Drill Destination</h1>

<span style="font-family:Arial">

The selected region is '<%= region %>'

<p/>

The selected department is '<%= department %>'

<p/>

The selected position is '<%= position %>'

</span>

</body> </html>

附錄09 Steel Wheels JSP

This page last changed on Jan 30, 2007 by wgorman.

*    <%@ page language="java"

import="java.util .ArrayList,

java .util .Date,

java. io. ByteArrayOutput Stream,

org. pentaho . core. ui . SimpleUrlFactory,

org.pentaho .messages .Messages,

org. pentaho . core. system. PentahoSystem,

org. pentaho . ui.component. DashboardWidgetComponent,

org. pentaho .core. solution. HttpRequestParameterProvider, org. pentaho .core. solution. HttpSessionParameterProvider, org. pentaho .core. session. IPentahoSession,

org. pentaho .core. util . UIUtil,

org. pentaho . util .VersionHelper,

org. pentaho .mes sages. util . LocaleHelper,

org. pentaho .core. solution .ActionResource,

org. pentaho .core. solution. IActionResource,

org. pentaho .core. solution. SimpleParameterProvider, org. pentaho . ui. ChartHelper,

java. io .*"

%><%

/*

*    Copyright 2006 Pentaho Corporation. All rights reserved.

*    This software was developed by Pentaho Corporation and is provided under the terms

*    of the Mozilla Public License, Version 1.1, or any later version. You may not use

*    this file except in compliance with the license. If you need a copy of the license,

*    please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho

*    BI Platform. The Initial Developer is Pentaho Corporation.

*

*    Software distributed under the Mozilla Public License is distributed on an "AS IS"

*    basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to

*    the license for the specific language governing your rights and limitations.

*

*    Created Feb 16, 2006

*    @author James Dixon modified by Kurtis Cruzada

*/

/*

*    This JSP is an example of how to use Pentaho components to build a dashboard.

*    The script in this file controls the layout and content generation of the dashboard.

*    See the document 'Dashboard Builder Guide' for more details

*/

// set the character encoding e.g. UFT-8

response. setCharacterEncoding (LocaleHelper.getSystemEncoding ());

*    // create a new Pentaho session

IPentahoSession userSession = UIUtil.getPentahoSession( request );

%>

<html>

*    <head>

<title>Pentaho Sample Dashboard - JSP</title>

</he ad> <body>

<table class="Banner" cellpadding="0" width="100%">

<tbody>

<%

// See if we have a 'territory' parameter

String territory = request.getParameter("territory"); // See if we have a 'productline' parameter

String productline = request.getParameter ("productline");

// Create the title for the top of the page

String title = "Revenue Analysis";

if( productline != null ) {

title = "Sales for " + territory + ", " + productline;

}

else if ( territory != null ) {

title = "Sales for " + territory;

} %>

<h1 style='font-family:Arial'></h1>

<table>

<tr>

<td width="75%"><img src="/sw-style/active/logo.png" border="0" /></a> </td>

<td align="right" style="font-family:Arial; font-weight:bold"

background="/sw-style/active/banner.png" valign="top" width="25%"></a><%= title %></td>

</tr>

<tr>

<td width="75%">

</td>

<td align="right" valign="top" width="25%"></td>

</tr>

</table>

<table style="text-align: left; width: 100%; background-color: rgb(231, 238, 248);">

<tr>

<td valign="top" align="center">

<%

// Make a pie chart showing the territories // create the parameres for the pie chart

SimpleParameterProvider parameters = new SimpleParameterProvider();

// define the click url template

parameters.setParameter( "drill-url", "SWDashboard?territory={ TERRITORY} " );

// define the slices of the pie chart

parameters. setParameter ( "inner-param", "TERRITORY"); //$NON-NLS-1$ //$NON-NLS-2$

// set the width and the height

parameters. setParameter ( "image-width", "350") ; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter( "image-height", "200"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content = new StringBuffer();

ArrayList messages = new ArrayList();

// call the chart helper to generate the pie chart image and to get the HTML

content

// use the chart definition in 'samples/dashboard/territory.widget.xml' ChartHelper.doPieChart ( "samples/steel-wheels", "dashboards", "territory.widget.xml",

parameters, content, userSession, messages, null ); %>

<%= content.toString() %>

<span style="font-family:Arial;font-size:12;font-weight:plain"> (Click

on a Territory) </span>

</td>

<td valign="top" align="center">

<%

if( territory == null ) {

// if the user has clicked on a slice of the pie chart we should have a

territory to work with

%>

<%

// Make a bar chart showing the department

// create the parameres for the bar chart

parameters = new SimpleParameterProvider();

// define the click url template

parameters. setParameter ( "drill-url",

"SWDashboard? territory="+territory+"&amp;productline={ SERIES} " );

parameters.setParameter( "TERRITORY", territory );

parameters. setParameter ( "outer-params", "TERRITORY" );

// define the category axis of the bar chart

parameters. setParameter ( "inner-param", "TERRITORY"); //$NON-NLS-1$

//$NON-NLS-2$

parameters. setParameter ( "inner-param", "PRODUCTLINE"); //$NON-NLS-1$

//$NON-NLS-2$

// set the width and the height

parameters. setParameter ( "image-width", "550") ; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter( "image-height", "200"); //$NON-NLS-1$ //$NON-NLS-2$ content = new StringBuffer();

messages = new ArrayList();

// call the chart helper to generate the pie chart image and to get the

HTML content

// use the chart definition in 'samples/dashboard/productline.widget.xml'

ChartHelper.doChart ( "samples/steel-wheels", "dashboards", "productline_all.widget.xml", parameters, content, userSession, messages, null );

%>

<%= content.toString() %>

<span style="font-family:Arial;font-size:12;font-weight:plain"> (Click on a Product Line) </span>

<%

}

%>

<%

if( territory != null ) {

// if the user has clicked on a slice of the pie chart we should have a

territory to work with

%>

<%

// Make a bar chart showing the department

// create the parameres for the bar chart

parameters = new SimpleParameterProvider();

// define the click url template

parameters. setParameter ( "drill-url",

"SWDashboard? territory="+territory+"&amp;productline={ SERIES} " );

parameters.setParameter( "TERRITORY", territory );

parameters. setParameter ( "outer-params", "TERRITORY" );

// define the category axis of the bar chart

parameters. setParameter ( "inner-param", "TERRITORY"); //$NON-NLS-1$

//$NON-NLS-2$

parameters. setParameter ( "inner-param", "PRODUCTLINE"); //$NON-NLS-1$

//$NON-NLS-2$

// set the width and the height

parameters. setParameter ( "image-width", "550") ; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter( "image-height", "200"); //$NON-NLS-1$ //$NON-NLS-2$ content = new StringBuffer();

messages = new ArrayList();

// call the chart helper to generate the pie chart image and to get the

HTML content

// use the chart definition in 'samples/dashboard/productline.widget.xml'

ChartHelper.doChart ( "samples/steel-wheels", "dashboards", "productline.widget.xml", parameters, content, userSession, messages, null );

%>

<%= content.toString() %>

<span style="font-family:Arial;font-size:12;font-weight:plain"> (Click on a Product Line) </span>

<%

}

%>

</td>

</tr>

</table>

<table style="text-align: left; width: 100%; background-color: rgb(231, 238,

248) ;">

<tr>

<td valign="top">

</td>

<td>

<%

if( productline != null ) {

// if the user has clicked on a bar of the bar chart we should have a territory and productline to work with

// create a dial and supply a value we create from the current

time

// create the parameters for the line chart parameters = new SimpleParameterProvider();parameters.setParameter( "TERRITORY", territory ); parameters. setParameter ( "outer-params", "TERRITORY" );parameters.setParameter( "PRODUCTLINE", productline ); parameters. setParameter ( "outer-params", "PRODUCTLINE" );

// define the category axis of the bar chart parameters.setParameter( "inner-param", "PRODUCTLINE");

//$NON-NLS-1$ //$NON-NLS-2$

// set the width and the height

parameters.setParameter( "image-width", "550"); //$NON-NLS-1$

//$NON-NLS-2$

parameters. setParameter ( "image-height", "200"); //$NON-NLS-1$

//$NON-NLS-2$

content = new StringBuffer();

messages = new ArrayList();

// call the chart helper to generate the pie chart image and to

get the HTML content

// use the chart definition in

'samples/dashboard/regions. widget. xml'

ChartHelper.doChart ( "samples/steel-wheels", "dashboards", "SalesOvertime.widget.xml", parameters, content, userSession, messages, null );

%>

<span style="font-family:Arial; font-weight:bold"></span>

<%= content.toString() %>

<%

}

%>

<%

if( productline == null ) {

// if the user has clicked on a bar of the bar chart we should have a territory and productline to work with

// create a dial and supply a value we create from the current

time

// create the parameters for the line chart parameters = new SimpleParameterProvider();parameters.setParameter( "TERRITORY", territory ); parameters. setParameter ( "outer-params", "TERRITORY" ); // define the category axis of the bar chart parameters.setParameter( "inner-param", "PRODUCTLINE");

//$NON-NLS-1$ //$NON-NLS-2$

//$NON-NLS-2$ //$NON-NLS-2$

get the HTML content  // set the width and the height

parameters.setParameter( "image-width", "550"); //$NON-NLS-1$

parameters. setParameter ( "image-height", "200"); //$NON-NLS-1$

content = new StringBuffer();

messages = new ArrayList();

// call the chart helper to generate the pie chart image and to

// use the chart definition in

'samples/dashboard/regions. widget. xml'

ChartHelper.doChart ( "samples/steel-wheels", "dashboards", "SalesOvertime_All.widget.xml", parameters, content, userSession, messages, null ); %>

<span style="font-family:Arial; font-weight:bold"></span> <%= content.toString() %>

}

</td>

</tr> </table>

</body> </html>

附錄10 Steel Wheels Territory Chart

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!-- This file defines the pie chart that shows the actual values for each region -->

<!-- Specify the title of the chart --> <title>Territory</title>

<!-- Specify the location of the title --> <title-position>top</title-position>

<!-- Specify the font of the title --> <title-font>

<font-family>Ariel< /font-family> <size>14</size>

<is-bold>true</is-bold>

<is-italic>false</is-italic> </title-font>

<width> 350</width> <height>200</height>

<!-- Specify the 3D-ness of the bars --> <is-3D> fal s e< / is-3D>

<!-- Specify if the chart has a border and the border color --> <border-vis ible>false</border-visible>

<!-- Specify is the chart legend should be shown --> <include-legend>false</ include-legend>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples/steel-wheels</data-solution> <data-path>dashboards</data-path>

<data-action>Sales _by _Territory. xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>swresult</data-output>

<data-name> TERRITORY< /data-name> <data-value>SOLD_PRICE< /data-value>

<!-- Specify whether to get the pie series from the rows or columns --> <data-orientation>columns</data-orientation>

</data>

</chart>

附錄11 Steel Wheels Product Line All Chart

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!-- This file defines the bar chart that shows the actual-to-budget variance for each department -->

<!-- Define the chart type --> <chart-type>BarChart</chart-type>

<!-- Specify the title of the chart --> <title>Product Line</title>

<!-- Specify the location of the title --> <title-position>TOP</title-position>

<!-- Specify the font of the title -->

<title-font>

<font-family>Ariel< /font-family>

<size>14</size>

<is-bold>true</is-bold>

<is-italic>false</is-italic>

</title-font>

<range-title></range-title>

<domain-label-rotation>1 .1</domain-label-rotation> <domain-label-rotation-dir></domain-label-rotation-dir> <domain-title>< /domain-title>

<chart-background type="color"> #FFFFFF< /chart-background> <plot-background type="color">#EEEEEE</plot-background> <!-- Specify the orientation of the bars -->

<orientation>horizontal</orientation>

<!-- Specify the 3D-ness of the bars --> <is-3D> false< / is-3D>

<!-- Specify if the bars are stacked --> <is-stacked>false</is-stacked>

<!-- Specify if the chart has a border and the border color --> <border-vis ible>false</border-visible>

<border-paint>#000000</border-paint>

<!-- Specify is the chart legend should be shown --> <include-legend>true</include-legend>

<!-- Specify the color palette for the chart -->

<color-palette>

<color>#336699</color> <color>#99CCFF</color> <color>#999933</color> <color>#666699</color> <color>#CC9933</color> <color>#006666</color> <color>#3399FF</color> <color>#993300</color> <color>#CCCC99</color> <color>#666666</color> <color>#FFCC66</color> <color>#6699CC</color><color>#663366</color>

</color-palette>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples/steel-wheels</data-solution> <data-path>dashboards</data-path>

<data-action>Sales_by_Productline_all . xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>swresult</data-output>

<!-- Specify whether to get the chart series from the rows or columns --> <data-orientation>rows< /data-orientation>

</data>

</chart>

附錄12 Steel Wheels Product Line Widget

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!-- This file defines the bar chart that shows the actual-to-budget variance for each department -->

<!-- Define the chart type --> <chart-type>BarChart</chart-type>

<!-- Specify the title of the chart --> <title>Product Line</title>

<!-- Specify the location of the title --> <title-position>TOP</title-position>

<!-- Specify the font of the title -->

<title-font>

<font-family>Ariel< /font-family>

<size>14</size>

<is-bold>true</is-bold>

<is-italic>false</is-italic>

</title-font>

<range-title></range-title>

<domain-label-rotation>1 .1</domain-label-rotation> <domain-label-rotation-dir></domain-label-rotation-dir> <domain-title>< /domain-title>

<chart-background type="color"> #FFFFFF< /chart-background> <plot-background type="color">#EEEEEE</plot-background>

<!-- Specify the orientation of the bars --> <orientation>horizontal< /orientation>

<!-- Specify the 3D-ness of the bars --> <is-3D> false< / is-3D>

<!-- Specify if the bars are stacked --> <is-stacked>false</is-stacked>

<!-- Specify if the chart has a border and the border color --> <border-vis ible>false</border-visible>

<border-paint>#000000</border-paint>

<!-- Specify is the chart legend should be shown --> <include-legend>true</include-legend>

<!-- Specify the color palette for the chart -->

<color-palette>

<color>#336699</color> <color>#99CCFF</color> <color>#999933</color> <color>#666699</color> <color>#CC9933</color> <color>#006666</color> <color>#3399FF</color> <color>#993300</color> <color>#CCCC99</color> <color>#666666</color> <color>#FFCC66</color> <color>#6699CC</color><color>#663366</color>

</color-palette>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples/steel-wheels</data-solution> <data-path>dashboards</data-path>

<data-action>Sales_by_Productline.xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>swresult</data-output>

<!-- Specify whether to get the chart series from the rows or columns --> <data-orientation>rows< /data-orientation>

</data>

</chart>

附錄13 Steel Wheels Sales Overtime Widget

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!-- This file defines the bar chart that shows the actual-to-budget variance for each department -->

<!-- Define the chart type --> <chart-type>LineChart</chart-type>

<!-- Specify the title of the chart --> <title>Sales Trends</title>

<!-- Specify the location of the title --> <title-position>TOP</title-position>

<!-- Specify the font of the title -->

<title-font>

<font-family>Ariel< /font-family>

<size>14</size>

<is-bold>true</is-bold>

<is-italic>false</is-italic>

</title-font>

<range-title></range-title>

<domain-label-rotation>1 .1</domain-label-rotation> <domain-label-rotation-dir></domain-label-rotation-dir> <domain-title>< /domain-title>

<chart-background type="color"> #FFFFFF< /chart-background> <plot-background type="color">#EEEEEE</plot-background>

<!-- Specify the orientation of the bars --> <orientation>vertical</orientation>

<!-- Specify the 3D-ness of the bars --> <is-3D> false< / is-3D>

<!-- Specify if the bars are stacked --> <is-stacked>false</is-stacked>

<!-- Specify if the chart has a border and the border color --> <border-visible>false</border-visible>

<border-paint>#000000</border-paint>

<!-- Specify is the chart legend should be shown --> <include-legend>false</ include-legend>

<!-- Specify the color palette for the chart -->

<color-palette>

<color>#336699</color> <color>#99CCFF</color> <color>#999933</color> <color>#666699</color> <color>#CC9933</color> <color>#006666</color> <color>#3399FF</color> <color>#993300</color> <color>#CCCC99</color> <color>#666666</color> <color>#FFCC66</color> <color>#6699CC</color><color>#663366</color>

</color-palette>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples/steel-wheels</data-solution> <data-path>dashboards</data-path>

<data-action>sales _overtime .xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>swresult</data-output>

<!-- Specify whether to get the chart series from the rows or columns --> <data-orientation>columns</data-orientation>

</data>

</chart>

附錄14 Steel Wheels Sales Overtime All Widget

This page last changed on Jan 30, 2007 by wgorman.

<chart>

<!-- This file defines the bar chart that shows the actual-to-budget variance for each department -->

<!-- Define the chart type --> <chart-type>LineChart</chart-type>

<!-- Specify the title of the chart --> <title>Sales Trends</title>

<!-- Specify the location of the title --> <title-position>TOP</title-position>

<!-- Specify the font of the title -->

<title-font>

<font-family>Ariel< /font-family>

<size>14</size>

<is-bold>true</is-bold>

<is-italic>false</is-italic>

</title-font>

<range-title></range-title>

<domain-label-rotation>1.1</domain-label-rotation> <domain-label-rotation-dir></domain-label-rotation-dir> <domain-title>< /domain-title>

<chart-background type="color"> #FFFFFF< /chart-background> <plot-background type="color">#EEEEEE</plot-background>

<!-- Specify the orientation of the bars --> <orientation>vertical</orientation>

<!-- Specify the 3D-ness of the bars --> <is-3D> false< / is-3D>

<!-- Specify if the bars are stacked --> <is-stacked>false</is-stacked>

<!-- Specify if the chart has a border and the border color --> <border-vis ible>false</border-visible>

<border-paint>#000000</border-paint>

<!-- Specify is the chart legend should be shown --> <include-legend>false</ include-legend>

<!-- Specify the color palette for the chart -->

<color-palette>

<color>#336699</color> <color>#99CCFF</color> <color>#999933</color> <color>#666699</color> <color>#CC9933</color> <color>#006666</color> <color>#3399FF</color> <color>#993300</color> <color>#CCCC99</color> <color>#666666</color> <color>#FFCC66</color> <color>#6699CC</color><color>#663366</color>

</color-palette>

<!-- Specify where the data for the chart comes from -->

<data>

<!-- Specify the path to the action sequence that provides the data --> <data-solution>samples/steel-wheels</data-solution> <data-path>dashboards</data-path>

<data-action>sales _overtime _all .xaction</data-action>

<!-- Specify the output of the action sequence that contains the data --> <data-output>swresult</data-output>

<!-- Specify whether to get the chart series from the rows or columns --> <data-orientation>columns</data-orientation>

</data>

</chart>

附錄15 Steel Wheels Sales By Territory XAction

This page last changed on Jan 30, 2007 by wgorman.

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<name> Sales _by _Territory.xaction</name> <title>05. SALES BY TERRITORY</title> <version> 1</version>

<logging-level>ERROR< /logging-level> <documentation>

<author>Kurtis Cruzada</author>

<description>List of Territories sorted by Sales. Select date range (Jan 2003 through May

2005). Includes chart.</description> <icon>slsbyter.png</icon>

<help/>

</documentation>

<inputs/>

<outputs>

<!-- an output stream will be provided by default --> <swresult>

<type>list</type>

</swresult>

</outputs>

<resources>

<!-- use this section to identify any files that the component needs to execute the report

- ->

</resources>

<actions>

<action-definition>

<component -name> SQLLookupRule< /component-name>

<action-type>SQL Query</action-type>

<action-inputs>

<territory_name type="string"/>

<product line_name type="string" />

</action-inputs> <action-outputs>

<query-result type="result-set" mapping="swresult"/>

</action-outputs> <component-definition>

<jndi>SampleData</jndi>

<query><![ CDATA[ SELECT OFFICES.TERRITORY,

SUM (ORDERDETAILS .QUANTITYORDERED*ORDERDETAILS . PRICEEACH) SOLD _PRICE FROM ORDERS INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE INNER JOIN CUSTOMERS ON ORDERS.CUSTOMERNUMBER =CUSTOMERS. CUSTOMERNUMBER INNER JOIN EMPLOYEES ON CUSTOMERS. SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE GROUP

BY OFFICES.TERRITORY ORDER BY 2 DESC]]></query>

</component-definition>

</action-definition>

</actions> </action-sequence>

附錄16 Steel Wheels Sales by Productline All XAction

This page last changed on Jan 30, 2007 by wgorman.

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<name> Sales _by _Productline.xaction</name> <title>06. SALES BY PRODUCTLINE</title> <version> 1</version>

<logging-level>ERROR< /logging-level> <documentation>

<author>Kurtis Cruzada</author>

<description>List of Product Lines sorted by Sales. Select date range (Jan 2003 through May

2005). Includes chart.</description> <icon>slsprdln.png</icon>

<help/>

</documentation>

<inputs/>

<outputs>

<!-- an output stream will be provided by default --> <swresult type="result-set"/>

</outputs>

<resources>

<!-- use this section to identify any files that the component needs to execute the report

- ->

</resources>

<actions>

<action-definition>

<component -name> SQLLookupRule< /component-name> <action-type>SQL Query</action-type>

<action-inputs/>

<action-outputs>

<query-result type="result-set" mapping="swresult"/> </action-outputs>

<component-definition>

<jndi>SampleData</jndi>

<query><![ CDATA[ SELECT PRODUCTS. PRODUCTLINE,

SUM (ORDERDETAILS .QUANTITYORDERED*ORDERDETAILS . PRICEEACH) REVENUE FROM ORDERS INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE INNER JOIN CUSTOMERS ON ORDERS.CUSTOMERNUMBER =CUSTOMERS. CUSTOMERNUMBER INNER JOIN EMPLOYEES ON CUSTOMERS. SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE GROUP BY PRODUCTS.PRODUCTLINE ORDER BY 2 DESC]]></query>

</component-definition>

</action-definition>

</actions> </action-sequence>

附錄17 Steel Wheels Sales by Productline XAction

This page last changed on Jan 30, 2007 by wgorman.

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<name> Sales _by _Productline .xaction</name> <title>06. SALES BY PRODUCTLINE</title> <version> 1</version>

<logging-level>ERROR< /logging-level> <documentation>

<author>Kurtis Cruzada</author>

<description>List of Product Lines sorted by Sales. Select date range (Jan 2003 through May

2005). Includes chart.</description> <icon>slsprdln.png</icon>

<help/>

</documentation>

<inputs>

<TERRITORY type="string">

<sources>

<request>TERRITORY< /request>

</sources> <default-value>NULL</default-value>

</TERRITORY> </inputs>

<outputs>

<!-- an output stream will be provided by default --> <swresult type="result-set"/>

</outputs>

<resources>

<!-- use this section to identify any files that the component needs to execute the report

- ->

</resources>

<actions>

<actions>

<condition><![ CDATA[ TERRITORY == "NULL"]] ></condition>

<action-definition>

<component-name> SQLLookupRule< / component-name>

<action-type>SQL Query</action-type>

<action-inputs /> <action-outputs>

<query-result type="result-set" mapping="swresult"/>

</action-outputs> <component-definition>

<jndi> SampleData< /jndi>

<query><![ CDATA[ SELECT PRODUCTS.PRODUCTLINE,

SUM (ORDERDETAILS .QUANTITYORDERED*ORDERDETAILS . PRICEEACH) REVENUE FROM ORDERS INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE INNER JOIN CUSTOMERS ON ORDERS.CUSTOMERNUMBER =CUSTOMERS. CUSTOMERNUMBER INNER JOIN EMPLOYEES ON CUSTOMERS. SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE GROUP BY PRODUCTS.PRODUCTLINE ORDER BY 2 DESC]]></query>

</component-definition>

</action-definition>

</actions>

<action-definition>

<component -name> SQLLookupRule< /component-name> <action-type>SQL Query</action-type>

<action-inputs>

<TERRITORY type="string"/>

</action-inputs>

<action-outputs>

<query-result type="result-set" mapping="swresult"/> </action-outputs>

<component-definition>

<jndi>SampleData</jndi>

<query><![ CDATA[ SELECT PRODUCTS. PRODUCTLINE,

SUM (ORDERDETAILS .QUANTITYORDERED*ORDERDETAILS . PRICEEACH) REVENUE FROM ORDERS INNER JOIN

ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE INNER JOIN CUSTOMERS ON ORDERS.CUSTOMERNUMBER =CUSTOMERS. CUSTOMERNUMBER INNER JOIN EMPLOYEES ON CUSTOMERS. SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE WHERE TERRITORY={ PREPARE:TERRITORY} GROUP BY PRODUCTS.PRODUCTLINE ORDER BY 2 DESC] ] ></query>

</component-definition>

</action-definition>

</actions> </action-sequence>

附錄18 Steel Wheels Sales Overtime XAction

This page last changed on Jan 30, 2007 by wgorman.

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<title/>

<version> 1</version>

<logging-level>ERROR< /logging-level> <documentation>

<author/>

<description>Empty blank action sequence document</description>

<help/>

<icon/>

</documentation>

<inputs>

<TERRITORY type="string">

<sources>

<request>TERRITORY< /request>

</sources> <default-value>NA</default-value>

</TERRITORY>

<PRODUCTLINE type="string">

<sources> <request>PRODUCTLINE</request>

</sources> <default-value>NULL</default-value>

</PRODUCTLINE> </inputs>

<outputs>

<swresult type="result-set"/> </outputs>

<resources/>

<actions>

<actions>

<condition><![ CDATA[ PRODUCTLINE != "NULL"]] ></condition> <action-definition>

<component-name> SQLLookupRule< / component-name> <action-type>SQL Query</action-type>

<action-inputs>

<territory type="string"/>

<productline type="string"/>

<PRODUCTLINE type="string"/>

<TERRITORY type="string"/>

</action-inputs>

<action-outputs>

<query-result type="result-set" mapping="swresult"/> </action-outputs>

<component-definition>

<jndi> SampleData< /jndi>

<query><![ CDATA[ SELECT CONCAT(CONCAT( YEAR(ORDERS.ORDERDATE),'-'

),MONTH (ORDERS.ORDERDATE)) AS TIME, SUM(ORDERDETAILS.QUANTITYORDERED*ORDERDETAILS.PRICEEACH)

SOLD _PRICE

FROM ORDERS

INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE INNER JOIN CUSTOMERS ON ORDERS. CUSTOMERNUMBER =CUSTOMERS . CUSTOMERNUMBER

INNER JOIN EMPLOYEES ON CUSTOMERS.SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER

INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE

WHERE PRODUCTS. PRODUCTLINE={ PREPARE: PRODUCTLINE} AND OFFICES. TERRITORY={ PREPARE: TERRITORY}

GROUP BY

CONCAT ( MONTH (ORDERS.ORDERDATE), YEAR(ORDERS.ORDERDATE) )] ] ></query> </component-definition>

</ act i on-de finition>

</actions> <actions>

<condition><![ CDATA[ PRODUCTLINE == "NULL"]] ></condition> <action-definition>

<component-name> SQLLookupRule< / component-name> <action-type>SQL Query</action-type>

<action-inputs>

<TERRITORY type="string"/>

</action-inputs>

<action-outputs>

<query-result type="result-set" mapping="swresult"/> </action-outputs>

<component-definition>

<j ndi> SampleData< /j ndi>

<query><![ CDATA[ SELECT CONCAT(CONCAT( YEAR(ORDERS.ORDERDATE),'-'

),MONTH (ORDERS.ORDERDATE)) AS TIME, SUM(ORDERDETAILS.QUANTITYORDERED*ORDERDETAILS.PRICEEACH)

SOLD _PRICE

FROM ORDERS

INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE INNER JOIN CUSTOMERS ON ORDERS. CUSTOMERNUMBER =CUSTOMERS . CUSTOMERNUMBER

INNER JOIN EMPLOYEES ON CUSTOMERS.SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER

INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE

WHERE OFFICE.TERRITORY='{ TERRITORY}'

GROUP BY

CONCAT ( MONTH (ORDERS.ORDERDATE), YEAR(ORDERS.ORDERDATE) )] ] ></query> </component-definition>

</action-definition>

</actions>

</actions> </action-sequence>

附錄19 Sales Overtime All XAction

This page last changed on Jan 30, 2007 by wgorman.

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<title/>

<version> 1</version>

<logging-level>ERROR< /logging-level> <documentation>

<author/>

<description>Empty blank action sequence document</description>

<help/>

<icon/>

</documentation>

<inputs>

<TERRITORY type="string">

<sources>

<request>TERRITORY< /request>

</sources> <default-value>NULL</default-value>

</TERRITORY> </inputs>

<outputs>

<swresult type="result-set"/> </outputs>

<resources/>

<actions>

<actions>

<condition><![ CDATA[ TERRITORY == "NULL"]] ></condition>

<action-definition>

<component-name> SQLLookupRule< / component-name>

<action-type>SQL Query no territory</action-type>

<action-inputs/> <action-outputs>

<query-result type="result-set" mapping="swresult"/>

</action-outputs> <component-definition>

<j ndi> SampleData< /j ndi>

<query><![ CDATA[ SELECT CONCAT(CONCAT( YEAR(ORDERS.ORDERDATE),'-'

),MONTH (ORDERS.ORDERDATE)) AS TIME, SUM(ORDERDETAILS.QUANTITYORDERED*ORDERDETAILS.PRICEEACH)

SOLD _PRICE

FROM ORDERS

INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER

INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE

INNER JOIN CUSTOMERS ON ORDERS. CUSTOMERNUMBER =CUSTOMERS . CUSTOMERNUMBER

INNER JOIN EMPLOYEES ON CUSTOMERS.SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER

INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE

GROUP BY

CONCAT ( MONTH (ORDERS.ORDERDATE), YEAR(ORDERS.ORDERDATE) )] ] ></query> </component-definition>

</ action-definition>

</actions>

<actions>

<condition><![ CDATA[ TERRITORY !== "NULL"] ] ></condition>

<action-definition>

<component-name> SQLLookupRule< / component-name>

<action-type>SQL Query with Territory</action-type>

<action-inputs>

<territory type="string"/> <productline type="string"/> <TERRITORY type="string"/>

</action-inputs>

<action-outputs>

<query-result type="result-set" mapping="swresult"/>

</action-outputs>

<component-definition>

<jndi> SampleData< /jndi>

<query><![ CDATA[ SELECT CONCAT(CONCAT( YEAR(ORDERS.ORDERDATE),'-'

),MONTH (ORDERS.ORDERDATE)) AS TIME, SUM(ORDERDETAILS.QUANTITYORDERED*ORDERDETAILS.PRICEEACH) SOLD _PRICE

FROM ORDERS

INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER

INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE

INNER JOIN CUSTOMERS ON ORDERS. CUSTOMERNUMBER =CUSTOMERS . CUSTOMERNUMBER

INNER JOIN EMPLOYEES ON CUSTOMERS.SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE

WHERE OFFICES. TERRITORY={ PREPARE: TERRITORY}

GROUP BY

CONCAT ( MONTH (ORDERS.ORDERDATE), YEAR(ORDERS.ORDERDATE) )] ] ></query> </component-definition>

</action-definition>

</actions>

</actions> </action-sequence>

使用 Filter Panel 開發 Portal Dashboard 

This page last changed on Feb 28, 2007 by sbarkdull.

動機

在 portal 中,digital dashboard是用戶接口組件的一個集合(又名 portlets),其提供了相關商業數據的一個視圖。digital dashboard 是頗有用的一種機制,其可快速的在一個頁面上展示一套 critical商業數據。開發人員可以使用 Pentaho BI 平臺以及 JSR168 portal 來實現 digital dashboard。此處我配置 Pentaho BI 平臺運行於 JBoss Portal 服務器,使用一個 FilterPanelPortlet,一個ActionPortlet 和一些 Action Sequences 來在一個 portal 頁面上實現一個 dashboard。

一個簡單的 Portal

簡單的說,portal 就是一個 portal 包含的一組相關 portal 頁面。一個 portal 頁面包含一套(1 或多個)窗口。每一個窗口包含一個 portlet,每一個 portlet 有服務端邏輯和客戶端用戶接口控制/顯示。

Dashboard

在 Pentaho BI 平臺中,可以使用一個 filter panel 和一個或多個包含內嵌於相同的 portal 頁面的可視化顯示的portlets 來建立一個基於 portal 的 dashboard。可視化的顯示一般指圖表和報表。

Filter Panel

一個 filter panel 包含和一個 HTML form 相關的客戶端 UI 控件,以及一個服務器端的 FilterPanelPortlet,其實 JSR168 GenericPortlet 的一個實現。當 form 提交給 Portal 服務器時,FilterPanelPortlet 將 form 中的數據放進 session scoped 參數中,而後這些參數就能夠做爲頁面中其餘 Portlets/Actions Sequences 的輸入。

當頁面中其餘 Pentaho-based portlets 被要求重畫自身時,它們可基於 filter panel 放進 session 中的參數值來重畫自身。

用實現了 Dashboard 的頁面配置 Portal

在 portal 中,配置 dashboard 有幾個必需的步驟:

1.       修改 portlet.xml 文件在 dashboard 中定義 portlets。

2.       修改 portlet-instances.xml 文件定義 portlet 實例。

3.       修改 pentaho-portal-object.xml 文件將 portlet 實例放進 portal 中的一個頁面。

4.     爲 portlet 添加 localized Strings,在 portlet.properties 文件中添加 portal 頁面標題。

5.       在 repository 中,建立一個 filter panel 定義文件。

6.       建立 Action Sequences 爲 filter panel 的控件提供 list-of-values (LOV) 數據。

7.       建立和頁面中的其餘 portlets 相關的 Action Sequences。這些 Action Sequences 響應 filter panel 放進 session 中的參數的改變,並提供商業數據的視圖。

8.       建立一個 JNDI 可訪問的 datasource,爲 Action Sequences 提供數據。

一個簡單的 Portal Dashboard 實例

在這個實例中,配置 portal 顯示一個 dashboard,經過:

1.       在 portal 添加兩個 portlets。

2.       在 portal 上添加這些 portlets 中每一個的實例。

3.       在 portal 中添加一個新的頁面

4.       在頁面中添加 2 個新的窗口。

5.       在兩個窗口中添加 2 個portlets。

修改 portal 配置文件

在 Pentaho Pre-Configured Install (PCI) 中,portal 配置文件位於/server/default/deploy/pentaho.war/WEB-INF。其名字是 portlet .xml,portlet-instances .xml 和pentaho-portal-object .xml。

Ø         portlet.xml: 包含 portlet 定義。

Ø         portlet-instances.xml: 包含 portlet-instance 定義。

Ø         pentaho-portal-object.xml: 包含 page 和 window 定義。

JBoss Portal 服務器特定配置文件

portlet.xml 文件的名字和格式在 JSR168 規範中肯定,對全部 JSR168 portals 都是同樣的。portlet-instances.xml  pentaho-portal-object.xml 文件的名字和格式是特定於 JBoss Portal 服務器的。

修改 portlet.xml 文件定義 dashboard 中的 portlets

這個 XML fragment 描述了 FilterPanelPortlet 類實現的一個 portlet,其 UI 由simple-dashboard.filterpanel.xml filter panel 描述文件指定。

TODO more detail

portlet 定義文件的更多信息請參考 JBoss Portal server documentation 或 JSR168 spec。

<portlet-app>

...

<portlet>

<portlet-name>SimpleFilterPanelPortlet</portlet-name>

<portlet-clas s>

org. pentaho . ui . portlet . FilterPanelPortlet

</portlet-class> <supports>

<mime-type>text/html</mime-type>

<portlet-mode>VIEW</portlet-mode>

</ supports>

<!-- package name containing the portlet.properties file, this file contains localized strings -->

<resource-bundle>

org .pentaho . locale .portlet

</resource-bundle> <portlet-info>

<!-- key into portlet.properties file containing the localized title of the portlet

displayed in the UI -->

<title>SimpleFilterPanelPortlet</title>

</portlet-info> <portlet-preferences>

<!-- filter panel description file -->

<preference> <name>filters</name>

<value>samples/simpleDashboard/simple-dashboard. filterpanel .xml</value>

</preference> </portlet-preferences>

</portlet>

...

</portlet-app>

這個 XML fragment 描述了 ActionPortlet 類實現的一個 portlet,其可視化顯示由 JFree_ChartComponent.xaction Action Sequence 建立。

<portlet-app>

...

<portlet>

<portlet-name>SimplePieChartPortlet</portlet-name>

<portlet-clas s>

org. pentaho . ui . portlet . ActionPortlet

</portlet-class> <supports>

<mime-type>text/html</mime-type>

<portlet-mode>VIEW</portlet-mode>

</ supports>

<resource-bundle>

org .pentaho . locale .portlet

</resource-bundle> <portlet-info> <title>SimplePieChartPortlet</title>

</portlet-info> <portlet-preferences>

<preference> <name>action</name>

<value>samples/simpleDashboard/JFree_ChartComponent .xaction</value>

</preference> </portlet-preferences>

</portlet>

...

</portlet-app>

修改 portlet-instances.xml 文件定義 portlet 實例

portlet-instances.xml 文件描述了 portlet 名字(在 portlet.xml)文件和一個 portlet 實例名間的映射。在 portal 中,你可有一個 portlet 的多個實例,每一個實例有本身的首選項。這個實例僅僅從 portlet 定義 '1inherits'1 它的首選項。實例名用於 add portlet instances to portal pages。

portlet 實例定義文件的更多信息請參考 JBoss Portal 服務器文檔。

<deployments>

...

<deployment> <if-exists>overwrite</if-exists>

<instance>

<instance-id>SimpleFilterPanelPortletInstance< /instance-id> <portlet-ref>SimpleFilterPanelPortlet< /portlet-ref>

</instance> </deployment> <deployment>

<if-exists>overwrite</if-exists>

<instance> <instance-id>SimplePieChartPortletInstance</instance-id> <portlet-ref>SimplePieChartPortlet</portlet-ref>

</instance> </deployment> ...

</deployments>

修改 pentaho-portal-object.xml 文件 to place portlet instances in a page in portal.

在 portal 上添加一個新的頁面,經過在 <deployements> 根元素上添加一個 <deployment> 元素,而後在<deployment> 元素中添加 <page> 元素。

爲每一個 portlet 添加一個窗口,經過在 <page> 元素上添加相應的 <window> 元素。爲每一個窗口添加一個 portlet,經過在 <window> 元素上添加 <instance-ref> 元素,指定 portlet 實例的名字(如portlet-instances.xml 文件所定義)做爲元素的文本。(TODO 中詳細介紹了元素)

portal 實例定義文件的更多信息請參考每行的註釋,以及 JBoss Portal server documentation。

<deployments>

...

<deployment>

<parent-ref>pentaho</parent-ref>

<if-exists>overwrite</if-exists>

<page>

<page-name>Simple Dashboard</page-name>

<properties> <property>

<name>order< /name>

<value> 90</value>

</property>

<!-- references a localized string in the portlet.properties file -->

<property>

<name>res ourceKey< /name>

<!-- the name of the key in the properties file --> <value>SimpleDashboard</value>

</property> </properties> <window>

<window-name>PentahoPortalNavigationWindow< /window-name>

<instance-ref>

PentahoPortalNavigationInstance

</instance-ref>

<region>navigation< /region>

<height> 0</height>

<!-- keep portal and page properties for this window -->

<properties>

<!-- use the window renderer from the emptyRenderer renderSet -->

<property>

<name> theme. windowRendererId< /name>

<value>emptyRenderer< /value> </property>

<!-- use the decoration renderer from the emptyRenderer renderSet -->

<property>

<name> theme. decorationRendererId</name>

<value>emptyRenderer< /value> </property>

<!-- use the portlet renderer from the emptyRenderer renderSet -->

<property>

<name> theme .portletRendererId</name>

<value>emptyRenderer< /value> </property>

</properties>

</window>

<!-- Specification of window containing the filter panel portlet -->

<window>

<window-name> SimpleFilterPanelPortletWindow< /window-name> <instance-ref>SimpleFilterPanelPortletInstance< /instance-ref>

<region> left</region>

<height> 0</height>

</window>

<!-- Specification of a window containing the ViewAction/pie chart portlet -->

<window>

<window-name> SimplePieChartPort letWindow< /window-name> <instance-ref>SimplePieChartPortletInstance</instance-ref>

<region> left</region>

<height> 1</height>

</window>

<!-- insert Secure security-constraints --> <security-constraint>

<policy-permiss ion>

<role-name>User< /role-name> <action-name>view</action-name> </policy-permis sion>

</security-constraint>

</page>

</deployment>

...

</deployments>

在portlet.properties 文件中,爲 Portlet 和 Portal Page Titles,添加 Localized Strings 

以前的 XML 片斷中的註釋標識了文本串,其是引用了本地化屬性文件(又名 resource bundles)中的文本串的鍵值。portlet.xml 文件標識了包含這些屬性文件的包(org.pentaho.locale.portlet)。你可能須要在適當的本地化文件中,爲你的鍵值添加 key/text-string 映射。

...

SimpleDashboard=SimPAL DashBORED

...

SimpleFilterPanelPortlet.javax.portlet. title=Simple Filter Panel Portlet SimplePieChartPortlet.javax.portlet .title=Simple Pie Chart Portlet

...

 

 Repository 中建立一個 Filter Panel 定義文件

在這個實例中,在 samples/simpleDashboard/simple-dashboard. filterpanel.xml 中指定 filter panel。

<filters><name>CustomerNamesFilter</name>

<filter>

<!-- Title text displayed in the filter panel --> <title>Customer</title>

<!-- name and id of the HTML form control representing this filter --> <name>customernumber< /name>

<!-- type of control to display in the filter panel --> <type>list</type>

<data-solution>samples</data-solution> <data-path>simpleDashboard</data-path> <data-action>getCustomerNames .xaction</data-action>

<!-- name of the action sequence's output parameter containing the LOV --> <data-output>customerNamesList</data-output> <!-- maps to the <option> element's text --> <data-display>customername</data-display> <!-- maps to the <option> element's value attribute in the HTML form --><data-value>customernumber</data-value>

</ filter>

</filters>

每一個 filter panel 定義文件定義了一個 filter panel 的 filters。每一個 filter 對應於用戶接口上的一個控件(UI) (例如 comboboxes,lists,radio buttons等) 這些控件用於 "filter" 平臺返回的數據。

建立一個 filter 定義,經過在 filter panel 定義文件的根節點(如 <filters>)上添加一個 <filter> 元素,而後在 <filter> 元素上添加適當的子元素。在 filter panel 上可指定 4 種不一樣的 filter 類型。每種類型使用一個不一樣的機制,用於獲取它的 LOV。經過在  <filter> 元素上添加一個或多個不一樣的子元素來指定獲取 LOV 的機制。

除了 <filter> 元素的一套不一樣子元素,還有一套全部 <filter> 元素共同擁有的元素。

List of Values (LOV)

A List of Values (LOV) 是描述 items 的列表的一個術語,每一個 item 有一個名字和一個值。一個實例可能跨越了一年中的數月,第一個 item 的名字是 Jan,其值是 0,第二個 item 的名字是 Feb,其值是 等等。

在一個用戶接口中,當一個用戶須要從不少 items 中選擇一個時,爲用戶顯示 LOV 中的每一個 item 的名字, 當用戶做出一個選擇時,將選中的 item 的值傳送到服務器。

 

公有元素

(* 必需元素)

Ø         <title> title 元素的文本,其在 HTML form 中顯示爲 filter 的 label。

Ø         <name> * 用於設置表單中的 HTML 控件的 name 和 id 屬性。例如,若是這個 filter 是用於生成一個列表(在 HTML 中也叫作 <select> 元素),<select> 元素的 id 和 name 屬性將被設置成 <name> 元素的文本。

Ø         <type> 在 filter panel 中放置的 HTML 控件的類型。若是沒有這個元素,或其值不能識別,生成一個 <select> 控件(又叫作複選框)。被識別的值有:

o      radio: 建立一套 radio buttons

o      list: 建立一個列表框

o      list-multi: 建立一個具備多個選擇的選擇列表

o      check-multi: 建立一套複選框,全部可見

o      check-multi-scroll: 在一個可滾動的面板裏建立一套檢查框

o      check-multi-scroll-2-column: 在一個可滾動的面板裏建立 2 列檢查框

o         check-multi-scroll-3-column: 在一個可滾動的面板裏建立 3 列檢查框

o         check-multi-scroll-4-column: 在一個可滾動的面板裏建立 4 列檢查框

Ø         <data-display> * LOV 中的列名,其用於提供 UI 顯示文本。例如若是 filter panel 的類型是 list,這列的值用於提供列表框中的文本。

Ø         <data-value> * LOV 中的列名,其用於提供和 UI 顯示文本相關的值。這些是當表單提交到服務器時,要發送的值。

Elements Unique to Each Filter Type

filter panel 中的每一個 filter 可從如下 4 種源獲取它的 list-of-values (LOV):

1.       session scoped 參數

2.       全局參數

3.       action sequence 輸出

4.       <filter> 元素的 body 中定義的 static list

Session Scoped 參數

爲配置 filter panel,從一個 session scoped 參數中獲取它的 LOV,添加 <session-attribute> 做爲 <filter> 元素的 child。元素的文本是一個 session scoped 參數的名字,其包含LOV。這個參數必須是如下類型之一:list,result-set(TODO 其餘是什麼?)。

Global Scoped 參數

爲配置 filter panel,從全局參數中獲取它的 LOV,添加 <global-attribute> 做爲 <filter> 元素的 child。元素的文本是包含 LOV 的全局參數的名字。這個參數必須是如下類型之一:list,result-set(TODO 其餘是什麼?)。

Action Sequence 輸出

爲配置 filter panel,從一個 Action Sequence 中獲取它的 LOV,添加元素 <data-solution>,<data-path>,<data-action> 和 <data-output> 做爲 <filter> 元素的 children。每一個元素的文本應該是:

Ø         <data-solution>: solution-repository 中的 solution 的名字,其包含 Action Sequence 定義文件。 例如,在 PCI solution-repository 的目錄中叫作 pentaho-solutions。solution 自身包含在solution-repository 目錄中。例如,PCI 自帶的 solutions 叫:samples,admin 和 test solutions。

Ø         <data-path>: 從 solution 到 Action Sequence 定義文件的路徑。

Ø         <data-action>: Action Sequence 定義文件的名字。

Ø         <data-output>: 若是這個元素存在,它的文本應該是 Action Sequence 將 LOV 放置其中的Action Sequence 輸出參數的名字。若是這個元素不存在,filter panel 將在名爲 resultset的Action Sequence 的輸出參數中尋找 LOV。

Static List

配置 filter panel,從 filter panel 定義文件中的 static list 獲取它的 LOV。

Static LOV 還不可用

用一個 static list 初始化一個 LOV 將在下一個版本中可用。

 

建立 Action Sequences 爲 Filter Panel's Controls 提供list-of-values (LOV) 數據

在這個實例中,在 samples/simpleDashboard/getCustomerNames.xaction 中建立了 action sequence。這個 Action Sequence 包含一個單獨的 Action,其運行一個 SQL 查詢,獲取客戶名和至少發了一個訂單的客戶的數量。注意列名 (customername, customernumber) 映射到 filter panel 定義文件中的 <data-display> 和 <data-value> 元素。也注意到 action sequence中的 Result Set Name (customerNamesList) 映射到 <data-output> 元素。Result Set 的值顯示在 filter panel's form 的 list 控件中。

建立和頁面中的其餘 Portlets 相關的 Action Sequences

在這個簡單的實例中,在頁面中僅有一個 portlet,SimplePieChartPortlet portlet (使用類 ActionPortlet 實現)。

你想起 SimplePieChartPortlet 的優先選擇,指定應該運行samples/simpleDashboard/JFree_ChartComponent.xaction Action Sequence。這個 Action Sequence 響應 filter panel 所放置的session 參數的改變,提供了商業數據的視圖。

這個 Action Sequence 包含:

1.       一個 Relational action,其獲取要在 pie chart 上顯示的數據。

2.       一個 Pie Chart action,其使用數據在服務器上建立一個 pie chart image。

3.       一個 Message Template,其建立一個 HTML fragment 將 pie chart image 放進 portlet 中。

Relational action 在 SimpleData 數據庫上運行一個查詢,肯定一個特定顧客最優先購買的 5 種產品。在這個實例中,我正使用一個 pie chart。一般,對於一個 pie chart,你須要 2 列數據。第一列肯定 pie slice 的 label,第二列肯定 pie slice 的相對數量。行數肯定了 slices 的數量。

在這個實例中,第一列包含購買的產品,第二列包含購買的產品的數量。

注意查詢中的 customernumber 來自 session scoped 輸入 customernumber。這個值由 filter panel 放進了session 中。

Pie Chart action 在服務器上生成一個.png 文件,其包含 pie chart image。注意 chart-filename 和 base-url 輸出。這些輸出由 Pie Chart action 自動建立。chart-filename 中有包含 pie chart image 的文件的名字。base-url 包含 pie chart image 文件的 portal 相關的 URL。Message Template action 繼續執行,建立引用服務器上的 chart image 的 HTML <img> tag。

Pie Chart 的默認行爲在 Portlet 中不生效

Pie Chart action 的缺省行爲就是生成一個包含 chart image 的完整 HTML 頁面。這對一個 JSP  Servlet 是適當的。然而,portlet 中的 HTML 包含一個 HTML fragment,而不是完整的 HTML 頁面。

能夠修改默認行爲,經過爲 Pie Chart action 指定輸出。幸運的,Pie Chart action 提供了 chart-filename base-url 輸出。經過爲 Pie Chart action 指定這些輸出,它們將對 Action Sequence 中剩下的 actions 可用。

Message Template action 建立一個 HTML <img> 元素,其引用服務器上的 chart's image 文件。Message Template 能構造一個具備有效 src 屬性的 HTML <img> 元素,經過合併 Pie Chartaction 的 base-url 和 chart-filename 輸入以引用服務器上生成的圖像文件。這個 action 的輸出(imgtag) 是一個 HTML fragment,其被添加到 Action Sequence 的輸出。

Action Sequence 的輸出(例如 HTML fragment) 由 ActionPortlet 捕獲。ActionPortlet 將這個 HTML fragment 傳送到 Portal,以和頁面上其餘 portlets 生成的 HTML fragments 進行聚合。而後聚合後的 HTML 內容被髮送回瀏覽器,以顯示 portal dashboard。

爲了方便,我已經包含了 JFree_ChartComponent Action Sequence 的 XML。

<?xml version="1 .0" encoding="UTF-8"?> <action-sequence>

<name>JFree_ChartComponent . xaction</name> <title>Simple Chart</title>

<version> 1</version>

<logging-level>DEBUG< /logging-level> <documentation>

<author>Steven Barkdull</author>

<description>Creates a chart image based on a SQL query</description>

<icon/>

<help>You R going to need it.</help> <result-type>rule</result-type> </documentation>

<inputs>

<chart-type type="string">

<default-value>.png</default-value> <sources>

<request>type</request>

</sources>

</chart-type>

<customernumber type="string">

<sources>

<session>customernumber</session> </sources>

<default-value><![ CDATA[ 141]] ></default-value>

</customernumber>

</inputs>

<outputs>

<imgtag type="string">

<destinations>

<response>content</response> </destinations>

</ imgtag>

</outputs>

<resources/>

<actions>

<action-definition>

<component -name> SQLLookupRule< /component-name>

<action-type>Query For Chart Data</action-type>

<action-inputs>

<customernumber type="string"/>

</action-inputs> <action-outputs>

<query-result type="result-set" mapping="chartData"/>

</action-outputs> <component-definition>

<source> sql</source>

<live>true< /live> <jndi>SampleData</j ndi>

<query><![ CDATA[

select top 5 products.productname, count( orderfact.productcode) as Amount

from orderfact inner join products on orderfact.productcode = products.productcode and orderfact.customernumber = { PREPARE:customernumber}

group by orderfact.productcode, products.productname] ] ></query> </component-definition>

</action-definition>

<action-definition>

<component -name>ChartComponent< /component -name> <action-type>Create The Chart</action-type>

<action-inputs>

<output-type type=" string" mapping="chart-type" /> <chart-data type="result-set" mapping=" chartData" /></action-inputs>

<action-outputs>

<chart-filename type="string"/>

<base-url type="string"/>

</action-outputs>

<component-definition>

<by-row> false</by-row>

<height> 400</height>

<width> 600</width>

<title>Top 5 Models Sold by Customer</title>

<chart-attributes>

<!-- this is the background for the whole image --> <!-- TODO support gradient and texture painting --> <chart-type>PieChart< /chart-type>

<title-position>TOP</title-position>

<height/>

<width/>

<title/>

<title-font>

<font-family>Serif</font-family>

<size>36</size>

<is-bold>false</is-bold>

<is-italic>false</is-italic>

</title-font>

<range-title>US Dollars</range-title>

<chart-background type="color">#FFFFFF</chart-background> <plot-background-color>#FF000 0</plot-background-color><orientation>Horizontal</orientation>

<is-3D>false</is-3D>

<is-stacked>false</is-stacked>

<category-label-rotation> 0</category-label-rotation> <border-visible>false</border-vis ible>

<border-paint>#33 99FF</border-paint>

<include-legend>true< /include-legend>

</chart-attributes>

</component-definition>

</action-definition>

<action-definition>

<component -name>TemplateComponent< /component-name> <action-type>Message Template</action-type> <action-inputs>

<base-url type="string"/>

<chart-filename type="string"/>

</action-inputs>

<action-outputs>

<output-message type="string" mapping="imgtag"/> </action-outputs>

<component-definition>

<template><![ CDATA[ <img src="{ base-url} /get Image? image={ chart-f ilename}"

/>]] ></template>

</component-definition>

</action-definition>

</actions> </action-sequence>

建立一個 JNDI 可訪問的 Datasource 爲 Action Sequences 提供數據

在 PCI 中,指定 datasources,經過在 PCI 的 server/default/deploy 文件夾下添加一個 XML 文件。文件的名字必須以 "-ds.xml" 結束。

這個實例使用 SampleData JNDI 名字來引用它的 datasource。SampleData 的配置文件叫sampledata-ds.xml,以下所示:

<?xml version="1 .0" encoding="UTF-8"?> <datasources>

<local-tx-datasource>

<j ndi-name> SampleData</j ndi-name>

<connection-url>j dbc : hsqldb : hsql: //localhost: 9001/sampledata</connection-url> <driver-class>org . hsqldb. j dbcDriver</driver-class>

<user-name>pentaho_user</user-name> <pas sword>password< /pas sword> <check-valid-connection-sql>

select count(*) from INFORMATION _SCHEMA. SYSTEM_SEQUENCES

</check-valid-connection-sql> </ local-tx-datasource>

</datasources>

配置 JNDI Datasources for use in Pentaho BI Platform有在 PCI 中建立 JNDI datasources 的更多信息。

使用一個 System Action 改善 Filter Panel 的性能

filter panel 的當前配置每次從數據庫獲取 list-of-values (LOV)。filter panel 在 portal 頁面中呈現。對於不多改變的 LOV,以這個頻率獲取數據,將會在數據庫服務器上引起沒必要要的負載。

經過如下方式,咱們可減小負載:

1.       配置一個 System Action 當平臺啓動時,一次從數據庫獲取值的列表,將之放進一個全局參數中。而後這個全局參數可用做任何 Action Sequence 的輸入。

2.       修改 filter panel 的定義從全局參數獲取 LOV,而不是運行 getCustomerNames Action Sequence 訪問 LOV。

3.       修改 getCustomerNames Action Sequence 確保它關閉了數據庫鏈接,將查詢的結果存儲在一個disconnected result set 中。

配置 System Action

簡單的說,一個 System Action 是一個 Action Sequence,其被配置運行於系統啓動時,或 session 啓動時。System Actions 在 repository 的系統配置文件中進行配置,一般稱做pentaho.xml。配置 System Actions 的詳細信息請參考文章 System Actions。

在系統配置文件中添加如下 xml fragment 將致使在系統啓動時,運行getCustomerNames.xaction,那個 action sequence 的輸出做爲全局參數,可用於 portlets。

<pentaho-system>

...

<system-actions>

...

<org.pentaho.ui.portlet.PentahoPortletSession scope="global">

samples/simpleDashboardUsingSystemAction/getCustomerNames.xaction </org.pentaho.ui.portlet. PentahoPortletSession>

... </system-actions>

...

</pentaho-system>

 

修改 Filter Panel

修改 filter panel 的定義:刪除節點 <data-solution>,<data-path>,<data-action> 和 <data-output>,用節點 <global-attribute> 替換它們。<global-attribute> 節點的文本應該和最初的 filter panel 配置文件中的 <data-output> 節點的文本同樣(例如 getCustomerNames Action Sequence 輸出的名字)。

在平臺的 Pre-1.6 版本中配置 Filter Panel

在平臺的 pre-1.6 版本中,不是使用 <global-attribute> 元素來標識輸入的名字,而是使用 <session-attribute> 元素。

<filters>

<name>CustomerNamesFilter</name>

<filter>

<!-- Title text displayed in the filter panel -->

<title>Customer</title>

<!-- name and id of the HTML form control representing this filter --> <name>customernumber< /name>

<!-- type of control to display in the filter panel -->

<type>list</type>

<!-- name of global scoped parameter containing the LOV --> <global-attribute>customerNamesList</global-attribute>

<!-- maps to the <option> element's text -->

<data-display>customername</data-display>

<!-- maps to the <option> element's value attribute in the HTML form --> <data-value>customernumber</data-value>

</ filter>

</filters>

 

修改 getCustomerNames Action Sequence 確保它關閉了它的數據庫鏈接

在 Relational action 中,默認選中 Keep Connection Open 複選框。你須要取消選中這個複選框。

"Keep Connections Open" 是什麼意思?

若是沒有選中 Keep Connections Open,當一個 Relational action 運行一個數據庫查詢時,它當即將查詢的結果存儲進一個 light-weight java 對象中,並關閉到數據庫的鏈接。這個 light-weight java 對象可被存儲爲請求中的一個參數,session  global scope。這使得對象可用於 action sequence 中的其餘 actions,以及在其餘時間運行的其餘action sequences。然而結果常常很大,使得將內容複製進一個 light-weight java 對象很昂貴。同時將這兩個對象臨時保存在內存中也很昂貴。在這種狀況下,選中 "Keep Connections Open" 就頗有意義。這將致使 result-set 到數據庫的鏈接處於 open 狀態。result-set 對這個 action sequence 中的其餘 actions 可用。不會對 light-weight java 對象做一個副本。在全部狀況下,執行完 action sequence,就會關閉到數據庫的鏈接。這就暗示選中了 "Keep Connections Open" 以後建立的 result set不會是 session  global scope,由於當前 action sequence 執行完後,就會關閉 result set 的鏈接,使之不可用。

你須要重啓你的服務器,使得這些改變生效。

測試 Portal-based Dashboard 實例文件

portlet.xml

portlet-instances.xml

pentaho-portal-object.xml

simple-dashboard.filterpanel.xml

JFree ChartComponent.xaction

getCustomerNames.xaction

alternate simple-dashboard.filterpanel.xml  pentaho.xml

相關文章
相關標籤/搜索