Package com.inet.report.database
Class BaseDataFactory
java.lang.Object
com.inet.report.database.BaseDataFactory
- All Implemented Interfaces:
DataFactory
,Serializable
- Direct Known Subclasses:
JdbcData
Abstract base implementation of the DataFactory.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
fetchData
(Engine engine, FetchTables fetchTables, DataCollector collector) Fetches the part of the report data for which this data factory is responsible.protected @Nonnull List<ColumnInfo>
getColumns
(@Nonnull Datasource datasource, String catalog, String schema, String name, int type) Returns the column information for a TableSource@Nonnull List<ColumnInfo>
getColumns
(@Nonnull TableSource ts) Returns the column information for a TableSource.com.inet.report.DatabaseConfiguration
Returns the DatabaseConfiguration of this DataFactory.boolean
Override this method only if you use subreport(s) and you set the data for the report with the getReportData orDataFactory.fetchData(Engine, FetchTables, DataCollector)
method.getTableSourceData
(@Nonnull TableSource ts) Is called from getReportData to request the data of a single TableSource if the TableSource is not a joined table or view.protected TableData
getTableSourceData
(@Nonnull TableSource ts, @Nonnull List<DatabaseField> columns) Is called from getTableSourceData to request the data of a singleTableSource
if theTableSource
is not a joined table or view.void
setConfiguration
(@Nonnull com.inet.report.DatabaseConfiguration configuration) Sets the DatabaseConfiguration for this DataFactory. this is calling from the runtime after creating.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inet.report.database.DataFactory
getSqlSyntax, getTableSourceInfos, getVersion, supportsCommands
-
Constructor Details
-
BaseDataFactory
protected BaseDataFactory()Create a new instance. The configuration receive a default value.- Since:
- 13.1
-
-
Method Details
-
getReportDataPerInstance
public boolean getReportDataPerInstance()Override this method only if you use subreport(s) and you set the data for the report with the getReportData orDataFactory.fetchData(Engine, FetchTables, DataCollector)
method. For more information please refer to the sample Main_and_Subreport_Data_WithExternalResultSet.java.
With this method you can specify whether the engine should call getReportData per subreport instance or only once for each of the subreports in the executed report. The same subreport can execute multiple time in a report with different parameters depending on its location. A subreport instance means one execution of one subreport. The method should return true if you want to set the different report data depending on the state of the report or if you want to set data depending on one or more parameter values. If you want to set data only once per sub-report, this function must return false. For example if you have a sub-report taking one prompt p0, and getReportDataPerInstance() returns true, then your sub-report will be called $n$ times whenever the value for p0 has been changed. So if your report has sub-reports and your sub-report prompts are linked with fields of the main report and you want to set the data whenever the sub-report prompts change, let getReportDataPerInstance() return true.- Specified by:
getReportDataPerInstance
in interfaceDataFactory
- Returns:
- true if the engine should invoke getReportData for every subreport instance or false otherwise.
-
getConfiguration
public com.inet.report.DatabaseConfiguration getConfiguration()Returns the DatabaseConfiguration of this DataFactory.- Specified by:
getConfiguration
in interfaceDataFactory
- Returns:
- the DatabaseConfiguration
-
setConfiguration
public void setConfiguration(@Nonnull @Nonnull com.inet.report.DatabaseConfiguration configuration) Sets the DatabaseConfiguration for this DataFactory. this is calling from the runtime after creating.- Specified by:
setConfiguration
in interfaceDataFactory
- Parameters:
configuration
- the current configuration
-
getTableSourceData
Is called from getReportData to request the data of a single TableSource if the TableSource is not a joined table or view. So it's called for procedures, commands and single tables or views.If you have define a column of type DatabaseMetaData.procedureColumnIn then you can get the current value with:
Object value = ts.getInputParameters().get(x).getValue();
- Specified by:
getTableSourceData
in interfaceDataFactory
- Parameters:
ts
- The current table source- Returns:
- The resulting data, never null.
- Throws:
ReportException
- if error occurs in the API access
-
getTableSourceData
protected TableData getTableSourceData(@Nonnull @Nonnull TableSource ts, @Nonnull @Nonnull List<DatabaseField> columns) throws ReportException Is called from getTableSourceData to request the data of a singleTableSource
if theTableSource
is not a joined table or view. So it's called for procedures, commands and single tables or views.
NOTE: You'll have to override either this method orgetTableSourceData(TableSource)
- the default implementation of this method will always throw aReportException
- Parameters:
ts
- the table source to get the data forcolumns
- the columns of the table source to get the data for- Returns:
- the resulting data, never
null
- Throws:
ReportException
- in case an error occurs during the API access or if this method is not implemented- Since:
- 15.1
-
getColumns
@Nonnull public @Nonnull List<ColumnInfo> getColumns(@Nonnull @Nonnull TableSource ts) throws ReportException Returns the column information for a TableSource.If you want return parameter columns with type
DatabaseMetaData.procedureColumnIn
thenDataFactory.getReportDataPerInstance()
must return true and theTableSourceInfo
must of typeTableSourceInfo.TYPE_SPROC
.- Specified by:
getColumns
in interfaceDataFactory
- Parameters:
ts
- the table source to get the data for- Returns:
- A list with column information, can be empty but not null
- Throws:
ReportException
- if any error occurs
-
getColumns
@Nonnull protected @Nonnull List<ColumnInfo> getColumns(@Nonnull @Nonnull Datasource datasource, String catalog, String schema, String name, int type) throws ReportException Returns the column information for a TableSource- Parameters:
datasource
- The Datasource containing the Connection.catalog
- The catalog/database.schema
- The object owner/schema or null.name
- The object name.type
- The type of source- Returns:
- A list with column infos, can be empty but not null
- Throws:
ReportException
- if any error occurs- Since:
- 13.0
-
fetchData
public void fetchData(Engine engine, FetchTables fetchTables, DataCollector collector) throws ReportException Fetches the part of the report data for which this data factory is responsible. A description about what tables are required to fetch is given in the specifiedFetchTables
instance. The resulting fetched data is put to the specifiedDataCollector
during execution of this method.An example implementation for this method:
for( TableSource tableSource : fetchDef.getTableSources() ) { TableData tableData; // retrieve data for table source "tableSource" tableData = [...] // deliver the data to the collector: collector.addUnjoinedData( tableSource, tableData ); }
- Specified by:
fetchData
in interfaceDataFactory
- Parameters:
engine
- the engine of the report to renderfetchTables
- a model of joining table describing the data this data factory needs to delivercollector
- the collector which receives any resulting data- Throws:
ReportException
- on failures during data fetching
-