Class FieldValueProvider

    • 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 on
      DatabaseField 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 condition
      DatabaseField 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 XML
      void 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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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' TableSource
        sortType - 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 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
        java.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 class SQLValueProvider
        Returns:
        query to be used
        Throws:
        ReportException - if the database structure does allow a single joined query
        java.sql.SQLException - on SQL errors during requesting metadata
      • 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
      • 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 interface CascadingSource
        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 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.