[Minor] Allow to query by Id and Name when without prefix
This commit is contained in:
parent
41f5f22574
commit
2cbdca3da8
|
@ -121,23 +121,11 @@ public abstract class QueryParser extends CompositeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
action("id", (String s) -> {
|
action("id", (String s) -> {
|
||||||
String trimmed = s.trim();
|
doIdAction(s);
|
||||||
if (trimmed.isEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (this.idSelection == null) {
|
|
||||||
this.idSelection = new IdSelection(trimmed, StringMatchMode.ci());
|
|
||||||
or().with(this.idSelection);
|
|
||||||
} else {
|
|
||||||
this.idSelection.with(trimmed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
action("name", (String s) -> {
|
action("name", (String s) -> {
|
||||||
String trimmed = s.trim();
|
doNameAction(s);
|
||||||
if (!trimmed.isEmpty())
|
|
||||||
or().with(new NameSelection(trimmed, StringMatchMode.ci()));
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
action("type", (String s) -> {
|
action("type", (String s) -> {
|
||||||
|
@ -150,25 +138,46 @@ public abstract class QueryParser extends CompositeParser {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
action("other", (String s) -> {
|
action("other", (String s) -> {
|
||||||
|
doIdAction(s);
|
||||||
for (String bagId : getBagParamSet().keySet()) {
|
doNameAction(s);
|
||||||
Set<String> set = getBagParamSet().getSet(bagId);
|
doParamAction(s);
|
||||||
for (String paramId : set) {
|
|
||||||
String trimmed = s.trim();
|
|
||||||
if (!trimmed.isEmpty())
|
|
||||||
or().with(
|
|
||||||
ParameterSelection.anyTypeSelection(bagId, paramId, trimmed, StringMatchMode.ci()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
action("start", o -> this.query);
|
action("start", o -> this.query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doIdAction(String s) {
|
||||||
|
String trimmed = s.trim();
|
||||||
|
if (trimmed.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.idSelection == null) {
|
||||||
|
this.idSelection = new IdSelection(trimmed, StringMatchMode.ci());
|
||||||
|
or().with(this.idSelection);
|
||||||
|
} else {
|
||||||
|
this.idSelection.with(trimmed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doNameAction(String s) {
|
||||||
|
String trimmed = s.trim();
|
||||||
|
if (!trimmed.isEmpty())
|
||||||
|
or().with(new NameSelection(trimmed, StringMatchMode.ci()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doParamAction(String s) {
|
||||||
|
for (String bagId : getBagParamSet().keySet()) {
|
||||||
|
Set<String> set = getBagParamSet().getSet(bagId);
|
||||||
|
for (String paramId : set) {
|
||||||
|
String trimmed = s.trim();
|
||||||
|
if (!trimmed.isEmpty())
|
||||||
|
or().with(ParameterSelection.anyTypeSelection(bagId, paramId, trimmed, StringMatchMode.ci()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
defs();
|
defs();
|
||||||
|
|
Loading…
Reference in New Issue