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 StringCMD_DISTINCTstatic StringCOUNT_COLNAMEprotected static StringCOUNT_TYPE(package private) booleandebugprotected static StringDISTINCTprotected static StringFROMprotected static StringIDprotected static intL_IDprotected static intL_SELECT(package private) org.slf4j.LoggerloggerThe internal slf4j logger.static StringMETHOD_IS_DEFstatic StringMETHOD_IS_DEF_static StringMETHOD_IS_NULLstatic StringMETHOD_IS_NULL_static StringMETHOD_TO_INITstatic StringMETHOD_TO_INIT_protected static StringSELECT-
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 StringbeforeSqlExecution(String name, String queryString)Used to possible SQL query/command modification just before it is executed.private BooleancallMethod(SqlRuntimeContext runtimeCtx, String attributeName, Object parentObj, Map<String,String> values)StringgetProcessingId(String name, Object dynamicInputValues, SqlControl sqlControl, Boolean useDynamicProcessingCache)Used to construct the unique ID of the executed statement based on the input values combination.StringidentitySelect(SqlRuntimeContext runtimeCtx, String identitySelectName, Class<?> inputValueType)Used to construct the identity SELECT SQL.protected booleanisEmpty(Object obj, Map<String,String> values)booleanisNotEmpty(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 booleanisNotEmptyInternal(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.booleanisTrue(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.LimitTypelimitQuery(String limitPattern, SqlFromToPlugin.LimitType limitType, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults)SqlFromToPlugin.LimitTypelimitQuery(SqlRuntimeContext runtimeCtx, String queryString, StringBuilder queryResult, Integer firstResult, Integer maxResults, boolean ordered)Used to construct the FROM-TO SQL.StringsequenceSelect(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:
isNotEmptyin 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:
isTruein 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:
sqlCountin 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:
limitQueryin 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:
identitySelectin 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:
sequenceSelectin 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:
beforeSqlExecutionin 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:
getProcessingIdin 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
-
-