Record Class FilterColumn

java.lang.Object
java.lang.Record
de.calamanari.adl.sql.config.FilterColumn
Record Components:
tableName - native name of the table
columnName - native name of the filter column
columnType - type of the filter column for sql generation
filterValue - fixed filter value as a condition to be included in the query, or ${argName} to fill-in the argument name
All Implemented Interfaces:
AdlSqlColumn, Serializable

public record FilterColumn(String tableName, String columnName, AdlSqlType columnType, String filterValue) extends Record implements AdlSqlColumn
A FilterColumn defines an extra filter condition to be applied to a query, so the scope of the original query will be narrowed.

A good example might be a TENANT-column that is not mapped to any attribute. Instead the value of this column will be compared to a process variable.

FilterColumns also allow for advanced querying on tables with different layouts.
Sometimes, a table may be organized in a way that the effective key is composed of two or more columns.
A FilterColumn is the definition of a column name and a fixed value to be included in the query when selecting rows.

   +------+------------+-------------+
   | ID   | ENTRY_TYPE | ENTRY_VALUE |
   +------+------------+-------------+
   | 8599 | MODEL      | X4886       |
   +------+------------+-------------+
   | 8599 | BRAND      | RED         |
   +------+------------+-------------+
   | 4132 | COLOR      | RED         |
   +------+------------+-------------+
   | ...  | ...        | ...         |
 
In the example above, multiple attributes of the logical data model are mapped to the ENTRY_TYPE column, e.g., model, brand and color.
However, a query like brand=RED must not be simply translated into SELECT ID FROM ... where ENTRY_VALUE='RED' because it would also return ID=4132 - which is wrong. Instead, an additional filtering by ENTRY_TYPE is required: SELECT ID FROM ... where ENTRY_TYPE='BRAND' AND ENTRY_VALUE='RED'.

To create more expressive configurations your can specify "${argName}" as the filterValue. Then the converter will fill-in the current argument name from the expression as the filter value. This is meant for flat tables where the argument name acts as a qualifier for the column holding the values.

Summary:
A FilterColumn is part of the mapping of a field of the logical data model to a column. It expresses an additional filter condition based on a column name and its fixed or dynamic value (global variable reference).
FilterColumns defined on a table pre-filter the data of that table for any related query.

Author:
Karl Eilebrecht
See Also:
  • Field Details

    • VAR_ARG_NAME

      public static final String VAR_ARG_NAME
      Fixed value that can be specified as a filterValue to tell the system to replace it at runtime with the current argName from the expression.

      This variable is highly dynamic and only available (of interest) during parameter creation.

      See Also:
    • ARG_NAME_PLACEHOLDER

      public static final String ARG_NAME_PLACEHOLDER
      Reference to the variable "argName"
      See Also:
  • Constructor Details

    • FilterColumn

      public FilterColumn(String tableName, String columnName, AdlSqlType columnType, String filterValue)
      Creates an instance of a FilterColumn record class.
      Parameters:
      tableName - the value for the tableName record component
      columnName - the value for the columnName record component
      columnType - the value for the columnType record component
      filterValue - the value for the filterValue record component
  • Method Details

    • nativeCondition

      public String nativeCondition()
      Returns:
      the native filter condition to be included in the SQL query
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tableName

      public String tableName()
      Returns the value of the tableName record component.
      Specified by:
      tableName in interface AdlSqlColumn
      Returns:
      the value of the tableName record component
    • columnName

      public String columnName()
      Returns the value of the columnName record component.
      Specified by:
      columnName in interface AdlSqlColumn
      Returns:
      the value of the columnName record component
    • columnType

      public AdlSqlType columnType()
      Returns the value of the columnType record component.
      Specified by:
      columnType in interface AdlSqlColumn
      Returns:
      the value of the columnType record component
    • filterValue

      public String filterValue()
      Returns the value of the filterValue record component.
      Returns:
      the value of the filterValue record component