Package org.sqlproc.engine.plugin
Class DefaultSqlPlugins
- java.lang.Object
-
- org.sqlproc.engine.plugin.DefaultSqlPlugins
-
- All Implemented Interfaces:
IsEmptyPlugin
,IsTruePlugin
,Modifiers
,SqlCountPlugin
,SqlExecutionPlugin
,SqlFromToPlugin
,SqlIdentityPlugin
,SqlProcessingIdPlugin
,SqlSequencePlugin
public class DefaultSqlPlugins extends Object implements IsEmptyPlugin, IsTruePlugin, SqlCountPlugin, SqlFromToPlugin, SqlSequencePlugin, SqlIdentityPlugin, SqlExecutionPlugin, SqlProcessingIdPlugin
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
Fields Modifier and Type Field Description protected static String
CMD_DISTINCT
static String
COUNT_COLNAME
protected static String
COUNT_TYPE
(package private) boolean
debug
protected static String
DISTINCT
protected static String
FROM
protected static String
ID
protected static int
L_ID
protected static int
L_SELECT
(package private) org.slf4j.Logger
logger
The internal slf4j logger.static String
METHOD_IS_DEF
static String
METHOD_IS_DEF_
static String
METHOD_IS_NULL
static String
METHOD_IS_NULL_
static String
METHOD_TO_INIT
static String
METHOD_TO_INIT_
protected static String
SELECT
-
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
Constructors Constructor Description DefaultSqlPlugins()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
beforeSqlExecution(String name, String queryString)
Used to possible SQL query/command modification just before it is executed.private Boolean
callMethod(SqlRuntimeContext runtimeCtx, String attributeName, Object parentObj, Map<String,String> values)
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.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.private SqlFromToPlugin.LimitType
limitQuery(String limitPattern, SqlFromToPlugin.LimitType limitType, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults)
SqlFromToPlugin.LimitType
limitQuery(SqlRuntimeContext runtimeCtx, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults, boolean ordered)
Used to construct the FROM-TO SQL.String
sequenceSelect(SqlRuntimeContext runtimeCtx, String sequenceName)
Used to construct the sequence SELECT SQL.String[]
sqlCount(String name, StringBuilder sql)
Used to construct the COUNT SQL.
-
-
-
Field Detail
-
logger
final org.slf4j.Logger logger
The internal slf4j logger.
-
METHOD_IS_NULL
public static final String METHOD_IS_NULL
- See Also:
- Constant Field Values
-
METHOD_IS_NULL_
public static final String METHOD_IS_NULL_
- See Also:
- Constant Field Values
-
METHOD_IS_DEF
public static final String METHOD_IS_DEF
- See Also:
- Constant Field Values
-
METHOD_IS_DEF_
public static final String METHOD_IS_DEF_
- See Also:
- Constant Field Values
-
METHOD_TO_INIT
public static final String METHOD_TO_INIT
- See Also:
- Constant Field Values
-
METHOD_TO_INIT_
public static final String METHOD_TO_INIT_
- See Also:
- Constant Field Values
-
debug
boolean debug
-
ID
protected static final String ID
- See Also:
- Constant Field Values
-
L_ID
protected static final int L_ID
-
FROM
protected static final String FROM
- See Also:
- Constant Field Values
-
SELECT
protected static final String SELECT
- See Also:
- Constant Field Values
-
L_SELECT
protected static final int L_SELECT
-
DISTINCT
protected static final String DISTINCT
- See Also:
- Constant Field Values
-
CMD_DISTINCT
protected static final String CMD_DISTINCT
- See Also:
- Constant Field Values
-
COUNT_COLNAME
public static final String COUNT_COLNAME
- See Also:
- Constant Field Values
-
COUNT_TYPE
protected static final String COUNT_TYPE
- See Also:
- Constant Field Values
-
-
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 interfaceIsEmptyPlugin
- Parameters:
runtimeCtx
- the public runtime contextattributeName
- the name of the input valueobj
- the input valueparentObj
- the parent of the input valuesqlMetaType
- the internal type (= META type) devoted for the special processing of the input valuesinOutModifier
- the input/output value modifier devoted to extend the processing of the input/output valuesinSqlSetOrInsert
- 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 contextattributeName
- the name of the input valueobj
- the input valueparentObj
- the parent of the input valuesqlMetaType
- the internal type (= META type) devoted for the special processing of the input valuesinOutModifier
- the input/output value modifier devoted to extend the processing of the input/output valuesinSqlSetOrInsert
- 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
-
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 interfaceIsTruePlugin
- Parameters:
runtimeCtx
- the public runtime contextattributeName
- the name of the input valueobj
- the input valueparentObj
- the parent of the input valuesqlMetaType
- the internal type (= META type) devoted for the special processing of the input valuesinOutModifier
- the input/output value modifier devoted to extend the processing of the input/output valuesvalues
- 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 interfaceSqlCountPlugin
- Parameters:
name
- Name of the META SQL query or statementsql
- 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 interfaceSqlFromToPlugin
- Parameters:
runtimeCtx
- the public runtime contextqueryString
- the original ANSI SQLqueryResult
- the final ANSI SQL reflected FROM and TO restrictionsfirstResult
- 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 interfaceSqlIdentityPlugin
- Parameters:
runtimeCtx
- the public runtime contextidentitySelectName
- the identity SELECT SQL nameinputValueType
- 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 interfaceSqlSequencePlugin
- Parameters:
runtimeCtx
- the public runtime contextsequenceName
- 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 interfaceSqlExecutionPlugin
- Parameters:
name
- Name of the META SQL query or statementqueryString
- 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 interfaceSqlProcessingIdPlugin
- Parameters:
name
- Name of the META SQL query or statementdynamicInputValues
- the SQL statement dynamic parameters (input values)sqlControl
- The compound parameters controlling the META SQL execution- Returns:
- the unique ID for processing case
-
-