Class WrqBindingItem

  • All Implemented Interfaces:
    WrsBindingItem

    public class WrqBindingItem
    extends java.lang.Object
    implements WrsBindingItem
    Represents a BindingItem in a Wrq, it is it has knowledge of the underlying BindingItem and the current query There can be multiple WrqBindingItem for a BindingItem(FromRel), to reflect different behaviora like aggr for example in select and in grouping clause
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Object> attributes  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected WrqBindingItem​(WrqInfo wrqInfo, java.lang.String id, BindingItem bi, java.lang.String alias, boolean enforceAggr)
      Used for creating a BindingItem from the info of a BindingSet
      protected WrqBindingItem​(WrqInfo wrqInfo, java.lang.String wrsAName, java.lang.String aggr, java.lang.String alias, WrqBindingItem parentC, java.lang.String columnExpression)
      Used for creating an artificial wrs:A attribute
      protected WrqBindingItem​(WrqInfo wrqInfo, org.w3c.dom.Element elem, java.lang.String alias, boolean enforceAggr)
      Used to derive a BindingItem from a wrs:C, it is combined with the info from the BindingSet but the WrsRequest provided info wins in case of conflict
      protected WrqBindingItem​(WrqInfo wrqInfo, org.w3c.dom.Element elem, java.lang.String alias, boolean enforceAggr, WrqBindingItem parentWrqC)
      Used to derive a BindingItem from a wrs:C/wrs:A, it is combined with the info from the BindingSet but the WrsRequest provided info wins in case of conflict If parentWrqC is not null, then this is a wrs:A
    • Field Detail

      • attributes

        protected final java.util.Map<java.lang.String,​java.lang.Object> attributes
    • Constructor Detail

      • WrqBindingItem

        protected WrqBindingItem​(WrqInfo wrqInfo,
                                 org.w3c.dom.Element elem,
                                 java.lang.String alias,
                                 boolean enforceAggr)
                          throws java.lang.Exception
        Used to derive a BindingItem from a wrs:C, it is combined with the info from the BindingSet but the WrsRequest provided info wins in case of conflict
        Throws:
        java.lang.Exception
      • WrqBindingItem

        protected WrqBindingItem​(WrqInfo wrqInfo,
                                 org.w3c.dom.Element elem,
                                 java.lang.String alias,
                                 boolean enforceAggr,
                                 WrqBindingItem parentWrqC)
                          throws java.lang.Exception
        Used to derive a BindingItem from a wrs:C/wrs:A, it is combined with the info from the BindingSet but the WrsRequest provided info wins in case of conflict If parentWrqC is not null, then this is a wrs:A
        Parameters:
        wrqInfo -
        elem -
        alias -
        enforceAggr -
        parentWrqC -
        Throws:
        java.lang.Exception
      • WrqBindingItem

        protected WrqBindingItem​(WrqInfo wrqInfo,
                                 java.lang.String wrsAName,
                                 java.lang.String aggr,
                                 java.lang.String alias,
                                 WrqBindingItem parentC,
                                 java.lang.String columnExpression)
        Used for creating an artificial wrs:A attribute
        Parameters:
        wrqInfo -
        wrsAName -
        aggr -
        alias -
        parentC -
        columnExpression -
      • WrqBindingItem

        protected WrqBindingItem​(WrqInfo wrqInfo,
                                 java.lang.String id,
                                 BindingItem bi,
                                 java.lang.String alias,
                                 boolean enforceAggr)
        Used for creating a BindingItem from the info of a BindingSet
        Parameters:
        wrqInfo -
        bi -
        alias -
        enforceAggr -
    • Method Detail

      • getDefaultAggr

        protected static java.lang.String getDefaultAggr​(int dataType)
        Usually, the aggregation is defined in the Wrq Element e for the column. There are two cases where not: is not given (select all, no select list), or the attribute is simply not set. Then we have this mechanism for default-aggregator 1) Wrq/Columns/C/@aggr 2) BindingSet/BindingItem/@aggr 3) MAX() or SUM() depending on the BindingItems data type
        Parameters:
        dataType -
        Returns:
      • setColumnNumber

        public void setColumnNumber​(int columnNumber)
      • toXML

        public void toXML​(javax.xml.stream.XMLStreamWriter writer,
                          boolean withColumnExpression)
                   throws javax.xml.stream.XMLStreamException
        Specified by:
        toXML in interface WrsBindingItem
        Throws:
        javax.xml.stream.XMLStreamException
      • addWrsAAttribute

        public void addWrsAAttribute​(WrqBindingItem wrsAttr)
      • getAggr

        public java.lang.String getAggr()
      • isOrderByDescending

        public boolean isOrderByDescending()
      • setOrderByDescending

        public void setOrderByDescending​(boolean isDescending)
      • getSplitColumnExpression

        public java.util.List<java.lang.String> getSplitColumnExpression()
        Used to identify column reference parts in a SQL Column expressions to allow for prepending table alias {@see BindingUtils.splitColumnExpression}
        Returns:
      • getSplitColumnExpression

        public java.util.List<java.lang.String> getSplitColumnExpression​(boolean applyVdm)
        Used to identify column reference parts in a SQL Column expressions to allow for prepending table alias {@see BindingUtils.splitColumnExpression}
        Parameters:
        applyVdm - If false, virtual dimension member caused case-when are ignored here
        Returns:
      • getQColumnExpressionWithAggr

        public java.lang.String getQColumnExpressionWithAggr()
                                                      throws BindingNotFoundException
        Returns the column expression with table alias and with aggregation applied, if any is set
        Returns:
        Throws:
        BindingNotFoundException
      • getQColumnExpressionWithAggr

        public java.lang.String getQColumnExpressionWithAggr​(boolean enforceAggr)
                                                      throws BindingNotFoundException
        Returns the column expression with table alias and with aggregation applied, if any is set or if enforceAggr=true
        Returns:
        Throws:
        BindingNotFoundException
      • getColumnExpressionWithAggr

        public java.lang.String getColumnExpressionWithAggr()
        Returns the column expression with aggregation applied, if any is set
        Returns:
      • getColumnExpressionWithAggr

        public java.lang.String getColumnExpressionWithAggr​(boolean enforceAggr)
        Returns the column expression with aggregation applied, if any is set or if enforceAggr=true
        Returns:
      • hasAColumnReference

        public boolean hasAColumnReference()
      • getQColumnExpression

        public java.lang.String getQColumnExpression​(boolean applyVdm)
                                              throws BindingNotFoundException
        Return the column expression with the table alias
        Parameters:
        applyVdm - If false, virtual dimension members are ignored here
        Returns:
        Throws:
        BindingNotFoundException
      • getColumnExpression

        public java.lang.String getColumnExpression()
        Return the physical DB column expression including virtual dimension member caused adjustments
        Returns:
      • setColumnExpression

        public void setColumnExpression​(java.lang.String cE)
        Derive the column expression< Note that for VDM, this relies on plainColumnExpression and jdbcDataType being set already to this.
        Parameters:
        cE -
      • getTableAlias

        public java.lang.String getTableAlias()
                                       throws BindingNotFoundException
        Usually the table alias is derived from the wrq-table alias with which this bindingItem is referenced b.country will be taken from the table that is associated with the wrq table alias "b" This value is created during each query. But here are two special cases: tableAliasOverwrite allows to completely ignore this and fix out table alias by using setTableAliasOverwrite(). This is used for CTE fo example tableAliasPostFix will be not empty in case the BindingItem comes from a Relation as it mist be the Relation-joined (as opposed to Wrq-joined) table
        Returns:
        Throws:
        BindingNotFoundException
      • getBoundVariables

        public java.util.List<org.w3c.dom.Element> getBoundVariables()
      • getSkipForTotals

        public java.lang.String getSkipForTotals()
      • getReferenceBindingItem

        public BindingItem getReferenceBindingItem()
        Returns:
        a BindingItem this item is referencing, maybe null in case this is a virtual item
      • isNumeric

        public boolean isNumeric()
        Returns:
        true if the BindingItem represents a numeric value
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
      • setTableAliasOverwrite

        public void setTableAliasOverwrite​(java.lang.String tableAlias)