Class FieldValueProvider

java.lang.Object
com.inet.report.SQLValueProvider
com.inet.report.FieldValueProvider
All Implemented Interfaces:
CascadingSource, DynamicValueProvider, NodeParser, 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:
  • Constructor Details

    • 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' TableSource
      sortType - 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 to true, 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 created
      distinct - if set to true, 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 query
      SQLException - on SQL errors during requesting metadata
      Since:
      i-net Clear Reports 15.0
    • getSQL

      public String getSQL() throws ReportException, SQLException
      Returns the query which is to be used for fetching the values and optionally descriptions dynamically.
      Specified by:
      getSQL in class SQLValueProvider
      Returns:
      query to be used
      Throws:
      ReportException - if the database structure does allow a single joined query
      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:
    • 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

      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:
      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 class SQLValueProvider
      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:
      IllegalArgumentException - if datasource is null
      Since:
      7.0
    • getFieldRefName

      public 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 interface CascadingSource
      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 FatalParserException
      FOR INTERNAL USE ONLY Internal method for reading report XML

      Parses 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 interface NodeParser
      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 parsed
      atts - The set of attributes in the current XMLTag
      parserMap - 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.