Package com.inet.report
Class QueryValueProvider
java.lang.Object
com.inet.report.SQLValueProvider
com.inet.report.QueryValueProvider
- All Implemented Interfaces:
CascadingSource
,DynamicValueProvider
,HasCascadingParent
,NodeParser
,Serializable
public class QueryValueProvider
extends SQLValueProvider
implements CascadingSource, HasCascadingParent
This implementation of DynamicValueProvider takes a given SQL statement and executes it as a
query on the given data source. This is done via
The ResultSet returned should have the data of the first column be for the value and, if desired, have a second column with data for the description of each default value. Optionally instead, there should be a column called 'value' and a column called 'description'.
Connection.createStatement()
and
Statement.executeQuery(String)
, which means that the SQL query can be any standard
SQL statement. SPs also work for most databases, but not for Oracle or PostgreSQL.The ResultSet returned should have the data of the first column be for the value and, if desired, have a second column with data for the description of each default value. Optionally instead, there should be a column called 'value' and a column called 'description'.
- Since:
- 7.0
- See Also:
-
Field Summary
Fields inherited from class com.inet.report.SQLValueProvider
MAX_RECORDS
-
Constructor Summary
ConstructorDescriptionQueryValueProvider
(String query, Datasource datasource) Creates an instance of QueryValueProvider with the given query and data source. -
Method Summary
Modifier and TypeMethodDescriptionReturns the data source the query is to be run onReturns the name to be used as the SQL reference name in the WHERE part of the query used by a cascading prompt referencing this as its parent.Returns the set parent prompt fieldgetQuery()
Get the current query to execute.getSQL()
Returns the query which is to be used for fetching the values and optionally descriptions dynamically.parseElement
(com.inet.report.parser.XMLTag group, String tag, Attributes atts, Map<String, Object> parserMap) FOR INTERNAL USE ONLY Internal method for reading report XMLvoid
setDatasource
(Datasource datasource) Sets the data source on which the query is to be executed.void
setFieldRefName
(String refName) Sets the reference name to use if this provider used as a parent source to a cascading prompt.void
setParent
(PromptField parent) Sets the parent prompt field which is to be used for filtering the default values.void
Query to execute.void
Deprecated.Methods inherited from class com.inet.report.SQLValueProvider
getDefaultValues, isDOMParser, parseDOM, parseEndElement, parseText
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.DynamicValueProvider
getDefaultValues
-
Constructor Details
-
QueryValueProvider
Creates an instance of QueryValueProvider with the given query and data source. The query's ResultSet should have its first column be the value of each default value and an optional second column will be used as the description of each default value. Optionally instead, there should be a column called 'value' and a column called 'description'.- Parameters:
query
- Query to use to extract default values from, may not be null. Its ResultSet should have its first column be the value of each default value and an optional second column will be used as the description of each default value. Optionally instead, there should be a column called 'value' and a column called 'description'.datasource
- data source to run the query on, may not be null- Throws:
IllegalArgumentException
- if the query or the data source is null- Since:
- 7.0
- See Also:
-
-
Method Details
-
setDatasource
Sets the data source on which the query is to be executed.- Parameters:
datasource
- data source to execute the query on.- Throws:
IllegalArgumentException
- if datasource is null- Since:
- 7.0
-
getDatasource
Returns the data source the query is to be run on- Specified by:
getDatasource
in classSQLValueProvider
- Returns:
- data source to use
-
setSQL
Deprecated.As of i-net Clear Reports 16, usesetQuery(String)
insteadQuery to execute. Should be a SELECT statement, but on databases which support a simple execute of an SP, it can be a Stored Procedure call.- Parameters:
query
- Query to execute. Its ResultSet should have its first column be the value of each default value and an optional second column will be used as the description of each default value.- Throws:
IllegalArgumentException
- if query is null- Since:
- 7.0
-
setQuery
Query to execute. Should be a SELECT statement, but on databases which support a simple execute of an SP, it can be a Stored Procedure call. This can contains place holders for formulas like SQL Command.- Parameters:
query
- Query to execute. Its ResultSet should have its first column be the value of each default value and an optional second column will be used as the description of each default value.- Throws:
IllegalArgumentException
- if query is null- Since:
- 16.0
-
getQuery
Get the current query to execute.- Returns:
- the query
- Since:
- 16.0
-
getSQL
Returns the query which is to be used for fetching the values and optionally descriptions dynamically.- Specified by:
getSQL
in classSQLValueProvider
- Returns:
- query to be used
- Throws:
ReportException
- if the database structure does allow a single joined query
-
getFieldRefName
Returns the name to be used as the SQL reference name in the WHERE part of the query used by a cascading prompt referencing this as its parent. The WHERE part of the SQL query will resemble something like "WHERE (reference name
=prompt value
)".- Specified by:
getFieldRefName
in interfaceCascadingSource
- Returns:
- Reference name of the parent source for a cascading prompt
- See Also:
-
setFieldRefName
Sets the reference name to use if this provider used as a parent source to a cascading prompt.- Parameters:
refName
- Reference name to use in the SQL query to filter cascading results if this provider is referenced as a parent to a cascading prompt.- Since:
- 7.0
-
parseElement
public NodeParser parseElement(com.inet.report.parser.XMLTag group, String tag, Attributes atts, Map<String, Object> parserMap) throws FatalParserExceptionFOR INTERNAL USE ONLY Internal method for reading report XMLParses an XML node with the given information, and returns either a sub-element which was created as a result, or null if no sub-element was created, i.e. the information was applied to the ReportComponent itself. Note that the parsing is highly tolerant, i.e. exceptions are intercepted and suppressed if at all possible.
- Specified by:
parseElement
in interfaceNodeParser
- Parameters:
group
- XMLTag of the current node to be parsed, or null if there is no such current group. An XMLTag is a group of nodes bundled together, usually it is a Properties node such as CommonProperties, BorderProperties, etc.tag
- The XMLTag to be parsedatts
- The set of attributes in the current XMLTagparserMap
- The map of current Parser.- Returns:
- The NodeParser sub-element if one needed to be created, or null if none was created.
- Throws:
FatalParserException
- if an exception occurs which causes the report to not be able to be read: causes the abortion of the reading of the report.
-
getParent
Returns the set parent prompt field- Specified by:
getParent
in interfaceHasCascadingParent
- Returns:
- Parent prompt field for this cascading provider.
-
setParent
Sets the parent prompt field which is to be used for filtering the default values.- Specified by:
setParent
in interfaceHasCascadingParent
- Parameters:
parent
- Parent prompt field, may not be null and must have a FieldValueProvider
-
setQuery(String)
instead