[New] allow passing enums in SearchExpressions, converting to string internally
This commit is contained in:
parent
6d216b6f58
commit
dacc890e8c
|
@ -22,6 +22,7 @@ import li.strolch.model.Resource;
|
|||
import li.strolch.model.State;
|
||||
import li.strolch.model.activity.Activity;
|
||||
import li.strolch.model.json.StrolchRootElementToJsonVisitor;
|
||||
import li.strolch.model.parameter.StringListParameter;
|
||||
import li.strolch.model.parameter.StringParameter;
|
||||
import li.strolch.persistence.api.StrolchTransaction;
|
||||
import li.strolch.privilege.model.Certificate;
|
||||
|
@ -73,6 +74,10 @@ public class StrolchSearchTest {
|
|||
bag.addParameter(new StringParameter("status", "Status", "STATUS"));
|
||||
bag.addParameter(new StringParameter("color", "Color", "green"));
|
||||
|
||||
bag.addParameter(new StringParameter("state", "State", State.EXECUTION.name()));
|
||||
bag.addParameter(new StringListParameter("stateList", "Status",
|
||||
asList(State.EXECUTION.name(), State.EXECUTED.name())));
|
||||
|
||||
tx.add(ball);
|
||||
}
|
||||
|
||||
|
@ -355,9 +360,18 @@ public class StrolchSearchTest {
|
|||
|
||||
@Override
|
||||
public void define() {
|
||||
types("Ball").where(id(isEqualTo(this.id)).or(param("parameters", "status", isEqualTo(this.status))
|
||||
types("Ball").where(id(isEqualTo(this.id)).or( //
|
||||
|
||||
param("parameters", "status", isEqualTo(this.status))
|
||||
.and(not(param("parameters", "color", isEqualTo(this.color))))
|
||||
|
||||
.and(param("parameters", "state", isEqualTo(State.EXECUTION)))
|
||||
.and(param("parameters", "state", isEqualToIgnoreCase(State.EXECUTION)))
|
||||
.and(param("parameters", "state", isIn(State.EXECUTION, State.CREATED)))
|
||||
.and(param("parameters", "state", contains(State.EXECUTION)))
|
||||
.and(param("parameters", "state", containsIgnoreCase(State.EXECUTION)))
|
||||
.and(param("parameters", "stateList", listContains(State.EXECUTED)))
|
||||
|
||||
.and(param(BAG_ID, PARAM_FLOAT_ID, isEqualTo(44.3D)))
|
||||
|
||||
.and(param(BAG_ID, PARAM_STRING_ID, isEqualTo("Strolch")))
|
||||
|
|
|
@ -70,6 +70,9 @@ public class ObjectHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (left instanceof String && right.getClass().isEnum())
|
||||
right = ((Enum<?>) right).name();
|
||||
|
||||
if (left.getClass() != right.getClass())
|
||||
return false;
|
||||
|
||||
|
@ -170,6 +173,9 @@ public class ObjectHelper {
|
|||
}
|
||||
}
|
||||
|
||||
if (right.getClass().isEnum())
|
||||
right = ((Enum<?>) right).name();
|
||||
|
||||
if (right instanceof String) {
|
||||
String rightString = (String) right;
|
||||
|
||||
|
@ -221,7 +227,7 @@ public class ObjectHelper {
|
|||
Collection<?> collectionleft = (Collection) left;
|
||||
for (Object oLeft : collectionleft) {
|
||||
for (Object oRight : collectionRight) {
|
||||
if (equals(oLeft, oRight, ignoreCase))
|
||||
if (equals(oRight, oLeft, ignoreCase))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +235,7 @@ public class ObjectHelper {
|
|||
} else {
|
||||
Collection<?> collection = (Collection) right;
|
||||
for (Object o : collection) {
|
||||
if (equals(left, o, ignoreCase))
|
||||
if (equals(o, left, ignoreCase))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue