Search in sources :

Example 11 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method throwManualOrderUnnecessaryThenFoundException.

protected void throwManualOrderUnnecessaryThenFoundException(HpMobCaseWhenElement current) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Found unnecessary 'then', all elements doesn't need it (if PriorityOrder).");
    br.addItem("Advice");
    br.addElement("You should NOT set 'then' value to all case-when elements");
    br.addElement("if you want to use PriorityOrder.");
    br.addElement("(No 'then' value means PriorityOrder)");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_GreaterThan(7);");
    br.addElement("    mob.when_LessThan(3).then(...); // *NG");
    br.addElement("  (o):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_GreaterThan(7);");
    br.addElement("    mob.when_LessThan(3); // OK");
    br.addItem("Target Element");
    br.addElement(current);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 12 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method throwManualOrderTwoConnectorUnsupportedException.

protected void throwManualOrderTwoConnectorUnsupportedException(ConditionKey conditionKey, Object orderValue, HpMobCaseWhenElement lastElement) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("both two connectors and/or were set.");
    br.addItem("Advice");
    br.addElement("Unsupported using both two connectors and/or in one case.");
    br.addElement("For example:");
    br.addElement("  (o): when FOO > 1 and FOO < 9 then ...");
    br.addElement("  (o): when FOO >= 1 or FOO >= 9 then ...");
    br.addElement("  (x): when FOO >= 1 and FOO >= 9 or FOO = 20 then ...");
    br.addItem("Added ConditionKey");
    br.addElement(conditionKey);
    br.addItem("Added OrderValue");
    br.addElement(orderValue);
    br.addItem("Fixed ConnectionMode");
    br.addElement(lastElement.getConnectionMode());
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 13 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method doValidateCaseWhenConstraint.

protected void doValidateCaseWhenConstraint() {
    if (_caseWhenAcceptedList.isEmpty()) {
        return;
    }
    final HpMobCaseWhenElement first = _caseWhenAcceptedList.get(0);
    final boolean firstThenExists = first.getThenValue() != null;
    for (HpMobCaseWhenElement current : _caseWhenAcceptedList) {
        final boolean currentThenExists = current.getThenValue() != null;
        if (firstThenExists && !currentThenExists) {
            throwManualOrderRequiredThenNotFoundException(current);
        } else if (!firstThenExists && currentThenExists) {
            throwManualOrderUnnecessaryThenFoundException(current);
        }
    }
    final boolean elseExists = _elseAcceptedValue != null;
    if (firstThenExists && !elseExists) {
        // e.g. SwitchOrder
        throwManualOrderRequiredElseNotFoundException();
    } else if (!firstThenExists && elseExists) {
        // e.g. PriorityOrder
        String msg = "Found unnecessary 'else', it doesn't need it if PriorityOrder: " + toString();
        throw new IllegalConditionBeanOperationException(msg);
    }
}
Also used : IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) HpMobCaseWhenElement(org.dbflute.cbean.chelper.HpMobCaseWhenElement)

Example 14 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method throwManualOrderRequiredElseNotFoundException.

protected void throwManualOrderRequiredElseNotFoundException() {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found 'else', it needs it (if SwitchOrder).");
    br.addItem("Advice");
    br.addElement("You should set 'else' value if you want to use SwitchOrder.");
    br.addElement("(settings for 'then' value means SwitchOrder)");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_GreaterThan(7).then(...);");
    br.addElement("    mob.when_LessThan(3).then(...);");
    br.addElement("    cb.query().addOrderBy_...().withManualOrder(mob); // *NG");
    br.addElement("  (o):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_GreaterThan(7).then(...);");
    br.addElement("    mob.when_LessThan(3).then(...);");
    br.addElement("    mob.elseEnd(3); // OK");
    br.addElement("    cb.query().addOrderBy_...().withManualOrder(mob);");
    br.addItem("CaseWhen Element");
    for (HpMobCaseWhenElement element : _caseWhenAcceptedList) {
        br.addElement(element);
    }
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) HpMobCaseWhenElement(org.dbflute.cbean.chelper.HpMobCaseWhenElement)

Example 15 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method throwManualOrderThenValueCaseWhenElementNotFoundException.

protected void throwManualOrderThenValueCaseWhenElementNotFoundException(Object thenValue) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found 'case when' element for 'then' value.");
    br.addItem("Advice");
    br.addElement("You should set 'case when' element before setting 'then' value.");
    br.addItem("Added ThenValue");
    br.addElement(thenValue);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Aggregations

IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)36 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)24 HpMobCaseWhenElement (org.dbflute.cbean.chelper.HpMobCaseWhenElement)3 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)3 DBMeta (org.dbflute.dbmeta.DBMeta)3 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)3 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)3 ArrayList (java.util.ArrayList)2 Method (java.lang.reflect.Method)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Entity (org.dbflute.Entity)1 HpCBPurpose (org.dbflute.cbean.chelper.HpCBPurpose)1 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)1 OrderByClause (org.dbflute.cbean.sqlclause.orderby.OrderByClause)1 OrderByElement (org.dbflute.cbean.sqlclause.orderby.OrderByElement)1 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)1