Search in sources :

Example 21 with IllegalConditionBeanOperationException

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

the class ConditionBeanExceptionThrower method throwManualOrderNotFoundOrderByException.

// ===================================================================================
// Manual Order
// ============
public void throwManualOrderNotFoundOrderByException(ConditionBean baseCB, ManualOrderOption moOp) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found order-by element for the ManualOrder.");
    br.addItem("Advice");
    br.addElement("Make sure your implementation:");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    cb.query().withManualOrder(op -> { // *Bad");
    br.addElement("        op.when_LessEqual(...);");
    br.addElement("    });");
    br.addElement("  (o):");
    br.addElement("    cb.query().addOrderBy_Birthdate_Asc().withManualOrder(op -> { // Good");
    br.addElement("        op.when_LessEqual(...);");
    br.addElement("    });");
    // don't use displaySql because of illegal CB's state
    br.addItem("ConditionBean");
    // check just in case
    br.addElement(baseCB != null ? baseCB.getClass().getName() : baseCB);
    br.addItem("ManualOrderOption");
    br.addElement(moOp);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 22 with IllegalConditionBeanOperationException

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

the class ManualOrderOption method assertFromToDateBothExistsOrOneSideAllowed.

protected void assertFromToDateBothExistsOrOneSideAllowed(Date fromDate, Date toDate, FromToOption option) {
    final boolean oneSideAllowed = option.isOneSideAllowed();
    if (fromDate == null && toDate == null) {
        String msg = "The both arguments of from-to for ManualOrder were null: " + option;
        throw new IllegalConditionBeanOperationException(msg);
    } else if (fromDate == null && !oneSideAllowed) {
        String msg = "The argument 'fromDate' of from-to for ManualOrder was null:";
        msg = msg + " toDate=" + toDate + " option=" + option;
        throw new IllegalConditionBeanOperationException(msg);
    } else if (toDate == null && !oneSideAllowed) {
        String msg = "The argument 'toDate' of from-to for ManualOrder was null:";
        msg = msg + " fromDate=" + fromDate + " option=" + option;
        throw new IllegalConditionBeanOperationException(msg);
    }
}
Also used : IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 23 with IllegalConditionBeanOperationException

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

the class ManualOrderOption method throwUnsupportedTypeSpecifiedException.

// -----------------------------------------------------
// Exception Handling
// ------------------
protected void throwUnsupportedTypeSpecifiedException(String notice, Object plainValue) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice(notice);
    br.addItem("Advice");
    br.addElement("The binding for the part, 'when' or 'then' or 'else',");
    br.addElement("is unsupported with the value type.");
    br.addItem("Specified Value");
    br.addElement(plainValue.getClass());
    br.addElement(plainValue);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 24 with IllegalConditionBeanOperationException

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

the class ManualOrderOption method throwManualOrderUnnecessaryElseNotFoundException.

protected void throwManualOrderUnnecessaryElseNotFoundException() {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Found unnecessary 'else', it doesn't need it (if PriorityOrder).");
    br.addItem("Advice");
    br.addElement("You should NOT set 'else' value 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);");
    br.addElement("    mob.elseEnd(3); // *NG");
    br.addElement("  (o):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_GreaterThan(7);");
    br.addElement("    mob.when_LessThan(3);");
    br.addElement("    cb.query().addOrderBy_...().withManualOrder(mob); // OK");
    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 25 with IllegalConditionBeanOperationException

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

the class ManualOrderOption method throwManualOrderRequiredThenNotFoundException.

protected void throwManualOrderRequiredThenNotFoundException(HpMobCaseWhenElement current) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found 'then', all elements need it (if SwitchOrder).");
    br.addItem("Advice");
    br.addElement("You should set 'then' value to all case-when elements");
    br.addElement("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); // *NG");
    br.addElement("  (o):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_GreaterThan(7).then(...);");
    br.addElement("    mob.when_LessThan(3).then(...); // 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)

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