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