blob: 255738c5fb0ccee905b856f7a8cec994d62ce6f0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.query.viatra.internal.pquery;
import org.eclipse.viatra.query.runtime.api.GenericQuerySpecification;
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
import org.eclipse.viatra.query.runtime.api.scope.QueryScope;
import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery;
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
import tools.refinery.store.query.viatra.internal.RelationalScope;
import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class RawPQuery extends BasePQuery {
private final String fullyQualifiedName;
private List<PParameter> parameters;
private final LinkedHashSet<PBody> bodies = new LinkedHashSet<>();
public RawPQuery(String name, PVisibility visibility) {
super(visibility);
fullyQualifiedName = name;
}
public RawPQuery(String name) {
this(name, PVisibility.PUBLIC);
}
@Override
public String getFullyQualifiedName() {
return fullyQualifiedName;
}
public void setParameters(List<PParameter> parameters) {
this.parameters = parameters;
}
@Override
public void addAnnotation(PAnnotation annotation) {
super.addAnnotation(annotation);
}
@Override
public List<PParameter> getParameters() {
return parameters;
}
public void addBody(PBody body) {
bodies.add(body);
}
@Override
protected Set<PBody> doGetContainedBodies() {
return bodies;
}
public GenericQuerySpecification<RawPatternMatcher> build() {
return new GenericQuerySpecification<>(this) {
@Override
public Class<? extends QueryScope> getPreferredScopeClass() {
return RelationalScope.class;
}
@Override
protected RawPatternMatcher instantiate(ViatraQueryEngine engine) {
RawPatternMatcher matcher = engine.getExistingMatcher(this);
if (matcher == null) {
matcher = engine.getMatcher(this);
}
return matcher;
}
@Override
public RawPatternMatcher instantiate() {
return new RawPatternMatcher(this);
}
};
}
}
|