Pentaho Reporting 3.5 for Java Developers- P8 - Pdf 72

Chapter 12
[
333
]
You'll need to update the Ant le with a new
runmeta
target, as well as a new path
reference. Add the following XML to the
chapter11/build.xml
le:
<path id="runtime_classpath">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<dirset dir="classes"/>
</path>

<target name="runmeta" depends="jar">
<java fork="true" classpathref="runtime_classpath" classname="Meta
TableModelDemo"/>
</target>
Now type
ant runmeta
on the command line. The PDF le
metadata_table.pdf

will be created in the root of the project. Open the PDF. Your results should look
something like this:
Note that the background
bg-color
attribute is taking effect, but the report header

to the reporting engine's
label
attribute. Finally, you'll need to tell the reporting engine about this data
schema le. Add the following property to
configuration.properties
, which
already exists in the
chapter11/src
folder:
# specify the data schema location
org.pentaho.reporting.engine.classic.core.DataSchemaDefinition.
exampleDomain=res://dataschema.xml
The reporting engine looks for all properties that begin with
org.pentaho.
reporting.engine.classic.core.DataSchemaDefinition
, loading all the
mappings dened in those les. Now re-run the report by typing
ant runmeta
,
and re-open the
metadata_table.pdf
le. Your report should now look like this:
The report is now fully utilizing the attributes dened in the
DefaultMetaTableModel
implementation.
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Chapter 12
[
335

interface, as well as the
OutputProcessorMetaData
interface.
The
OutputProcessor
and
OutputProcessorMetaData
interfaces are located in
the
org.pentaho.reporting.engine.classic.core.layout.output
package.
The OutputProcessorMetaData interface
The
OutputProcessorMetaData
interface provides a general metadata
interface for the
OutputProcessor
, including which features and content are
supported, as well as providing access to the report conguration along with
access to font metric details. The class
AbstractOutputProcessorMetaData

is available, which implements the common set of functionality across the
various output implementations. As an example, the Excel implementation of
OutputProcessorMetaData
congures the various features of Excel rendering
based on conguration properties, while the PDF implementation also overrides
some of the default font behavior for translation into the PDF format.
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

traverses the logical page,
providing direct access to each physical page within the page grid. The
AbstractTableOutputProcessor
provides a attened two dimensional
structure of the report, useful for rendering cell based formats. The
AbstractTableOutputProcessor
also implements the
IterativeOutputProcessor

interface, an extension to the
OutputProcessor
interface, which allows for
iterative rendering.
RenderNode Document Object Model
The
OutputProcessor
receives the report model in a
RenderNode
Document
Object Model, which it translates to a specic output. The
RenderNode
class,
located in the
org.pentaho.reporting.engine.classic.core.layout.model

package, is the base of the
RenderNode
DOM and denes a set of core attributes.
Child classes add additional metadata. For instance, the
RenderBox

[
337
]
Updating Report Designer
To expose a custom output format in Report Designer, you must implement a
DesignerContextAction
located in the
org.pentaho.reporting.designer.core.
actions
package of Report Designer. The
org.pentaho.reporting.designer.
core.actions.report.preview
package contains the default implementations
as examples. These examples contain the user interface and report generation code,
allowing previews in the various supported formats.
To add the action to Report Designer's menu system, edit the
designer-frame.xul

le located in the
org.pentaho.reporting.designer.core.xul
package. Find the
file-preview-popup
menu pop up element in the XUL le, and add a new menu
item with reference to the action class name.
Under the covers, the Report Designer uses its own
OutputProcessor
, the
DesignerOutputProcessor
, which only works with the logical page model, for
rendering of the report in design mode. This guarantees compatibility between the

import org.pentaho.reporting.engine.classic.core.layout.output.
AbstractOutputProcessorMetaData;
import org.pentaho.reporting.libraries.base.config.Configuration;
public class PojoOutputMetaData extends
AbstractOutputProcessorMetaData {
// Define a basic constructor that calls its super.
public PojoOutputMetaData(final Configuration configuration) {
super(configuration);
}
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Additional Pentaho Reporting Topics
[
338
]
// Provide an export descriptor.
public String getExportDescriptor() {
return "stream/pojo";
}
}
Now you'll begin to build the
PojoOutputProcessor
class. This class implements
the
OutputProcessor
interface, and manages the creation of the list of plain old
Java objects, which will contain an x and y coordinate, along with the text associated
with that location. Comments have been placed in the source that describe the
inner workings of this very simple example. Create the le
chapter11/src/

// rendering the report
public static class PojoObject {
// Define the x location of the PojoObject.
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Chapter 12
[
339
]
int x;
// Define the y location of the PojoObject.
int y;
// Define the text extracted during report rendering.
String text = "";
}

// Define a reference to the PojoOutputMetaData class.
PojoOutputMetaData metadata;
// Define a list of the pojo objects you're about to generate.
List<PojoObject> pojoObjects = new ArrayList<PojoObject>();
// The constructor creates a new metadata object.
public PojoOutputProcessor(final Configuration configuration) {
metadata = new PojoOutputMetaData(configuration);
}
// The processPageContent callback renders a report page from
// a LogicalPageBox. This method is called by
// the ReportProcessor when the page content is ready
// for rendering.
protected void processPageContent(LogicalPageKey logicalPageKey,
LogicalPageBox logicalPage) throws

// on a ParagraphPoolBox, which contains text and spacer
// nodes.
public void handleParagraph(ParagraphPoolBox box) {
RenderNode node = box.getFirstChild();
// Create a PojoObject with x and y coordinates.
PojoObject object = new PojoObject();
object.x = (int)node.getX() / 1000;
object.y = (int)node.getY() / 1000;
// Populate the PojoObject's text appropriately.
while (node != null) {
if (node instanceof RenderableText) {
object.text += ((RenderableText)node).
getRawText();
} else if (node instanceof SpacerRenderNode) {
for (int i = 0; i < ((SpacerRenderNode)node).
getSpaceCount(); i++) {
object.text += " ";
}
}
node = node.getNext();
}
// Add the PojoObject to the list.
pojoObjects.add(object);
}
// Return a reference to the custom OutputProcessorMetaData
// instance.
public OutputProcessorMetaData getMetaData() {
return metadata;
}
// Allow access to the generated PojoObject list.

import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
public class PojoUtil {
// The createPojoReport method generates a PojoObject
// list from a report.
public static List<PojoOutputProcessor.PojoObject>
createPojoReport(final MasterReport report)
throws ReportProcessingException, IOException {
// Instantiate a target PojoOutputProcessor class,
// passing in the report configuration.
final PojoOutputProcessor target = new
PojoOutputProcessor(report.getConfiguration());
// Instantiate a StreamReportProcessor with references
// to the report and the OutputProcessor.
final StreamReportProcessor reportProcessor = new
StreamReportProcessor(report, target);
// Process the report.
reportProcessor.processReport();
// Close the report after processing.
reportProcessor.close();
// Return a list of the plain old Java objects
// generated from this report.
return target.getPojoObjects();
}
// The main method generates a plain old Java object
// output from the simple report defined earlier.
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Additional Pentaho Reporting Topics
[
342

Type
ant runpojo
to see the results. You should see a printout that looks
something like this:
In this example, you created the simplest of output formats, the plain old Java
object
OutputProcessor
, demonstrating the implementation and use of an
OutputProcessor
within the reporting engine.
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Chapter 12
[
343
]
The Pentaho community—getting help
and contributing
As an open source project, Pentaho Reporting has a community of people and
organizations who contribute through answering questions, contributing translations,
ling and xing bugs, writing documentation, and of course, contributing code. To
make sure you can nd what you need to engage the Pentaho Reporting community.
The following is the list of online places and tools to help you get started.
Asking questions, helping others
Today, there are two primary methods of communication within the Pentaho
Reporting community. The rst and most widely used are the Pentaho Reporting
forums. These forums are located at
/> under the main
category Reporting. Thomas Morgner, the founder and primary architect of Pentaho
Reporting, also known as Taqua in the forums, has over 4,800 posts and is always

.
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Additional Pentaho Reporting Topics
[
344
]
Pentaho Reporting is broken out into two main projects—the Pentaho Reporting
Engine and the Pentaho Report Designer. Each project contains a Road Map link,
containing a list of prioritized activities that Pentaho and the open source community
are working on.
Contributing code
If you'd like to add a new feature to Pentaho Reporting or x a bug, the source code
for the reporting engine and Report Designer is easily accessible. Pentaho hosts the
reporting project's SVN server at
/>.
The reporting engine's core source code is located in the
engines/classic
sub-folder,
and the Report Designer is located in the
tools/report-designer
sub-folder. By
going to
/>, you can
browse the source and version changes using your browser.
Once you've made your change, you can submit your patch to Pentaho's JIRA
system. If you become a regular contributor, often Thomas will grant you direct
commit access to SVN.
One of the many types of contributions Pentaho receives includes translated message
bundles. These message bundles are located within the reporting projects, and can be

learning where to set up database connections and add users to the BI Server. You
also were introduced to mobile reporting, which included a reference to Pentaho's
iPhone BI Extension.
Also in this chapter, you discovered Pentaho Reporting's data source metadata
capabilities by implementing your own
MetaTableModel
class. You were introduced
to Pentaho Reporting's output rendering API through a simple plain old Java object
output example.
Finally, you learned more about the Pentaho Reporting community, including where
to go to ask questions, le bugs, and how to contribute back to Pentaho's open source
reporting projects.
Thank you for taking the time to read this book. I hope you learned a lot along
the way, and are excited about using Pentaho Reporting to solve your business
reporting needs!
This material is copyright and is licensed for the sole use by David Martone on 16th September 2009
710 South Avenue West, , Westfield, , 07090Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status