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