diff options
Diffstat (limited to 'subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java')
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java new file mode 100644 index 00000000..8dfa22e0 --- /dev/null +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java | |||
@@ -0,0 +1,43 @@ | |||
1 | package tools.refinery.store.query.viatra.internal; | ||
2 | |||
3 | import org.apache.log4j.Logger; | ||
4 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
5 | import org.eclipse.viatra.query.runtime.api.scope.IEngineContext; | ||
6 | import org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener; | ||
7 | import org.eclipse.viatra.query.runtime.api.scope.QueryScope; | ||
8 | import tools.refinery.store.model.Model; | ||
9 | import tools.refinery.store.model.Tuple; | ||
10 | import tools.refinery.store.model.representation.Relation; | ||
11 | import tools.refinery.store.query.viatra.internal.context.RelationalEngineContext; | ||
12 | import tools.refinery.store.query.viatra.internal.viewupdate.ModelUpdateListener; | ||
13 | import tools.refinery.store.query.view.RelationView; | ||
14 | |||
15 | import java.util.Set; | ||
16 | |||
17 | public class RelationalScope extends QueryScope { | ||
18 | private final Model model; | ||
19 | private final ModelUpdateListener updateListener; | ||
20 | |||
21 | public RelationalScope(Model model, Set<RelationView<?>> relationViews) { | ||
22 | this.model = model; | ||
23 | this.updateListener = new ModelUpdateListener(relationViews); | ||
24 | } | ||
25 | |||
26 | public <D> void processUpdate(Relation<D> relation, Tuple key, D oldValue, D newValue) { | ||
27 | updateListener.addUpdate(relation, key, oldValue, newValue); | ||
28 | } | ||
29 | |||
30 | public boolean hasChanges() { | ||
31 | return updateListener.hasChanges(); | ||
32 | } | ||
33 | |||
34 | public void flush() { | ||
35 | updateListener.flush(); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | protected IEngineContext createEngineContext(ViatraQueryEngine engine, IIndexingErrorListener errorListener, | ||
40 | Logger logger) { | ||
41 | return new RelationalEngineContext(model, updateListener); | ||
42 | } | ||
43 | } | ||