Package com.inet.report
Class FieldValueProvider
java.lang.Object
com.inet.report.SQLValueProvider
com.inet.report.FieldValueProvider
- All Implemented Interfaces:
CascadingSource
,DynamicValueProvider
,NodeParser
,Serializable
- Direct Known Subclasses:
CascadingValueProvider
The FieldValueProvider takes one or two DatabaseFields and at run time provides the values in the
fields as default values. The first DatabaseField is used to fetch the values and the second
is used to fetch the default values.
- Since:
- 7.0
- See Also:
-
Field Summary
Fields inherited from class com.inet.report.SQLValueProvider
MAX_RECORDS
-
Constructor Summary
ConstructorDescriptionFieldValueProvider
(DatabaseField values, DatabaseField descriptions, int sortType) Creates a FieldValueProvider with the given DatabaseFields. -
Method Summary
Modifier and TypeMethodDescriptionReturns the data source the query is to be run onReturns the DatabaseField responsible for fetching the descriptions from.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.int
Returns the SortField constant specifying how the values are to be sorted.getSQL()
Returns the query which is to be used for fetching the values and optionally descriptions dynamically.protected String
Returns the query to be used, using the given String as its WHERE conditionReturns the DatabaseField responsible for fetching the values from.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 datasource to run the query on.void
setDescriptions
(DatabaseField descriptions) Sets the description DatabaseField.void
setSortType
(int sortType) Sets the sort type, specifying how the values are to be sorted.void
setValues
(DatabaseField values) Sets the DatabaseField for fetching the values from.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
-
FieldValueProvider
Creates a FieldValueProvider with the given DatabaseFields.- Parameters:
values
- DatabaseField to use to fetch the values. Must not be null.descriptions
- DatabaseField to use to fetch the descriptions. May be null. If not, it must be a String field and its Tablesource must be the same as the values' TableSourcesortType
- The SortField constant to specify how the values are to be sorted.- Throws:
IllegalArgumentException
- if values is null, or the table sources of the two fields are not the same or the table source comes from an SQL query- Since:
- 7.0
- See Also:
-
-
Method Details
-
getSQL
protected String getSQL(String where, boolean join, boolean distinct) throws ReportException, SQLException Returns the query to be used, using the given String as its WHERE condition- Parameters:
where
- WHERE condition to use. If no WHERE condition is to be used, use an empty string.join
- if set totrue
, a full join on all tables of the report will be created, otherwise only a select of the single table of this value will be createddistinct
- if set totrue
, the query will contain the DISTINCT keyword- Returns:
- Query to be used for this FieldValueProvider.
- Throws:
ReportException
- if the database structure does allow a single joined querySQLException
- on SQL errors during requesting metadata- Since:
- i-net Clear Reports 15.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 querySQLException
- on SQL errors during requesting metadata
-
getSortType
public int getSortType()Returns the SortField constant specifying how the values are to be sorted.- Returns:
- sorting type for the fields
- Since:
- 7.0
- See Also:
-
setSortType
public void setSortType(int sortType) Sets the sort type, specifying how the values are to be sorted.- Parameters:
sortType
- SortField constant specifying how to sort the values.- Since:
- 7.0
- See Also:
-
getDescriptions
Returns the DatabaseField responsible for fetching the descriptions from. Can be null if no descriptions are to be fetched.- Returns:
- DatabaseField for the descriptions
- Since:
- 7.0
-
setDescriptions
Sets the description DatabaseField. If this is null, it means there are to be no descriptions. If not null, it must come from the same Datasource and TableSource as the values DatabaseField- Parameters:
descriptions
- DatabaseField for the descriptions- Since:
- 7.0
-
getValues
Returns the DatabaseField responsible for fetching the values from. Will never be null- Returns:
- DatabaseField for the values.
- Since:
- 7.0
-
setValues
Sets the DatabaseField for fetching the values from. May not be null, and its Datasource and TableSource must be equal to those of the descriptions' field if there is one.- Parameters:
values
- DatabaseField for the values- Throws:
IllegalArgumentException
- if values is null or its table source does not match the description field's table source- 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
-
setDatasource
Sets the datasource to run the query on.- Parameters:
datasource
- data source to run the query on.- Throws:
IllegalArgumentException
- if datasource is null- Since:
- 7.0
-
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:
-
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.
-