Search in sources :

Example 1 with SqlStringFilter

use of org.dbflute.hook.SqlStringFilter in project lastaflute by lastaflute.

the class SimpleAsyncManager method extractSqlCounter.

// ===================================================================================
// SQL Counter
// ===========
protected OptionalThing<ExecutedSqlCounter> extractSqlCounter() {
    final CallbackContext context = CallbackContext.getCallbackContextOnThread();
    if (context == null) {
        return OptionalThing.empty();
    }
    final SqlStringFilter filter = context.getSqlStringFilter();
    if (filter == null || !(filter instanceof ExecutedSqlCounter)) {
        return OptionalThing.empty();
    }
    return OptionalThing.of(((ExecutedSqlCounter) filter));
}
Also used : RomanticTraceableSqlStringFilter(org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlStringFilter) SqlStringFilter(org.dbflute.hook.SqlStringFilter) CallbackContext(org.dbflute.hook.CallbackContext) ExecutedSqlCounter(org.dbflute.bhv.proposal.callback.ExecutedSqlCounter)

Example 2 with SqlStringFilter

use of org.dbflute.hook.SqlStringFilter in project lastaflute by lastaflute.

the class SimpleAsyncManager method doInheritCallbackContext.

protected CallbackContext doInheritCallbackContext(ConcurrentAsyncCall call) {
    // null allowed
    final CallbackContext src = CallbackContext.getCallbackContextOnThread();
    if (src == null) {
        return null;
    }
    final CallbackContext dest = newCallbackContext();
    final ConcurrentAsyncOption option = call.option();
    final ConcurrentAsyncOption defaultOption = defaultConcurrentAsyncOption;
    if (isInherit(option.getBehaviorCommandHookType(), defaultOption.getBehaviorCommandHookType())) {
        final BehaviorCommandHook hook = src.getBehaviorCommandHook();
        if (hook != null) {
            dest.setBehaviorCommandHook(hook);
        }
    }
    if (isInherit(option.getSqlFireHookType(), defaultOption.getSqlFireHookType())) {
        final SqlFireHook hook = src.getSqlFireHook();
        if (hook != null) {
            dest.setSqlFireHook(hook);
        }
    } else {
        // as default
        dest.setSqlFireHook(createDefaultSqlFireHook(call));
    }
    if (isInherit(option.getSqlLogHandlerType(), defaultOption.getSqlLogHandlerType())) {
        final SqlLogHandler handler = src.getSqlLogHandler();
        if (handler != null) {
            dest.setSqlLogHandler(handler);
        }
    }
    if (isInherit(option.getSqlResultHandlerType(), defaultOption.getSqlResultHandlerType())) {
        final SqlResultHandler handler = src.getSqlResultHandler();
        if (handler != null) {
            dest.setSqlResultHandler(handler);
        }
    } else {
        dest.setSqlResultHandler(createDefaultSqlResultHandler(call));
    }
    if (isInherit(option.getSqlStringFilterType(), defaultOption.getSqlStringFilterType())) {
        final SqlStringFilter filter = src.getSqlStringFilter();
        if (filter != null) {
            dest.setSqlStringFilter(filter);
        }
    } else {
        // as default
        dest.setSqlStringFilter(createDefaultSqlStringFilter(call));
    }
    return dest;
}
Also used : SqlLogHandler(org.dbflute.hook.SqlLogHandler) SqlResultHandler(org.dbflute.hook.SqlResultHandler) RomanticTraceableSqlResultHandler(org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlResultHandler) RomanticTraceableSqlStringFilter(org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlStringFilter) SqlStringFilter(org.dbflute.hook.SqlStringFilter) BehaviorCommandHook(org.dbflute.bhv.core.BehaviorCommandHook) CallbackContext(org.dbflute.hook.CallbackContext) RomanticTraceableSqlFireHook(org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlFireHook) SqlFireHook(org.dbflute.hook.SqlFireHook)

Example 3 with SqlStringFilter

use of org.dbflute.hook.SqlStringFilter in project dbflute-core by dbflute.

the class SelectCBExecution method doFilterExecutedSqlByCallbackFilter.

protected String doFilterExecutedSqlByCallbackFilter(String executedSql) {
    final SqlStringFilter sqlStringFilter = getSqlStringFilter();
    if (sqlStringFilter != null) {
        final BehaviorCommandMeta meta = ResourceContext.behaviorCommand();
        final String filteredSql = sqlStringFilter.filterSelectCB(meta, executedSql);
        return filteredSql != null ? filteredSql : executedSql;
    }
    return executedSql;
}
Also used : SqlStringFilter(org.dbflute.hook.SqlStringFilter) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta)

Example 4 with SqlStringFilter

use of org.dbflute.hook.SqlStringFilter in project dbflute-core by dbflute.

the class TnProcedureCommand method doFilterExecutedSqlByCallbackFilter.

protected String doFilterExecutedSqlByCallbackFilter(String executedSql) {
    final SqlStringFilter sqlStringFilter = getSqlStringFilter();
    if (sqlStringFilter != null) {
        final BehaviorCommandMeta meta = ResourceContext.behaviorCommand();
        final String filteredSql = sqlStringFilter.filterProcedure(meta, executedSql);
        return filteredSql != null ? filteredSql : executedSql;
    }
    return executedSql;
}
Also used : SqlStringFilter(org.dbflute.hook.SqlStringFilter) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta)

Example 5 with SqlStringFilter

use of org.dbflute.hook.SqlStringFilter in project dbflute-core by dbflute.

the class AbstractOutsideSqlExecution method doFilterExecutedSqlByCallbackFilter.

protected String doFilterExecutedSqlByCallbackFilter(String executedSql) {
    final SqlStringFilter sqlStringFilter = getSqlStringFilter();
    if (sqlStringFilter != null) {
        final BehaviorCommandMeta meta = ResourceContext.behaviorCommand();
        final String filteredSql = sqlStringFilter.filterOutsideSql(meta, executedSql);
        return filteredSql != null ? filteredSql : executedSql;
    }
    return executedSql;
}
Also used : SqlStringFilter(org.dbflute.hook.SqlStringFilter) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta)

Aggregations

SqlStringFilter (org.dbflute.hook.SqlStringFilter)7 BehaviorCommandMeta (org.dbflute.bhv.core.BehaviorCommandMeta)5 CallbackContext (org.dbflute.hook.CallbackContext)2 RomanticTraceableSqlStringFilter (org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlStringFilter)2 BehaviorCommandHook (org.dbflute.bhv.core.BehaviorCommandHook)1 ExecutedSqlCounter (org.dbflute.bhv.proposal.callback.ExecutedSqlCounter)1 SqlFireHook (org.dbflute.hook.SqlFireHook)1 SqlLogHandler (org.dbflute.hook.SqlLogHandler)1 SqlResultHandler (org.dbflute.hook.SqlResultHandler)1 RomanticTraceableSqlFireHook (org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlFireHook)1 RomanticTraceableSqlResultHandler (org.lastaflute.db.dbflute.callbackcontext.traceablesql.RomanticTraceableSqlResultHandler)1