Class SQLValueProvider

  • All Implemented Interfaces:
    DynamicValueProvider, NodeParser, java.io.Serializable
    Direct Known Subclasses:
    FieldValueProvider, QueryValueProvider

    public abstract class SQLValueProvider
    extends java.lang.Object
    implements DynamicValueProvider, NodeParser
    This implementation of DynamicValueProvider takes a given SQL statement and executes it as a query on the given data source. This is done via 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 one column for the value and, if desired, one for the description of each default value.
    Since:
    7.0
    See Also:
    Datasource, Statement.execute(String), Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_RECORDS
      The maximum number of records that will be fetched before the rest are ignored and the prompt becomes editable.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract Datasource getDatasource()
      Returns the data source the query is to be run on
      void getDefaultValues​(java.util.function.Function<DefaultValue,​java.lang.Boolean> func)
      Query the DefaultValue objects for a prompt field.
      abstract java.lang.String getSQL()
      Returns the query which is to be used for fetching the values and optionally descriptions dynamically.
      boolean isDOMParser()
      FOR INTERNAL USE ONLY Internal method for reading report XML
      void parseDOM​(org.w3c.dom.Node node, java.util.Map<java.lang.String,​java.lang.Object> parserMap)
      FOR INTERNAL USE ONLY Internal method for reading report XML
      void parseEndElement​(com.inet.report.parser.XMLTag group, java.lang.String tag, java.util.Map<java.lang.String,​java.lang.Object> parserMap)
      FOR INTERNAL USE ONLY Internal method for reading report XML
      void parseText​(java.lang.String text, java.util.Map<java.lang.String,​java.lang.Object> parserMap)
      FOR INTERNAL USE ONLY Internal method for reading report XML
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_RECORDS

        public static final int MAX_RECORDS
        The maximum number of records that will be fetched before the rest are ignored and the prompt becomes editable.
        See Also:
        Constant Field Values
    • Method Detail

      • getDefaultValues

        public void getDefaultValues​(java.util.function.Function<DefaultValue,​java.lang.Boolean> func)
        Query the DefaultValue objects for a prompt field. Its stops if the function return false.
        Specified by:
        getDefaultValues in interface DynamicValueProvider
        Parameters:
        func - the function to use to compute the value
        Throws:
        java.lang.IllegalStateException - if the query returns a value or a description longer than 50000 characters.
      • getSQL

        public abstract 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.
        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
        Since:
        7.0
      • getDatasource

        public abstract Datasource getDatasource()
        Returns the data source the query is to be run on
        Returns:
        data source to use
        Since:
        7.0
      • isDOMParser

        public boolean isDOMParser()
        FOR INTERNAL USE ONLY Internal method for reading report XML

        Returns whether this node is to be read via a DOM parser.

        Specified by:
        isDOMParser in interface NodeParser
        Returns:
        true if this node is to be read via a DOM parser, false otherwise.
      • parseEndElement

        public void parseEndElement​(com.inet.report.parser.XMLTag group,
                                    java.lang.String tag,
                                    java.util.Map<java.lang.String,​java.lang.Object> parserMap)
                             throws FatalParserException
        FOR INTERNAL USE ONLY Internal method for reading report XML

        Receive notification of the end of an XML tag.

        Specified by:
        parseEndElement in interface NodeParser
        Parameters:
        group - XMLTag of the current node to be parsed, or null if there is no such current group.
        tag - The XMLTag to be parsed
        parserMap - The map of current Parser.
        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.
      • parseText

        public void parseText​(java.lang.String text,
                              java.util.Map<java.lang.String,​java.lang.Object> parserMap)
        FOR INTERNAL USE ONLY Internal method for reading report XML

        This method is called if text was encountered in the context of this node. (Examples would be a formula's text or a text element's text)

        Specified by:
        parseText in interface NodeParser
        Parameters:
        text - text encountered and to be stored
        parserMap - The map of current Parser.
      • parseDOM

        public void parseDOM​(org.w3c.dom.Node node,
                             java.util.Map<java.lang.String,​java.lang.Object> parserMap)
                      throws FatalParserException
        FOR INTERNAL USE ONLY Internal method for reading report XML

        Parses the node.

        Specified by:
        parseDOM in interface NodeParser
        Parameters:
        node - the node
        parserMap - The map of current Parser.
        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.