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);
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations