added UUID support

This commit is contained in:
2019-10-28 14:51:59 +01:00
parent bea1d80f1e
commit 233164fb54
2 changed files with 24 additions and 10 deletions

View File

@ -23,6 +23,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import javax.ejb.Lock; import javax.ejb.Lock;
import javax.ejb.LockType; import javax.ejb.LockType;
import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttribute;
@ -510,6 +511,21 @@ public abstract class CommonAbstractController {
throw new ControllerException(ControllerException.INTERNAL_ERROR, currentFilter.getComparator() + "not support for searchValue " + searchValue); throw new ControllerException(ControllerException.INTERNAL_ERROR, currentFilter.getComparator() + "not support for searchValue " + searchValue);
} }
returnCondition = addFilterCondition(cb, returnCondition, predicate); returnCondition = addFilterCondition(cb, returnCondition, predicate);
} else if (currentFilter.getSearchValue() instanceof UUID) {
UUID searchValue = (UUID) currentFilter.getSearchValue();
Path<UUID> booleanPath = root.<UUID>get(currentFilter.getFieldName());
Predicate predicate;
switch (currentFilter.getComparator()) {
case EQUAL:
predicate = cb.equal(booleanPath, searchValue);
break;
case NOT_EQUAL:
predicate = cb.notEqual(booleanPath, searchValue);
break;
default:
throw new ControllerException(ControllerException.INTERNAL_ERROR, currentFilter.getComparator() + "not support for searchValue " + searchValue);
}
returnCondition = addFilterCondition(cb, returnCondition, predicate);
} else { } else {
throw new ControllerException(ControllerException.INTERNAL_ERROR, "Filter for " + currentFilter.getSearchValue().getClass().getSimpleName() + " not yet implemented"); throw new ControllerException(ControllerException.INTERNAL_ERROR, "Filter for " + currentFilter.getSearchValue().getClass().getSimpleName() + " not yet implemented");
} }

View File

@ -32,16 +32,15 @@ public class ControllerException extends Exception {
public static final int CAUSE_CANNOT_PERSIST = 3; public static final int CAUSE_CANNOT_PERSIST = 3;
public static final int CAUSE_TOO_MANY_ROWS = 4; public static final int CAUSE_TOO_MANY_ROWS = 4;
public static final int CAUSE_CANNOT_DELETE = 5; public static final int CAUSE_CANNOT_DELETE = 5;
public static final int INVALID_FILTER = 6;
private final int causeCode; private final int causeCode;
/** /**
* Creates a new instance of <code>ControllerException</code> without detail * Creates a new instance of <code>ControllerException</code> without detail message.
* message.
* *
* @param cause the reason code * @param cause the reason code
* @param message the detail message. The detail message is saved for later * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
* retrieval by the {@link #getMessage()} method.
*/ */
public ControllerException(int cause, String message) { public ControllerException(int cause, String message) {
super(message); super(message);
@ -51,11 +50,9 @@ public class ControllerException extends Exception {
/** /**
* *
* @param causeCode the reason code * @param causeCode the reason code
* @param message the detail message. The detail message is saved for later * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
* retrieval by the {@link #getMessage()} method.
* *
* @param cause the cause (which is saved for later retrieval by the * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and
* {@link #getCause()} method). (A {@code null} value is permitted, and
* indicates that the cause is nonexistent or unknown.) * indicates that the cause is nonexistent or unknown.)
*/ */
public ControllerException(int causeCode, String message, Throwable cause) { public ControllerException(int causeCode, String message, Throwable cause) {
@ -65,6 +62,7 @@ public class ControllerException extends Exception {
/** /**
* returns the cause code * returns the cause code
*
* @return the cause code * @return the cause code
*/ */
public int getCauseCode() { public int getCauseCode() {