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.util;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.report.DataSourceFactory;
26cdf0e10cSrcweir import com.sun.star.report.InputRepository;
27cdf0e10cSrcweir import com.sun.star.report.JobDefinitionException;
28cdf0e10cSrcweir import com.sun.star.report.JobProperties;
29cdf0e10cSrcweir import com.sun.star.report.OutputRepository;
30cdf0e10cSrcweir import com.sun.star.report.ParameterMap;
31cdf0e10cSrcweir import com.sun.star.report.ReportEngineMetaData;
32cdf0e10cSrcweir import com.sun.star.report.ReportEngineParameterNames;
33cdf0e10cSrcweir import com.sun.star.report.ReportJobDefinition;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir public class DefaultReportJobDefinition implements ReportJobDefinition
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 
38cdf0e10cSrcweir     public static final String OUTPUT_TYPE = "output-type";
39cdf0e10cSrcweir     private final DefaultParameterMap parameters;
40cdf0e10cSrcweir     private final DefaultJobProperties properties;
41cdf0e10cSrcweir 
DefaultReportJobDefinition(final ReportEngineMetaData metaData)42cdf0e10cSrcweir     public DefaultReportJobDefinition(final ReportEngineMetaData metaData)
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         this.parameters = new DefaultParameterMap();
45cdf0e10cSrcweir         this.properties = new DefaultJobProperties(metaData);
46cdf0e10cSrcweir     }
47cdf0e10cSrcweir 
setDataSourceFactory(final DataSourceFactory dataSourceFactory)48cdf0e10cSrcweir     public void setDataSourceFactory(final DataSourceFactory dataSourceFactory)
49cdf0e10cSrcweir             throws JobDefinitionException
50cdf0e10cSrcweir     {
51cdf0e10cSrcweir         this.properties.setProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY, dataSourceFactory);
52cdf0e10cSrcweir     }
53cdf0e10cSrcweir 
getDataSourceFactory()54cdf0e10cSrcweir     public DataSourceFactory getDataSourceFactory()
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         return (DataSourceFactory) this.properties.getProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY);
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir 
getInputRepository()59cdf0e10cSrcweir     public InputRepository getInputRepository()
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         return (InputRepository) this.properties.getProperty(ReportEngineParameterNames.INPUT_REPOSITORY);
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir 
setInputRepository(final InputRepository inputRepository)64cdf0e10cSrcweir     public void setInputRepository(final InputRepository inputRepository)
65cdf0e10cSrcweir             throws JobDefinitionException
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir         this.properties.setProperty(ReportEngineParameterNames.INPUT_REPOSITORY, inputRepository);
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir 
getOutputRepository()70cdf0e10cSrcweir     public OutputRepository getOutputRepository()
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir         return (OutputRepository) this.properties.getProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY);
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir 
setOutputRepository(final OutputRepository outputRepository)75cdf0e10cSrcweir     public void setOutputRepository(final OutputRepository outputRepository)
76cdf0e10cSrcweir             throws JobDefinitionException
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         this.properties.setProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY, outputRepository);
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     /**
82cdf0e10cSrcweir      * The parameters of the root report definition. The parameters for the subreports are
83cdf0e10cSrcweir      * defined using mappings, it would not make sense to define them here.
84cdf0e10cSrcweir      *
85cdf0e10cSrcweir      * @return a map container for query parameters.
86cdf0e10cSrcweir      */
getQueryParameters()87cdf0e10cSrcweir     public ParameterMap getQueryParameters()
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir         return parameters;
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir 
setReportDefinitionName(final String reportDefinitionName)92cdf0e10cSrcweir     public void setReportDefinitionName(final String reportDefinitionName)
93cdf0e10cSrcweir             throws JobDefinitionException
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         this.properties.setProperty(ReportEngineParameterNames.INPUT_NAME, reportDefinitionName);
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     /**
99cdf0e10cSrcweir      * The name under which we can load the report definition.
100cdf0e10cSrcweir      *
101cdf0e10cSrcweir      * @return the report definition's name.
102cdf0e10cSrcweir      */
getReportDefinitionName()103cdf0e10cSrcweir     public String getReportDefinitionName()
104cdf0e10cSrcweir     {
105cdf0e10cSrcweir         return (String) this.properties.getProperty(ReportEngineParameterNames.INPUT_NAME);
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
getProcessingParameters()108cdf0e10cSrcweir     public JobProperties getProcessingParameters()
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         return properties;
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir }
113