diff options
author | 2023-05-26 22:24:40 +0200 | |
---|---|---|
committer | 2023-05-26 22:24:40 +0200 | |
commit | d2348a15846ad861fc58b018f50a502a288bfcec (patch) | |
tree | 3a03b9eb35e9f90fd7f0e669ed00bf3aa8636982 /subprojects/store-query-viatra/src/main | |
parent | feat: count and aggregation literal reduction (diff) | |
download | refinery-d2348a15846ad861fc58b018f50a502a288bfcec.tar.gz refinery-d2348a15846ad861fc58b018f50a502a288bfcec.tar.zst refinery-d2348a15846ad861fc58b018f50a502a288bfcec.zip |
refactor: simplified Dnf parameter directions
Diffstat (limited to 'subprojects/store-query-viatra/src/main')
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java index ec880435..5b0ea61d 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java | |||
@@ -88,8 +88,7 @@ public class Dnf2PQuery { | |||
88 | List<PParameter> parameterList = new ArrayList<>(); | 88 | List<PParameter> parameterList = new ArrayList<>(); |
89 | for (var parameter : dnfQuery.getSymbolicParameters()) { | 89 | for (var parameter : dnfQuery.getSymbolicParameters()) { |
90 | var direction = switch (parameter.getDirection()) { | 90 | var direction = switch (parameter.getDirection()) { |
91 | case IN_OUT -> PParameterDirection.INOUT; | 91 | case OUT -> parameter.isUnifiable() ? PParameterDirection.INOUT : PParameterDirection.OUT; |
92 | case OUT -> PParameterDirection.OUT; | ||
93 | case IN -> throw new IllegalArgumentException("Query %s with input parameter %s is not supported" | 92 | case IN -> throw new IllegalArgumentException("Query %s with input parameter %s is not supported" |
94 | .formatted(dnfQuery, parameter.getVariable())); | 93 | .formatted(dnfQuery, parameter.getVariable())); |
95 | }; | 94 | }; |
@@ -154,9 +153,9 @@ public class Dnf2PQuery { | |||
154 | } | 153 | } |
155 | 154 | ||
156 | private void translateEquivalenceLiteral(EquivalenceLiteral equivalenceLiteral, PBody body) { | 155 | private void translateEquivalenceLiteral(EquivalenceLiteral equivalenceLiteral, PBody body) { |
157 | PVariable varSource = body.getOrCreateVariableByName(equivalenceLiteral.getLeft().getUniqueName()); | 156 | PVariable varSource = body.getOrCreateVariableByName(equivalenceLiteral.left().getUniqueName()); |
158 | PVariable varTarget = body.getOrCreateVariableByName(equivalenceLiteral.getRight().getUniqueName()); | 157 | PVariable varTarget = body.getOrCreateVariableByName(equivalenceLiteral.right().getUniqueName()); |
159 | if (equivalenceLiteral.isPositive()) { | 158 | if (equivalenceLiteral.positive()) { |
160 | new Equality(body, varSource, varTarget); | 159 | new Equality(body, varSource, varTarget); |
161 | } else { | 160 | } else { |
162 | new Inequality(body, varSource, varTarget); | 161 | new Inequality(body, varSource, varTarget); |
@@ -213,13 +212,13 @@ public class Dnf2PQuery { | |||
213 | } | 212 | } |
214 | 213 | ||
215 | private void translateConstantLiteral(ConstantLiteral constantLiteral, PBody body) { | 214 | private void translateConstantLiteral(ConstantLiteral constantLiteral, PBody body) { |
216 | var variable = body.getOrCreateVariableByName(constantLiteral.getVariable().getUniqueName()); | 215 | var variable = body.getOrCreateVariableByName(constantLiteral.variable().getUniqueName()); |
217 | new ConstantValue(body, variable, constantLiteral.getNodeId()); | 216 | new ConstantValue(body, variable, constantLiteral.nodeId()); |
218 | } | 217 | } |
219 | 218 | ||
220 | private <T> void translateAssignLiteral(AssignLiteral<T> assignLiteral, PBody body) { | 219 | private <T> void translateAssignLiteral(AssignLiteral<T> assignLiteral, PBody body) { |
221 | var variable = body.getOrCreateVariableByName(assignLiteral.getTargetVariable().getUniqueName()); | 220 | var variable = body.getOrCreateVariableByName(assignLiteral.variable().getUniqueName()); |
222 | var term = assignLiteral.getTerm(); | 221 | var term = assignLiteral.term(); |
223 | if (term instanceof ConstantTerm<T> constantTerm) { | 222 | if (term instanceof ConstantTerm<T> constantTerm) { |
224 | new ConstantValue(body, variable, constantTerm.getValue()); | 223 | new ConstantValue(body, variable, constantTerm.getValue()); |
225 | } else { | 224 | } else { |
@@ -229,7 +228,7 @@ public class Dnf2PQuery { | |||
229 | } | 228 | } |
230 | 229 | ||
231 | private void translateAssumeLiteral(AssumeLiteral assumeLiteral, PBody body) { | 230 | private void translateAssumeLiteral(AssumeLiteral assumeLiteral, PBody body) { |
232 | var evaluator = new AssumptionEvaluator(assumeLiteral.getTerm()); | 231 | var evaluator = new AssumptionEvaluator(assumeLiteral.term()); |
233 | new ExpressionEvaluation(body, evaluator, null); | 232 | new ExpressionEvaluation(body, evaluator, null); |
234 | } | 233 | } |
235 | 234 | ||