diff options
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java')
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java index 5a32b1ba..225f6844 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java | |||
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | package tools.refinery.store.query.dnf; | 6 | package tools.refinery.store.query.dnf; |
7 | 7 | ||
8 | import tools.refinery.store.query.InvalidQueryException; | ||
8 | import tools.refinery.store.query.literal.CallPolarity; | 9 | import tools.refinery.store.query.literal.CallPolarity; |
9 | import tools.refinery.store.query.term.Aggregator; | 10 | import tools.refinery.store.query.term.Aggregator; |
10 | import tools.refinery.store.query.term.AssignedValue; | 11 | import tools.refinery.store.query.term.AssignedValue; |
@@ -26,14 +27,14 @@ public final class FunctionalQuery<T> extends Query<T> { | |||
26 | var parameter = parameters.get(i); | 27 | var parameter = parameters.get(i); |
27 | var parameterType = parameter.tryGetType(); | 28 | var parameterType = parameter.tryGetType(); |
28 | if (parameterType.isPresent()) { | 29 | if (parameterType.isPresent()) { |
29 | throw new IllegalArgumentException("Expected parameter %s of %s to be a node variable, got %s instead" | 30 | throw new InvalidQueryException("Expected parameter %s of %s to be a node variable, got %s instead" |
30 | .formatted(parameter, dnf, parameterType.get().getName())); | 31 | .formatted(parameter, dnf, parameterType.get().getName())); |
31 | } | 32 | } |
32 | } | 33 | } |
33 | var outputParameter = parameters.get(outputIndex); | 34 | var outputParameter = parameters.get(outputIndex); |
34 | var outputParameterType = outputParameter.tryGetType(); | 35 | var outputParameterType = outputParameter.tryGetType(); |
35 | if (outputParameterType.isEmpty() || !outputParameterType.get().equals(type)) { | 36 | if (outputParameterType.isEmpty() || !outputParameterType.get().equals(type)) { |
36 | throw new IllegalArgumentException("Expected parameter %s of %s to be %s, but got %s instead".formatted( | 37 | throw new InvalidQueryException("Expected parameter %s of %s to be %s, but got %s instead".formatted( |
37 | outputParameter, dnf, type, outputParameterType.map(Class::getName).orElse("node"))); | 38 | outputParameter, dnf, type, outputParameterType.map(Class::getName).orElse("node"))); |
38 | } | 39 | } |
39 | this.type = type; | 40 | this.type = type; |
@@ -54,6 +55,16 @@ public final class FunctionalQuery<T> extends Query<T> { | |||
54 | return null; | 55 | return null; |
55 | } | 56 | } |
56 | 57 | ||
58 | @Override | ||
59 | protected FunctionalQuery<T> withDnfInternal(Dnf newDnf) { | ||
60 | return newDnf.asFunction(type); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public FunctionalQuery<T> withDnf(Dnf newDnf) { | ||
65 | return (FunctionalQuery<T>) super.withDnf(newDnf); | ||
66 | } | ||
67 | |||
57 | public AssignedValue<T> call(List<NodeVariable> arguments) { | 68 | public AssignedValue<T> call(List<NodeVariable> arguments) { |
58 | return targetVariable -> { | 69 | return targetVariable -> { |
59 | var argumentsWithTarget = new ArrayList<Variable>(arguments.size() + 1); | 70 | var argumentsWithTarget = new ArrayList<Variable>(arguments.size() + 1); |