Package com.inet.report
Class FieldValueProvider
- java.lang.Object
-
- com.inet.report.SQLValueProvider
-
- com.inet.report.FieldValueProvider
-
- All Implemented Interfaces:
CascadingSource
,DynamicValueProvider
,NodeParser
,java.io.Serializable
- Direct Known Subclasses:
CascadingValueProvider
public class FieldValueProvider extends SQLValueProvider implements CascadingSource
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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.inet.report.SQLValueProvider
MAX_RECORDS
-
-
Constructor Summary
Constructors Constructor Description FieldValueProvider(DatabaseField values, DatabaseField descriptions, int sortType)
Creates a FieldValueProvider with the given DatabaseFields.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Datasource
getDatasource()
Returns the data source the query is to be run onDatabaseField
getDescriptions()
Returns the DatabaseField responsible for fetching the descriptions from.java.lang.String
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.int
getSortType()
Returns the SortField constant specifying how the values are to be sorted.java.lang.String
getSQL()
Returns the query which is to be used for fetching the values and optionally descriptions dynamically.protected java.lang.String
getSQL(java.lang.String where, boolean join, boolean distinct)
Returns the query to be used, using the given String as its WHERE conditionDatabaseField
getValues()
Returns the DatabaseField responsible for fetching the values from.NodeParser
parseElement(com.inet.report.parser.XMLTag group, java.lang.String tag, org.xml.sax.Attributes atts, java.util.Map<java.lang.String,java.lang.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 Detail
-
FieldValueProvider
public FieldValueProvider(DatabaseField values, DatabaseField descriptions, int sortType)
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:
java.lang.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:
SortField.ASCENDING_ORDER
,SortField.DESCENDING_ORDER
,SortField.ORIGINAL_ORDER
-
-
Method Detail
-
getSQL
protected java.lang.String getSQL(java.lang.String where, boolean join, boolean distinct) throws ReportException, java.sql.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 queryjava.sql.SQLException
- on SQL errors during requesting metadata- Since:
- i-net Clear Reports 15.0
-
getSQL
public java.lang.String getSQL() throws ReportException, java.sql.SQLException
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 queryjava.sql.SQLException
- 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:
SortField.ASCENDING_ORDER
,SortField.DESCENDING_ORDER
,SortField.ORIGINAL_ORDER
-
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:
SortField.ASCENDING_ORDER
,SortField.DESCENDING_ORDER
,SortField.ORIGINAL_ORDER
-
getDescriptions
public DatabaseField 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
public void setDescriptions(DatabaseField descriptions)
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
public DatabaseField getValues()
Returns the DatabaseField responsible for fetching the values from. Will never be null- Returns:
- DatabaseField for the values.
- Since:
- 7.0
-
setValues
public void setValues(DatabaseField values)
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:
java.lang.IllegalArgumentException
- if values is null or its table source does not match the description field's table source- Since:
- 7.0
-
getDatasource
public Datasource getDatasource()
Returns the data source the query is to be run on- Specified by:
getDatasource
in classSQLValueProvider
- Returns:
- data source to use
-
setDatasource
public void setDatasource(Datasource datasource)
Sets the datasource to run the query on.- Parameters:
datasource
- data source to run the query on.- Throws:
java.lang.IllegalArgumentException
- if datasource is null- Since:
- 7.0
-
getFieldRefName
public java.lang.String 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:
CascadingValueProvider
,SQLValueProvider
-
parseElement
public NodeParser parseElement(com.inet.report.parser.XMLTag group, java.lang.String tag, org.xml.sax.Attributes atts, java.util.Map<java.lang.String,java.lang.Object> parserMap) throws FatalParserException
FOR 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.
-
-