Search in sources :

Example 1 with ConditionKey

use of org.dbflute.cbean.ckey.ConditionKey in project dbflute-core by dbflute.

the class ManualOrderOption method doBindCaseWhen.

protected HpMobCaseWhenElement doBindCaseWhen(HpManualOrderThemeListHandler handler, HpMobCaseWhenElement element) {
    final ConditionKey conditionKey = element.getConditionKey();
    final Object orderValue = resolveBoundValue(handler, element.getOrderValue(), false);
    final HpMobCaseWhenElement boundElement = createElement(conditionKey, orderValue);
    boundElement.setConnectionMode(element.getConnectionMode());
    boundElement.setThenValue(resolveBoundValue(handler, element.getThenValue(), _suppressThenBinding));
    return boundElement;
}
Also used : ConditionKey(org.dbflute.cbean.ckey.ConditionKey) HpMobCaseWhenElement(org.dbflute.cbean.chelper.HpMobCaseWhenElement)

Example 2 with ConditionKey

use of org.dbflute.cbean.ckey.ConditionKey in project dbflute-core by dbflute.

the class AbstractConditionQuery method regROO.

// ===================================================================================
// RangeOf Query
// =============
protected void regROO(Number minNumber, Number maxNumber, ConditionValue cvalue, String columnDbName, RangeOfOption option) {
    assertObjectNotNull("option(RangeOfOption)", option);
    if (option.hasCalculationRange()) {
        final ConditionBean dreamCruiseCB = xgetBaseCB().xcreateDreamCruiseCB();
        option.xinitCalculationRange(xgetBaseCB(), dreamCruiseCB);
    }
    // this RangeOf process is very similar to FromTo process
    final ConditionKey minKey = option.getMinNumberConditionKey();
    final ConditionKeyPrepareResult minResult = prepareQueryNoCheck(minKey, minNumber, cvalue, columnDbName);
    final ConditionKey maxKey = option.getMaxNumberConditionKey();
    final ConditionKeyPrepareResult maxResult = prepareQueryNoCheck(maxKey, maxNumber, cvalue, columnDbName);
    final boolean needsAndPart = isOrScopeQueryDirectlyUnder() && minResult.newClause() && maxResult.newClause();
    if (needsAndPart) {
        xgetSqlClause().beginOrScopeQueryAndPart();
    }
    try {
        if (minResult.newClause()) {
            setupConditionValueAndRegisterWhereClause(minKey, minNumber, cvalue, columnDbName, option);
        }
        if (maxResult.newClause()) {
            setupConditionValueAndRegisterWhereClause(maxKey, maxNumber, cvalue, columnDbName, option);
        }
        if (minResult.invalid() && maxResult.invalid()) {
            xhandleRangeOfBothSideInvalidQuery(minNumber, maxNumber, columnDbName, option, minKey, maxKey);
        } else if (minResult.invalid() || maxResult.invalid()) {
            xhandleRangeOfOneSideInvalidQuery(minNumber, maxNumber, columnDbName, option, minKey, maxKey);
        }
    } finally {
        if (needsAndPart) {
            xgetSqlClause().endOrScopeQueryAndPart();
        }
    }
}
Also used : ConditionKeyPrepareResult(org.dbflute.cbean.ckey.ConditionKeyPrepareResult) ConditionKey(org.dbflute.cbean.ckey.ConditionKey)

Example 3 with ConditionKey

use of org.dbflute.cbean.ckey.ConditionKey in project dbflute-core by dbflute.

the class AbstractConditionQuery method handleInvalidQueryList.

protected void handleInvalidQueryList(List<ConditionKey> keyList, List<? extends Object> valueList, String columnDbName) {
    if (keyList.size() != valueList.size()) {
        String msg = "The argument 'keyList' should have the same size as 'valueList':";
        msg = msg + " keyList=" + keyList + ", valueList=" + valueList;
        throw new IllegalArgumentException(msg);
    }
    final HpInvalidQueryInfo[] invalidQueryInfoAry = new HpInvalidQueryInfo[keyList.size()];
    int index = 0;
    for (ConditionKey key : keyList) {
        final Object value = valueList.get(index);
        invalidQueryInfoAry[index] = xcreateInvalidQueryInfo(key, value, columnDbName);
        ++index;
    }
    xdoHandleInvalidQuery(columnDbName, invalidQueryInfoAry);
}
Also used : HpInvalidQueryInfo(org.dbflute.cbean.chelper.HpInvalidQueryInfo) ConditionKey(org.dbflute.cbean.ckey.ConditionKey)

Example 4 with ConditionKey

use of org.dbflute.cbean.ckey.ConditionKey in project dbflute-core by dbflute.

the class AbstractConditionQuery method regFTQ.

// ===================================================================================
// FromTo Query
// ============
protected void regFTQ(Date fromDate, Date toDate, ConditionValue cvalue, String columnDbName, FromToOption option) {
    assertObjectNotNull("option(FromToOption)", option);
    // for fixed option
    filterFromToOption(columnDbName, option);
    // this FromTo process is very similar to RangeOf process
    final Date filteredFromDate = option.filterFromDate(fromDate);
    final ConditionKey fromKey = option.getFromDateConditionKey();
    final ConditionKeyPrepareResult fromResult = prepareQueryNoCheck(fromKey, filteredFromDate, cvalue, columnDbName);
    final Date filteredToDate = option.filterToDate(toDate);
    final ConditionKey toKey = option.getToDateConditionKey();
    final ConditionKeyPrepareResult toResult = prepareQueryNoCheck(toKey, filteredToDate, cvalue, columnDbName);
    final boolean needsAndPart = isOrScopeQueryDirectlyUnder() && fromResult.newClause() && toResult.newClause();
    if (needsAndPart) {
        xgetSqlClause().beginOrScopeQueryAndPart();
    }
    try {
        if (fromResult.newClause()) {
            final Object registered = filterFromToRegisteredDate(option, filteredFromDate, columnDbName);
            setupConditionValueAndRegisterWhereClause(fromKey, registered, cvalue, columnDbName);
        }
        if (toResult.newClause()) {
            final Object registered = filterFromToRegisteredDate(option, filteredToDate, columnDbName);
            setupConditionValueAndRegisterWhereClause(toKey, registered, cvalue, columnDbName);
        }
        if (fromResult.invalid() && toResult.invalid()) {
            xhandleFromToBothSideInvalidQuery(fromDate, toDate, columnDbName, option, fromKey, toKey);
        } else if (fromResult.invalid() || toResult.invalid()) {
            xhandleFromToOneSideInvalidQuery(fromDate, toDate, columnDbName, option, fromKey, toKey);
        }
    } finally {
        if (needsAndPart) {
            xgetSqlClause().endOrScopeQueryAndPart();
        }
    }
}
Also used : ConditionKeyPrepareResult(org.dbflute.cbean.ckey.ConditionKeyPrepareResult) ConditionKey(org.dbflute.cbean.ckey.ConditionKey) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 5 with ConditionKey

use of org.dbflute.cbean.ckey.ConditionKey in project dbflute-core by dbflute.

the class ManualOrderOption method doWhen_FromTo.

protected HpMobConnectedBean doWhen_FromTo(Date fromDate, Date toDate, FromToOption option) {
    assertFromToOption(option);
    assertFromToDateBothExistsOrOneSideAllowed(fromDate, toDate, option);
    final ConditionKey fromDateConditionKey = option.getFromDateConditionKey();
    final ConditionKey toDateConditionKey = option.getToDateConditionKey();
    final Date filteredFromDate = option.filterFromDate(fromDate);
    final Date filteredToDate = option.filterToDate(toDate);
    return doWhen(fromDateConditionKey, filteredFromDate).doAnd(toDateConditionKey, filteredToDate);
}
Also used : ConditionKey(org.dbflute.cbean.ckey.ConditionKey) Date(java.util.Date) LocalDate(java.time.LocalDate)

Aggregations

ConditionKey (org.dbflute.cbean.ckey.ConditionKey)6 LocalDate (java.time.LocalDate)2 Date (java.util.Date)2 ConditionKeyPrepareResult (org.dbflute.cbean.ckey.ConditionKeyPrepareResult)2 HpInvalidQueryInfo (org.dbflute.cbean.chelper.HpInvalidQueryInfo)1 HpMobCaseWhenElement (org.dbflute.cbean.chelper.HpMobCaseWhenElement)1