org.sqlproc.engine.plugin
Class DefaultSqlPlugins

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

public class DefaultSqlPlugins
extends Object
implements IsEmptyPlugin, IsTruePlugin, SqlCountPlugin, SqlFromToPlugin, SqlSequencePlugin, SqlIdentityPlugin, SqlExecutionPlugin

The SQL Processor plugins standard implementation.

Author:
Vladimir Hudec

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.sqlproc.engine.plugin.SqlFromToPlugin
SqlFromToPlugin.LimitType
 
Field Summary
(package private)  boolean debug
           
(package private)  org.slf4j.Logger logger
          The internal slf4j logger.
 
Fields inherited from interface org.sqlproc.engine.plugin.Modifiers
MODIFIER_ANY, MODIFIER_ANYSET, MODIFIER_CALL, MODIFIER_DISCRIMINATOR, MODIFIER_EMPTY, MODIFIER_GTYPE, MODIFIER_ID, MODIFIER_IDENTITY_GENERATOR, MODIFIER_IDENTITY_SELECT, MODIFIER_NOTEMPTY, MODIFIER_NOTNULL, MODIFIER_NULL, MODIFIER_SEQUENCE, MODIFIER_TYPE
 
Constructor Summary
DefaultSqlPlugins()
           
 
Method Summary
 String beforeSqlExecution(String name, String queryString)
          Used to possible SQL query/command modification just before it is executed.
private  Boolean callMethod(String attributeName, Object parentObj, Map<String,String> values)
           
 String identitySelect(SqlRuntimeContext runtimeCtx, String identitySelectName, Class<?> inputValueType)
          Used to construct the identity SELECT SQL.
protected  boolean isEmpty(Object obj, Map<String,String> values)
           
 boolean isNotEmpty(SqlRuntimeContext runtimeCtx, String attributeName, Object obj, Object parentObj, SqlMetaType sqlMetaType, String inOutModifier, boolean inSqlSetOrInsert, Map<String,String> values)
          Used for the evaluation of the emptiness in the META SQL fragments.
protected  boolean isNotEmptyInternal(SqlRuntimeContext runtimeCtx, String attributeName, Object obj, Object parentObj, SqlMetaType sqlMetaType, String inOutModifier, boolean inSqlSetOrInsert, Map<String,String> values)
          Used for the evaluation of the emptiness in the META SQL fragments.
 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.
 SqlFromToPlugin.LimitType limitQuery(SqlRuntimeContext runtimeCtx, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults, boolean ordered)
          Used to construct the FROM-TO SQL.
private  SqlFromToPlugin.LimitType limitQuery(String limitPattern, SqlFromToPlugin.LimitType limitType, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults)
           
 String sequenceSelect(SqlRuntimeContext runtimeCtx, String sequenceName)
          Used to construct the sequence SELECT SQL.
 String sqlCount(StringBuilder sql)
          Used to construct the COUNT SQL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

final org.slf4j.Logger logger
The internal slf4j logger.


debug

boolean debug
Constructor Detail

DefaultSqlPlugins

public DefaultSqlPlugins()
Method Detail

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(StringBuilder sql)
Used to construct the COUNT SQL.

Specified by:
sqlCount in interface SqlCountPlugin
Parameters:
sql - original META SQL
Returns:
the COUNT SQL

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(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


Copyright © 2015. All rights reserved.