Search in sources :

Example 11 with BehaviorCommandMeta

use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.

the class CallbackContextTest method test_BehaviorCommandHook_twoSet_noInherits.

// -----------------------------------------------------
// No Inherits
// -----------
public void test_BehaviorCommandHook_twoSet_noInherits() throws Exception {
    // ## Arrange ##
    CallbackContext context = new CallbackContext();
    assertNull(context.getBehaviorCommandHook());
    // ## Act ##
    context.setBehaviorCommandHook(new BehaviorCommandHook() {

        public void hookBefore(BehaviorCommandMeta meta) {
            fail();
        }

        public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
            fail();
        }
    });
    context.setBehaviorCommandHook(new BehaviorCommandHook() {

        public void hookBefore(BehaviorCommandMeta meta) {
            markHere("secondBefore");
        }

        public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
            markHere("secondFinally");
        }

        @Override
        public boolean inheritsExistingHook() {
            return false;
        }
    });
    // ## Assert ##
    BehaviorCommandHook hook = context.getBehaviorCommandHook();
    assertFalse(hook.inheritsExistingHook());
    hook.hookBefore(null);
    hook.hookFinally(null, null);
    assertMarked("secondBefore");
    assertMarked("secondFinally");
}
Also used : BehaviorCommandHook(org.dbflute.bhv.core.BehaviorCommandHook) InheritableBehaviorCommandHook(org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta)

Example 12 with BehaviorCommandMeta

use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.

the class TnAbstractEntityDynamicCommand method doFilterExecutedSqlByCallbackFilter.

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

Example 13 with BehaviorCommandMeta

use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.

the class TnAbstractQueryDynamicCommand method filterSqlStringByCallbackFilter.

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

Aggregations

BehaviorCommandMeta (org.dbflute.bhv.core.BehaviorCommandMeta)13 BehaviorCommandHook (org.dbflute.bhv.core.BehaviorCommandHook)6 SqlStringFilter (org.dbflute.hook.SqlStringFilter)5 InheritableBehaviorCommandHook (org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook)3 Collections (java.util.Collections)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Entity (org.dbflute.Entity)1 BehaviorCommand (org.dbflute.bhv.core.BehaviorCommand)1 DBMeta (org.dbflute.dbmeta.DBMeta)1 ExecutionTimeInfo (org.dbflute.jdbc.ExecutionTimeInfo)1 DfCollectionUtil (org.dbflute.util.DfCollectionUtil)1 RomanticTransaction (org.lastaflute.db.jta.RomanticTransaction)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1