Debian Codegraph @

source/org/jfree/report/flow/flowing/FlowReportProcessor.java

raw
1 /**
2 * ========================================
3 * JFreeReport : a free Java report library
4 * ========================================
5 *
6 * Project Info: http://reporting.pentaho.org/
7 *
8 * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
9 *
10 * This library is free software; you can redistribute it and/or modify it under the terms
11 * of the GNU Lesser General Public License as published by the Free Software Foundation;
12 * either version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License along with this
19 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
23 * in the United States and other countries.]
24 *
25 * ------------
26 * $Id: FlowReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
27 * ------------
28 * (C) Copyright 2000-2005, by Object Refinery Limited.
29 * (C) Copyright 2005-2007, by Pentaho Corporation.
30 */
31 package org.jfree.report.flow.flowing;
32
33 import org.jfree.layouting.ChainingLayoutProcess;
34 import org.jfree.layouting.DefaultLayoutProcess;
35 import org.jfree.layouting.LayoutProcess;
36 import org.jfree.layouting.output.OutputProcessor;
37 import org.jfree.report.DataSourceException;
38 import org.jfree.report.ReportDataFactoryException;
39 import org.jfree.report.ReportProcessingException;
40 import org.jfree.report.flow.AbstractReportProcessor;
41 import org.jfree.report.flow.LibLayoutReportTarget;
42 import org.jfree.report.flow.ReportJob;
43 import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
44 import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
45
46 /**
47 * This is written to use LibLayout. It will never work with other report
48 * targets.
49 *
50 * @author Thomas Morgner
51 */
52 public class FlowReportProcessor extends AbstractReportProcessor
53 {
54 private OutputProcessor outputProcessor;
55
56 public FlowReportProcessor()
57 {
58 }
59
60 public OutputProcessor getOutputProcessor()
61 {
62 return outputProcessor;
63 }
64
65 public void setOutputProcessor(final OutputProcessor outputProcessor)
66 {
67 this.outputProcessor = outputProcessor;
68 }
69
70 protected LibLayoutReportTarget createTarget(final ReportJob job)
71 {
72 if (outputProcessor == null)
73 {
74 throw new IllegalStateException(
75 "OutputProcessor is invalid.");
76 }
77 final LayoutProcess layoutProcess =
78 new ChainingLayoutProcess(new DefaultLayoutProcess(outputProcessor));
79 final ResourceManager resourceManager = job.getReportStructureRoot().getResourceManager();
80 final ResourceKey resourceKey = job.getReportStructureRoot().getBaseResource();
81
82 return new LibLayoutReportTarget
83 (job, resourceKey, resourceManager, layoutProcess);
84 }
85
86 /**
87 * Bootstraps the local report processing. This way of executing the report
88 * must be supported by *all* report processor implementations. It should
89 * fully process the complete report.
90 *
91 * @param job
92 * @throws ReportDataFactoryException
93 */
94 public void processReport (final ReportJob job)
95 throws ReportDataFactoryException, DataSourceException,
96 ReportProcessingException
97 {
98 if (job == null)
99 {
100 throw new NullPointerException();
101 }
102
103 synchronized (job)
104 {
105 // first, compute the globals
106 processReportRun(job, createTarget(job));
107 // second, paginate (this splits the stream into flows)
108 processReportRun(job, createTarget(job));
109 // third, generate the content.
110 processReportRun(job, createTarget(job));
111 }
112 }
113
114 }