1*1a37d047SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1a37d047SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1a37d047SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1a37d047SAndrew Rist  * distributed with this work for additional information
6*1a37d047SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1a37d047SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1a37d047SAndrew Rist  * "License"); you may not use this file except in compliance
9*1a37d047SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1a37d047SAndrew Rist  *
11*1a37d047SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1a37d047SAndrew Rist  *
13*1a37d047SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1a37d047SAndrew Rist  * software distributed under the License is distributed on an
15*1a37d047SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1a37d047SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1a37d047SAndrew Rist  * specific language governing permissions and limitations
18*1a37d047SAndrew Rist  * under the License.
19*1a37d047SAndrew Rist  *
20*1a37d047SAndrew Rist  *************************************************************/
21*1a37d047SAndrew Rist 
22*1a37d047SAndrew Rist 
23cdf0e10cSrcweir package com.sun.star.report.pentaho.output.chart;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.report.DataSourceFactory;
26cdf0e10cSrcweir import com.sun.star.report.ImageService;
27cdf0e10cSrcweir import com.sun.star.report.InputRepository;
28cdf0e10cSrcweir import com.sun.star.report.OutputRepository;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir import org.jfree.report.DataSourceException;
31cdf0e10cSrcweir import org.jfree.report.ReportDataFactoryException;
32cdf0e10cSrcweir import org.jfree.report.ReportProcessingException;
33cdf0e10cSrcweir import org.jfree.report.flow.ReportJob;
34cdf0e10cSrcweir import org.jfree.report.flow.ReportStructureRoot;
35cdf0e10cSrcweir import org.jfree.report.flow.ReportTarget;
36cdf0e10cSrcweir import org.jfree.report.flow.SinglePassReportProcessor;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir /**
41cdf0e10cSrcweir  *
42cdf0e10cSrcweir  * @author Ocke Janssen
43cdf0e10cSrcweir  */
44cdf0e10cSrcweir public class ChartRawReportProcessor extends SinglePassReportProcessor
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     private final OutputRepository outputRepository;
48cdf0e10cSrcweir     private final String targetName;
49cdf0e10cSrcweir     private final InputRepository inputRepository;
50cdf0e10cSrcweir     private final ImageService imageService;
51cdf0e10cSrcweir     private final DataSourceFactory dataSourceFactory;
52cdf0e10cSrcweir 
ChartRawReportProcessor(final InputRepository inputRepository, final OutputRepository outputRepository, final String targetName, final ImageService imageService, final DataSourceFactory dataSourceFactory)53cdf0e10cSrcweir     public ChartRawReportProcessor(final InputRepository inputRepository,
54cdf0e10cSrcweir             final OutputRepository outputRepository,
55cdf0e10cSrcweir             final String targetName,
56cdf0e10cSrcweir             final ImageService imageService,
57cdf0e10cSrcweir             final DataSourceFactory dataSourceFactory)
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir         if (inputRepository == null)
60cdf0e10cSrcweir         {
61cdf0e10cSrcweir             throw new NullPointerException();
62cdf0e10cSrcweir         }
63cdf0e10cSrcweir         if (outputRepository == null)
64cdf0e10cSrcweir         {
65cdf0e10cSrcweir             throw new NullPointerException();
66cdf0e10cSrcweir         }
67cdf0e10cSrcweir         if (targetName == null)
68cdf0e10cSrcweir         {
69cdf0e10cSrcweir             throw new NullPointerException();
70cdf0e10cSrcweir         }
71cdf0e10cSrcweir         if (imageService == null)
72cdf0e10cSrcweir         {
73cdf0e10cSrcweir             throw new NullPointerException();
74cdf0e10cSrcweir         }
75cdf0e10cSrcweir         if (dataSourceFactory == null)
76cdf0e10cSrcweir         {
77cdf0e10cSrcweir             throw new NullPointerException();
78cdf0e10cSrcweir         }
79cdf0e10cSrcweir         this.targetName = targetName;
80cdf0e10cSrcweir         this.inputRepository = inputRepository;
81cdf0e10cSrcweir         this.outputRepository = outputRepository;
82cdf0e10cSrcweir         this.imageService = imageService;
83cdf0e10cSrcweir         this.dataSourceFactory = dataSourceFactory;
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
createReportTarget(final ReportJob job)86cdf0e10cSrcweir     protected ReportTarget createReportTarget(final ReportJob job)
87cdf0e10cSrcweir             throws ReportProcessingException
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir         final ReportStructureRoot report = job.getReportStructureRoot();
90cdf0e10cSrcweir         final ResourceManager resourceManager = report.getResourceManager();
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         return new ChartRawReportTarget(job, resourceManager, report.getBaseResource(),
93cdf0e10cSrcweir                 inputRepository, outputRepository, targetName, imageService, dataSourceFactory);
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir 
processReport(final ReportJob job)96cdf0e10cSrcweir     public void processReport(final ReportJob job) throws ReportDataFactoryException, DataSourceException,
97cdf0e10cSrcweir             ReportProcessingException
98cdf0e10cSrcweir     {
99cdf0e10cSrcweir         final ReportTarget reportTarget = createReportTarget(job);
100cdf0e10cSrcweir         processReportRun(job, reportTarget);
101cdf0e10cSrcweir     }
102cdf0e10cSrcweir }
103