Class WrqQueryBuilder


  • public class WrqQueryBuilder
    extends java.lang.Object
    Takes a full Wrq query, formally a "select-statement" and generates SQL from it [WITH]* SELECT [UNION SELECT]* [ORDER BY] Children can be recursive full-selects or a sub-selects or it is an empty (no select at all) or a meta-data request (endRow==0 ) One instance of this class only handles one Wrq NOTE: We do not check the rights, use assurePermittedOnAllResolvedBindingSets() for verifying this
    • Field Detail

      • wrq2Sql

        protected final Wrq2Sql wrq2Sql
      • bindings

        protected final Bindings bindings
      • wrqElem

        protected final org.w3c.dom.Element wrqElem
      • selectedBindingItems

        protected java.util.LinkedList<WrsBindingItem> selectedBindingItems
      • aliasCounter

        protected int aliasCounter
      • wrqBindingSetForWrqAlias

        protected java.util.Map<java.lang.String,​WrqBindingSet> wrqBindingSetForWrqAlias
      • queryGlobalStorage

        protected final java.util.Map<java.lang.String,​java.lang.Object> queryGlobalStorage
      • jdbcResourceName

        protected java.lang.String jdbcResourceName
    • Constructor Detail

      • WrqQueryBuilder

        public WrqQueryBuilder​(Wrq2Sql wrq2Sql,
                               Bindings bindings,
                               org.w3c.dom.Element wrqElem)
                        throws java.lang.Exception
        We are initialized a single wrq:WrqRequest.
        Throws:
        java.lang.Exception
    • Method Detail

      • getSelectedBindingItems

        public java.util.LinkedList<WrsBindingItem> getSelectedBindingItems()
                                                                     throws java.lang.Exception
        All BindingItems ever used in our query. Needed in cases when the selected BindingSet depends on it, which is in only the case for a single plain SELECT.
        Returns:
        Throws:
        java.lang.Exception
      • getCteBindingSetForWrqAlias

        public WrqBindingSet getCteBindingSetForWrqAlias​(java.lang.String wrqAlias)
        Get the BindingSet for a user provided table expression alias
        Parameters:
        wrqAlias -
        Returns:
      • addCteBindingSetForWrqAlias

        public void addCteBindingSetForWrqAlias​(java.lang.String wrqAlias,
                                                WrqBindingSet bindingSet)
        Set the BindingSet for a user provided table expression alias
        Parameters:
        wrqAlias -
        bindingSet -
      • hasCteBindingSetForWrqAlias

        public boolean hasCteBindingSetForWrqAlias​(java.lang.String wrqAlias)
        Set the BindingSet for a user provided table expression alias
        Parameters:
        wrqAlias -
      • getBindings

        public Bindings getBindings()
        Helps us use it in batch environments when not using Bindings.getInstance()
        Returns:
      • getMaxRows

        public int getMaxRows()
      • getResolvedBindingSets

        public java.util.Set<StandardBindingSet> getResolvedBindingSets()
        The predefined BindingStets from WEB-INF/bindings we determined for this query, including BindingGroup resolution
        Returns:
      • getFromQueryGlobalStorage

        public java.lang.Object getFromQueryGlobalStorage​(java.lang.String key)
        Allows storing a query-wide value
        Parameters:
        key -
        Returns:
      • addToQueryGlobalStorage

        public java.lang.Object addToQueryGlobalStorage​(java.lang.String key,
                                                        java.lang.Object value)
        Allows storing a query-wide value
        Parameters:
        key -
        Returns:
      • assurePermittedOnAllResolvedBindingSets

        public void assurePermittedOnAllResolvedBindingSets​(BindingSet.SECURITY_OPS operation)
                                                     throws SecurityException
        Make sure that all BindingSets we touch are allowed to be used for the current Principal for the operation
        Parameters:
        operation -
        Throws:
        SecurityException
      • getNextCteTableSqlAlias

        public java.lang.String getNextCteTableSqlAlias()
        Produce a new unique sql table alias for the current select scope
        Returns:
      • getJdbcResourceName

        public java.lang.String getJdbcResourceName()
        The database source name our query goes to
        Returns: