001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: * FieldsProvider.java
025: *
026: * Created on December 5, 2006, 8:55 PM
027: *
028: */
029:
030: package it.businesslogic.ireport;
031:
032: import it.businesslogic.ireport.gui.ReportQueryDialog;
033: import java.awt.Component;
034: import java.util.Map;
035: import net.sf.jasperreports.engine.JRDataset;
036: import net.sf.jasperreports.engine.JRException;
037: import net.sf.jasperreports.engine.JRField;
038:
039: /**
040: *
041: * @author gtoffoli
042: */
043: public interface FieldsProvider {
044:
045: /**
046: * Returns true if the provider supports the {@link #getFields(IReportConnection,JRDataset,Map) getFields}
047: * operation. By returning true in this method the data source provider indicates
048: * that it is able to introspect the data source and discover the available fields.
049: *
050: * @return true if the getFields() operation is supported.
051: */
052: public boolean supportsGetFieldsOperation();
053:
054: /**
055: * Returns the fields that are available from a query of a specific language
056: * The provider can use the passed in report to extract some additional
057: * configuration information such as report properties.
058: * The IReportConnection object can be used to execute the query.
059: *
060: * @param con the IReportConnection active in iReport.
061: * @param the JRDataset that will be filled using the data source created by this provider.
062: * The passed in report can be null. That means that no compiled report is available yet.
063: * @param parameters map containing the interpreted default value of each parameter
064: * @return a non null fields array. If there are no fields then an empty array must be returned.
065: *
066: * @throws UnsupportedOperationException is the method is not supported
067: * @throws JRException if an error occurs.
068: */
069: public JRField[] getFields(IReportConnection con,
070: JRDataset reportDataset, Map parameters)
071: throws JRException, UnsupportedOperationException;
072:
073: /**
074: * Returns true if the getFields can be run in a backgroiund thread each time the user changes the query.
075: * This approach can not be valid for fieldsProviders that require much time to return the list of fields.
076: */
077: public boolean supportsAutomaticQueryExecution();
078:
079: /**
080: * Returns true if the FieldsProvider can run an own query designer
081: */
082: public boolean hasQueryDesigner();
083:
084: /**
085: * Returns true if the FieldsProvider can run an own editor
086: */
087: public boolean hasEditorComponent();
088:
089: /**
090: * This method is used to run a query designer for the specific language.
091: *
092: * @param con the IReportConnection active in iReport.
093: * @param query the query to modify
094: * @param reportQueryDialog the parent reportQueryDialog. It can be used to get all (sub)dataset informations
095: * with reportQueryDialog.getSubDataset();
096: *
097: */
098: public String designQuery(IReportConnection con, String query,
099: ReportQueryDialog reportQueryDialog) throws JRException,
100: UnsupportedOperationException;
101:
102: /**
103: * The component that will stay on the right of the query panel. To listen for query changes, the component must implement
104: * the interface FieldsProviderEditor. The component will be visible only when a queryCahnged is succesfully executed.
105: * The component can store the reference to the report query dialog in which it will appear.
106: *
107: * The editor can
108: */
109: public FieldsProviderEditor getEditorComponent(
110: ReportQueryDialog reportQueryDialog);
111:
112: }
|