Class DefaultSqlPlugins

java.lang.Object
org.sqlproc.engine.plugin.DefaultSqlPlugins
All Implemented Interfaces:
IsEmptyPlugin, IsTruePlugin, Modifiers, SqlCountPlugin, SqlExecutionPlugin, SqlFromToPlugin, SqlIdentityPlugin, SqlProcessingIdPlugin, SqlSequencePlugin

The SQL Processor plugins standard implementation.
Author:
Vladimir Hudec
  • Field Details

  • Constructor Details

    • DefaultSqlPlugins

      public DefaultSqlPlugins()
  • Method Details

    • isNotEmpty

      public boolean isNotEmpty(SqlRuntimeContext runtimeCtx, String attributeName, Object obj, Object parentObj, SqlMetaType sqlMetaType, String inOutModifier, boolean inSqlSetOrInsert, Map<String,String> values) throws IllegalArgumentException
      Used for the evaluation of the emptiness in the META SQL fragments.
      Specified by:
      isNotEmpty in interface IsEmptyPlugin
      Parameters:
      runtimeCtx - the public runtime context
      attributeName - the name of the input value
      obj - the input value
      parentObj - the parent of the input value
      sqlMetaType - the internal type (= META type) devoted for the special processing of the input values
      inOutModifier - the input/output value modifier devoted to extend the processing of the input/output values
      inSqlSetOrInsert - an indicator the input value is evaluated in the CRUD statement (INSERT or SET)
      values - values for a special identifier handling, for example a sequence for an identity
      Returns:
      the non-emptiness of the input value
      Throws:
      IllegalArgumentException
    • isNotEmptyInternal

      protected boolean isNotEmptyInternal(SqlRuntimeContext runtimeCtx, String attributeName, Object obj, Object parentObj, SqlMetaType sqlMetaType, String inOutModifier, boolean inSqlSetOrInsert, Map<String,String> values) throws IllegalArgumentException
      Used for the evaluation of the emptiness in the META SQL fragments.
      Parameters:
      runtimeCtx - the public runtime context
      attributeName - the name of the input value
      obj - the input value
      parentObj - the parent of the input value
      sqlMetaType - the internal type (= META type) devoted for the special processing of the input values
      inOutModifier - the input/output value modifier devoted to extend the processing of the input/output values
      inSqlSetOrInsert - an indicator the input value is evaluated in the CRUD statement (INSERT or SET)
      values - values for a special identifier handling, for example a sequence for an identity
      Returns:
      the non-emptiness of the input value
      Throws:
      IllegalArgumentException
    • isEmpty

      protected boolean isEmpty(Object obj, Map<String,String> values)
    • isTrue

      public boolean isTrue(SqlRuntimeContext runtimeCtx, String attributeName, Object obj, Object parentObj, SqlMetaType sqlMetaType, String inOutModifier, Map<String,String> values)
      Used for the evaluation of the logical expression in the conditional META SQL fragments.
      Specified by:
      isTrue in interface IsTruePlugin
      Parameters:
      runtimeCtx - the public runtime context
      attributeName - the name of the input value
      obj - the input value
      parentObj - the parent of the input value
      sqlMetaType - the internal type (= META type) devoted for the special processing of the input values
      inOutModifier - the input/output value modifier devoted to extend the processing of the input/output values
      values - values for a special identifier handling, for example a sequence for an identity
      Returns:
      the boolean value of the logical expression
    • sqlCount

      public String[] sqlCount(String name, StringBuilder sql)
      Used to construct the COUNT SQL.
      Specified by:
      sqlCount in interface SqlCountPlugin
      Parameters:
      name - Name of the META SQL query or statement
      sql - original META SQL
      Returns:
      the COUNT SQL and COUNT column
    • limitQuery

      public SqlFromToPlugin.LimitType limitQuery(SqlRuntimeContext runtimeCtx, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults, boolean ordered)
      Used to construct the FROM-TO SQL.
      Specified by:
      limitQuery in interface SqlFromToPlugin
      Parameters:
      runtimeCtx - the public runtime context
      queryString - the original ANSI SQL
      queryResult - the final ANSI SQL reflected FROM and TO restrictions
      firstResult - The first SQL execution output row to be returned in the case we need to skip some rows in the result set. The primary usage is to support the pagination.
      maxResults - The max number of SQL execution output rows, which can be returned in the result list. The primary usage is to support the pagination.
      ordered - the SQL output is sorted
      Returns:
      the characteristic of FROM and TO restrictions used in SqlQuery.list(SqlRuntimeContext)
    • callMethod

      private Boolean callMethod(SqlRuntimeContext runtimeCtx, String attributeName, Object parentObj, Map<String,String> values)
    • limitQuery

      private SqlFromToPlugin.LimitType limitQuery(String limitPattern, SqlFromToPlugin.LimitType limitType, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults)
    • identitySelect

      public String identitySelect(SqlRuntimeContext runtimeCtx, String identitySelectName, Class<?> inputValueType)
      Used to construct the identity SELECT SQL.
      Specified by:
      identitySelect in interface SqlIdentityPlugin
      Parameters:
      runtimeCtx - the public runtime context
      identitySelectName - the identity SELECT SQL name
      inputValueType - a dynamic input value Java type
      Returns:
      the final identity SELECT SQL
    • sequenceSelect

      public String sequenceSelect(SqlRuntimeContext runtimeCtx, String sequenceName)
      Used to construct the sequence SELECT SQL.
      Specified by:
      sequenceSelect in interface SqlSequencePlugin
      Parameters:
      runtimeCtx - the public runtime context
      sequenceName - the sequence name
      Returns:
      the final sequence SELECT SQL
    • beforeSqlExecution

      public String beforeSqlExecution(String name, String queryString)
      Used to possible SQL query/command modification just before it is executed.
      Specified by:
      beforeSqlExecution in interface SqlExecutionPlugin
      Parameters:
      name - Name of the META SQL query or statement
      queryString - the SQL query command
      Returns:
      the SQL query command, which is going to be executed
    • getProcessingId

      public String getProcessingId(String name, Object dynamicInputValues, SqlControl sqlControl, Boolean useDynamicProcessingCache)
      Used to construct the unique ID of the executed statement based on the input values combination.
      Specified by:
      getProcessingId in interface SqlProcessingIdPlugin
      Parameters:
      name - Name of the META SQL query or statement
      dynamicInputValues - the SQL statement dynamic parameters (input values)
      sqlControl - The compound parameters controlling the META SQL execution
      Returns:
      the unique ID for processing case