Class WurbletArgument

  • All Implemented Interfaces:
    WurbletArgumentOperand

    public class WurbletArgument
    extends java.lang.Object
    implements WurbletArgumentOperand
    A wurblet argument.

    There are 4 WurbletArgumentTypes:

    • property condition: refers to an Entity's Attribute that must meet a condition.
    • property update: defines an Entity's Attribute that will be updated.
    • property sorting: define the sorting according to an Entity's Attribute.
    • load join: describes a Relation that will be eagerly loaded.

    An argument is of the form:

    [*|+|-][Relation|.Entity[.Relation...]][Attribute[#column][[name]]][:relop[:value|#value]]

    • argument type:
      • default (missing): attribute as a condition or for update
      • + or -: sorting criteria (+ for ascending, - for descending)
      • *: load join
    • relation-path: list of relations.
      Optional for conditions, required for load joins. Illegal for updates and sorting.
      If the current entity is a root-entity, the path starts with a dot and is followed by the name of a pointsToComponent, the pointsToComponent is replaced by its relation path, if there is only one path.
      For joins, the dots between the relations can be replaced by asterisks.
    • attribute: a property of an entity.
      Required for conditions, updates, sorting. Illegal for joins.
    • column: the optional column suffix or getter name for multi-column types. If missing and the multi-column type defines a default column, this column is taken. A * will explicitly select all columns.
    • name: optional name of the method argument.
      Only allowed for conditions and updates.
    • relop-expression: optional relop.
      Only allowed for conditions.
      Defaults to '='.
      The special relop ':null' will be translated to " IS NULL" and ':notnull' translated to " IS NOT NULL".
      ':like' will translated to " LIKE ". ':notlike' will be translated to " NOT LIKE ".
      The optional ':value' will be set as a '?'-parameter of the generated prepared statement. As an alternative, the value may be given as '#value' which will include the value literally in the SQL-string.
     Examples:
              poolId                      -> attribute=poolId, arg=poolId, relop="="
              poolId[from]:>=             -> attribute=poolId, arg=from, relop=">="
              code:=:"Hurrz"              -> attribute=code, relop="=", value="Hurz"
              code:=#"Hurrz"              -> attribute=code, relop="=", value="Hurz", literally=true
    
              +poolId -kurzname           -> ORDER BY pool_id ASC, kurzname DESC
    
              invoice.lines.currencyId    -> SQL WHERE condition for currency_id
              .InvoiceLine.currencyId     -> equivalent to the above
    
              *invoice.lines              -> joins the invoice pointsToComponent together with its lines
    invoice*lines              -> equivalent to the above
    
     
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      WurbletArgument​(org.tentackle.model.Entity entity, int index, java.lang.String text, boolean expressionFinished, boolean argumentGroupingEnabled)
      Constructs a wurblet argument.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      WurbletArgumentType getArgumentType()
      Gets the argument type.
      org.tentackle.model.Attribute getAttribute()
      Gets the model attribute.
      java.lang.Integer getColumnIndex()
      Gets the datatype column index.
      org.tentackle.model.Entity getComponent()
      Gets the component that prepends the relation path.
      org.tentackle.sql.DataType<?> getDataType()
      Gets the effective datatype of the attribute.
      org.tentackle.model.Entity getEntity()
      Gets the entity the wurblet is applied to.
      java.util.Set<org.tentackle.model.Entity> getExistsComponents()
      Gets the components for the current SQL EXISTS clause.
      java.util.Set<org.tentackle.model.Relation> getExistsRelations()
      Sets the relations used within the current SQL EXISTS clause.
      java.util.List<org.tentackle.model.Relation> getExpressionRelations()
      Gets the compacted relation path starting with the last component relation in chain, if any.
      int getIndex()
      Gets the index within the wurblet anchor.
      java.lang.String getJdbcValue()
      Gets the value to be used in JDBC prepared statements.
      java.lang.String getMethodArgumentName()
      Gets the effective name of the method argument.
      This is ether the optionally defined [name] or the name of the Attribute.
      java.lang.String getName()
      Gets the optional name of the method argument.
      java.util.List<org.tentackle.model.Relation> getRelations()
      Gets the relation path.
      java.lang.String getRelop()
      Gets the relational operator.
      org.tentackle.model.SortType getSortType()
      Gets the sorting type if this a sorting criteria argument.
      java.lang.String getText()
      Gets the original text.
      java.lang.String getValue()
      Gets the predefined value.
      boolean isEndOfExistsClause()
      Returns whether this is the last argument of the current SQL EXISTS clause.
      boolean isMethodArgument()
      Returns whether this is a method argument.
      boolean isPath()
      Returns whether argument points to another entity.
      boolean isValueLiterally()
      fixed value (directly put into sql-statement).
      void setEndOfExistsClause​(boolean endOfExistsClause)
      Sets whether this is the last argument of the current SQL EXISTS clause.
      void setExistsComponents​(java.util.Set<org.tentackle.model.Entity> existsComponents)
      Sets the components for the current SQL EXISTS clause.
      void setExistsRelations​(java.util.Set<org.tentackle.model.Relation> existsRelations)
      Sets the relations used within the current SQL EXISTS clause.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WurbletArgument

        public WurbletArgument​(org.tentackle.model.Entity entity,
                               int index,
                               java.lang.String text,
                               boolean expressionFinished,
                               boolean argumentGroupingEnabled)
                        throws org.wurbelizer.wurbel.WurbelException
        Constructs a wurblet argument.

        Parameters:
        entity - the entity the wurblet is applied to
        index - the position among all arguments
        text - the wurblet arg
        expressionFinished - true if expression is finished
        argumentGroupingEnabled - true if argument grouping is enabled
        Throws:
        org.wurbelizer.wurbel.WurbelException - if parsing failed
    • Method Detail

      • getEntity

        public org.tentackle.model.Entity getEntity()
        Gets the entity the wurblet is applied to.
        Returns:
        the entity
      • getIndex

        public int getIndex()
        Gets the index within the wurblet anchor.
        Returns:
        the index, lower comes first
      • getText

        public java.lang.String getText()
        Gets the original text.
        Returns:
        the text
      • getArgumentType

        public WurbletArgumentType getArgumentType()
        Gets the argument type.
        Returns:
        the type, never null
      • getAttribute

        public org.tentackle.model.Attribute getAttribute()
        Gets the model attribute.
        Returns:
        the attribute
      • getDataType

        public org.tentackle.sql.DataType<?> getDataType()
        Gets the effective datatype of the attribute.
        Returns:
        the datatype
      • getColumnIndex

        public java.lang.Integer getColumnIndex()
        Gets the datatype column index.
        Returns:
        the index if column specified, else null
      • getRelations

        public java.util.List<org.tentackle.model.Relation> getRelations()
        Gets the relation path.

        If the path starts with a component, the relations start there.

        Returns:
        the relations, null if refers directly to the wurblet's entity
      • getExistsRelations

        public java.util.Set<org.tentackle.model.Relation> getExistsRelations()
        Sets the relations used within the current SQL EXISTS clause.
        Returns:
        the relations, null if argument has no relations or already covered by EXISTS-clause
      • setExistsRelations

        public void setExistsRelations​(java.util.Set<org.tentackle.model.Relation> existsRelations)
        Sets the relations used within the current SQL EXISTS clause.
        Parameters:
        existsRelations - the effective relations
      • getExistsComponents

        public java.util.Set<org.tentackle.model.Entity> getExistsComponents()
        Gets the components for the current SQL EXISTS clause.
        Returns:
        the components, null if argument has no relations or already covered by EXISTS-clause
      • setExistsComponents

        public void setExistsComponents​(java.util.Set<org.tentackle.model.Entity> existsComponents)
        Sets the components for the current SQL EXISTS clause.
        Parameters:
        existsComponents - the components
      • isEndOfExistsClause

        public boolean isEndOfExistsClause()
        Returns whether this is the last argument of the current SQL EXISTS clause.
        Returns:
        true if finish clause
      • setEndOfExistsClause

        public void setEndOfExistsClause​(boolean endOfExistsClause)
        Sets whether this is the last argument of the current SQL EXISTS clause.
        Parameters:
        endOfExistsClause - true if finish clause
      • getExpressionRelations

        public java.util.List<org.tentackle.model.Relation> getExpressionRelations()
        Gets the compacted relation path starting with the last component relation in chain, if any.
        Returns:
        the relation path to be used in expressions, null if refers directly to the wurblet's entity
      • getComponent

        public org.tentackle.model.Entity getComponent()
        Gets the component that prepends the relation path.
        Returns:
        the component, null if path does not start with a component
      • isPath

        public boolean isPath()
        Returns whether argument points to another entity.
        Returns:
        true if argument describes a path to another entity
      • getSortType

        public org.tentackle.model.SortType getSortType()
        Gets the sorting type if this a sorting criteria argument.
        Returns:
        ASC or DESC, null if not a sorting argument
      • getName

        public java.lang.String getName()
        Gets the optional name of the method argument.
        Returns:
        the argument name, null if default attribute name
      • isMethodArgument

        public boolean isMethodArgument()
        Returns whether this is a method argument.
        Returns:
        true if attribute set and value is null
      • getMethodArgumentName

        public java.lang.String getMethodArgumentName()
                                               throws org.wurbelizer.wurbel.WurbelException
        Gets the effective name of the method argument.
        This is ether the optionally defined [name] or the name of the Attribute.
        Returns:
        the method argument name, never null
        Throws:
        org.wurbelizer.wurbel.WurbelException - if arhument type provides no argument name
      • getJdbcValue

        public java.lang.String getJdbcValue()
                                      throws org.wurbelizer.wurbel.WurbelException,
                                             org.tentackle.model.ModelException
        Gets the value to be used in JDBC prepared statements.
        Returns:
        the JDBC value
        Throws:
        org.wurbelizer.wurbel.WurbelException - if failed
        org.tentackle.model.ModelException
      • getRelop

        public java.lang.String getRelop()
        Gets the relational operator.
        Returns:
        the relop
      • getValue

        public java.lang.String getValue()
        Gets the predefined value.
        Returns:
        the value
      • isValueLiterally

        public boolean isValueLiterally()
        fixed value (directly put into sql-statement).
        Returns:
        the fixed
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object