diff options
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains')
45 files changed, 12512 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore new file mode 100644 index 00000000..3e7cd5e2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /.CoverageMetric.java._trace | ||
2 | /.SatelliteMetrics.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore new file mode 100644 index 00000000..d3195cfc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /.MissionCoverage.java._trace | ||
2 | /.SatelliteMetricsAll.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore new file mode 100644 index 00000000..5f0d5b4b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore | |||
@@ -0,0 +1,22 @@ | |||
1 | /.SatelliteQueries.java._trace | ||
2 | /.NoLinkToGroundStation.java._trace | ||
3 | /.CommunicationLoop.java._trace | ||
4 | /.SingleInterferometryPayload.java._trace | ||
5 | /.NoInterferometryPayload.java._trace | ||
6 | /.NotENoughInterferometryPayloads.java._trace | ||
7 | /.NotEnoughInterferometryPayloads.java._trace | ||
8 | /.UhfAntennaGainNotLow.java._trace | ||
9 | /.XAntennaGainNotMedium.java._trace | ||
10 | /.KaAntennaGainLow.java._trace | ||
11 | /.IncompatibleSourceAndTarget.java._trace | ||
12 | /.IncompatibleSourceAndTargetBand.java._trace | ||
13 | /.IncompatibleSourceAndTargetGain.java._trace | ||
14 | /.CubeSatWithKaAntenna.java._trace | ||
15 | /.ThreeUCubeSatWithNonUhfCrossLink.java._trace | ||
16 | /.CommunicationLinkDoesNotStartAtContainingElement.java._trace | ||
17 | /.SpacecraftWithInterferometryPayload.java._trace | ||
18 | /.SatelliteMetrics.java._trace | ||
19 | /.CoverageMetric.java._trace | ||
20 | /.TimeMetric.java._trace | ||
21 | /.CostMetric.java._trace | ||
22 | /.SpacecraftCost.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CommunicationLinkDoesNotStartAtContainingElement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CommunicationLinkDoesNotStartAtContainingElement.java new file mode 100644 index 00000000..dde3c20f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CommunicationLinkDoesNotStartAtContainingElement.java | |||
@@ -0,0 +1,579 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(severity = "error", key = {Link}, | ||
50 | * message = "Communication links must start from the containing element.") | ||
51 | * pattern communicationLinkDoesNotStartAtContainingElement(Link : DirectedCommunicationLink) { | ||
52 | * CommunicatingElement.communicationLink(Element, Link); | ||
53 | * DirectedCommunicationLink.source(Link, SourceComm); | ||
54 | * CommunicatingElement.commSubsystem(SourceElement, SourceComm); | ||
55 | * Element != SourceElement; | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class CommunicationLinkDoesNotStartAtContainingElement extends BaseGeneratedEMFQuerySpecification<CommunicationLinkDoesNotStartAtContainingElement.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLinkDoesNotStartAtContainingElement pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private DirectedCommunicationLink fLink; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("Link"); | ||
81 | |||
82 | private Match(final DirectedCommunicationLink pLink) { | ||
83 | this.fLink = pLink; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | if ("Link".equals(parameterName)) return this.fLink; | ||
89 | return null; | ||
90 | } | ||
91 | |||
92 | public DirectedCommunicationLink getLink() { | ||
93 | return this.fLink; | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public boolean set(final String parameterName, final Object newValue) { | ||
98 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
99 | if ("Link".equals(parameterName) ) { | ||
100 | this.fLink = (DirectedCommunicationLink) newValue; | ||
101 | return true; | ||
102 | } | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | public void setLink(final DirectedCommunicationLink pLink) { | ||
107 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
108 | this.fLink = pLink; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public String patternName() { | ||
113 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLinkDoesNotStartAtContainingElement"; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public List<String> parameterNames() { | ||
118 | return CommunicationLinkDoesNotStartAtContainingElement.Match.parameterNames; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public Object[] toArray() { | ||
123 | return new Object[]{fLink}; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public CommunicationLinkDoesNotStartAtContainingElement.Match toImmutable() { | ||
128 | return isMutable() ? newMatch(fLink) : this; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String prettyPrint() { | ||
133 | StringBuilder result = new StringBuilder(); | ||
134 | result.append("\"Link\"=" + prettyPrintValue(fLink)); | ||
135 | return result.toString(); | ||
136 | } | ||
137 | |||
138 | @Override | ||
139 | public int hashCode() { | ||
140 | return Objects.hash(fLink); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public boolean equals(final Object obj) { | ||
145 | if (this == obj) | ||
146 | return true; | ||
147 | if (obj == null) { | ||
148 | return false; | ||
149 | } | ||
150 | if ((obj instanceof CommunicationLinkDoesNotStartAtContainingElement.Match)) { | ||
151 | CommunicationLinkDoesNotStartAtContainingElement.Match other = (CommunicationLinkDoesNotStartAtContainingElement.Match) obj; | ||
152 | return Objects.equals(fLink, other.fLink); | ||
153 | } else { | ||
154 | // this should be infrequent | ||
155 | if (!(obj instanceof IPatternMatch)) { | ||
156 | return false; | ||
157 | } | ||
158 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
159 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public CommunicationLinkDoesNotStartAtContainingElement specification() { | ||
165 | return CommunicationLinkDoesNotStartAtContainingElement.instance(); | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * Returns an empty, mutable match. | ||
170 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
171 | * | ||
172 | * @return the empty match. | ||
173 | * | ||
174 | */ | ||
175 | public static CommunicationLinkDoesNotStartAtContainingElement.Match newEmptyMatch() { | ||
176 | return new Mutable(null); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Returns a mutable (partial) match. | ||
181 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
182 | * | ||
183 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
184 | * @return the new, mutable (partial) match object. | ||
185 | * | ||
186 | */ | ||
187 | public static CommunicationLinkDoesNotStartAtContainingElement.Match newMutableMatch(final DirectedCommunicationLink pLink) { | ||
188 | return new Mutable(pLink); | ||
189 | } | ||
190 | |||
191 | /** | ||
192 | * Returns a new (partial) match. | ||
193 | * This can be used e.g. to call the matcher with a partial match. | ||
194 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
195 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
196 | * @return the (partial) match object. | ||
197 | * | ||
198 | */ | ||
199 | public static CommunicationLinkDoesNotStartAtContainingElement.Match newMatch(final DirectedCommunicationLink pLink) { | ||
200 | return new Immutable(pLink); | ||
201 | } | ||
202 | |||
203 | private static final class Mutable extends CommunicationLinkDoesNotStartAtContainingElement.Match { | ||
204 | Mutable(final DirectedCommunicationLink pLink) { | ||
205 | super(pLink); | ||
206 | } | ||
207 | |||
208 | @Override | ||
209 | public boolean isMutable() { | ||
210 | return true; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | private static final class Immutable extends CommunicationLinkDoesNotStartAtContainingElement.Match { | ||
215 | Immutable(final DirectedCommunicationLink pLink) { | ||
216 | super(pLink); | ||
217 | } | ||
218 | |||
219 | @Override | ||
220 | public boolean isMutable() { | ||
221 | return false; | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | /** | ||
227 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLinkDoesNotStartAtContainingElement pattern, | ||
228 | * providing pattern-specific query methods. | ||
229 | * | ||
230 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
231 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
232 | * | ||
233 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
234 | * | ||
235 | * <p>Original source: | ||
236 | * <code><pre> | ||
237 | * {@literal @}Constraint(severity = "error", key = {Link}, | ||
238 | * message = "Communication links must start from the containing element.") | ||
239 | * pattern communicationLinkDoesNotStartAtContainingElement(Link : DirectedCommunicationLink) { | ||
240 | * CommunicatingElement.communicationLink(Element, Link); | ||
241 | * DirectedCommunicationLink.source(Link, SourceComm); | ||
242 | * CommunicatingElement.commSubsystem(SourceElement, SourceComm); | ||
243 | * Element != SourceElement; | ||
244 | * } | ||
245 | * </pre></code> | ||
246 | * | ||
247 | * @see Match | ||
248 | * @see CommunicationLinkDoesNotStartAtContainingElement | ||
249 | * | ||
250 | */ | ||
251 | public static class Matcher extends BaseMatcher<CommunicationLinkDoesNotStartAtContainingElement.Match> { | ||
252 | /** | ||
253 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
254 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
255 | * | ||
256 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
257 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
258 | * | ||
259 | */ | ||
260 | public static CommunicationLinkDoesNotStartAtContainingElement.Matcher on(final ViatraQueryEngine engine) { | ||
261 | // check if matcher already exists | ||
262 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
263 | if (matcher == null) { | ||
264 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
265 | } | ||
266 | return matcher; | ||
267 | } | ||
268 | |||
269 | /** | ||
270 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
271 | * @return an initialized matcher | ||
272 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
273 | * | ||
274 | */ | ||
275 | public static CommunicationLinkDoesNotStartAtContainingElement.Matcher create() { | ||
276 | return new Matcher(); | ||
277 | } | ||
278 | |||
279 | private static final int POSITION_LINK = 0; | ||
280 | |||
281 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CommunicationLinkDoesNotStartAtContainingElement.Matcher.class); | ||
282 | |||
283 | /** | ||
284 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
285 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
286 | * | ||
287 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * | ||
290 | */ | ||
291 | private Matcher() { | ||
292 | super(querySpecification()); | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
297 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
298 | * @return matches represented as a Match object. | ||
299 | * | ||
300 | */ | ||
301 | public Collection<CommunicationLinkDoesNotStartAtContainingElement.Match> getAllMatches(final DirectedCommunicationLink pLink) { | ||
302 | return rawStreamAllMatches(new Object[]{pLink}).collect(Collectors.toSet()); | ||
303 | } | ||
304 | |||
305 | /** | ||
306 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
307 | * </p> | ||
308 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
309 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
310 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
311 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
312 | * @return a stream of matches represented as a Match object. | ||
313 | * | ||
314 | */ | ||
315 | public Stream<CommunicationLinkDoesNotStartAtContainingElement.Match> streamAllMatches(final DirectedCommunicationLink pLink) { | ||
316 | return rawStreamAllMatches(new Object[]{pLink}); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
321 | * Neither determinism nor randomness of selection is guaranteed. | ||
322 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
323 | * @return a match represented as a Match object, or null if no match is found. | ||
324 | * | ||
325 | */ | ||
326 | public Optional<CommunicationLinkDoesNotStartAtContainingElement.Match> getOneArbitraryMatch(final DirectedCommunicationLink pLink) { | ||
327 | return rawGetOneArbitraryMatch(new Object[]{pLink}); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
332 | * under any possible substitution of the unspecified parameters (if any). | ||
333 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
334 | * @return true if the input is a valid (partial) match of the pattern. | ||
335 | * | ||
336 | */ | ||
337 | public boolean hasMatch(final DirectedCommunicationLink pLink) { | ||
338 | return rawHasMatch(new Object[]{pLink}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
343 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
344 | * @return the number of pattern matches found. | ||
345 | * | ||
346 | */ | ||
347 | public int countMatches(final DirectedCommunicationLink pLink) { | ||
348 | return rawCountMatches(new Object[]{pLink}); | ||
349 | } | ||
350 | |||
351 | /** | ||
352 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
353 | * Neither determinism nor randomness of selection is guaranteed. | ||
354 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
355 | * @param processor the action that will process the selected match. | ||
356 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
357 | * | ||
358 | */ | ||
359 | public boolean forOneArbitraryMatch(final DirectedCommunicationLink pLink, final Consumer<? super CommunicationLinkDoesNotStartAtContainingElement.Match> processor) { | ||
360 | return rawForOneArbitraryMatch(new Object[]{pLink}, processor); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Returns a new (partial) match. | ||
365 | * This can be used e.g. to call the matcher with a partial match. | ||
366 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
367 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
368 | * @return the (partial) match object. | ||
369 | * | ||
370 | */ | ||
371 | public CommunicationLinkDoesNotStartAtContainingElement.Match newMatch(final DirectedCommunicationLink pLink) { | ||
372 | return CommunicationLinkDoesNotStartAtContainingElement.Match.newMatch(pLink); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Retrieve the set of values that occur in matches for Link. | ||
377 | * @return the Set of all values or empty set if there are no matches | ||
378 | * | ||
379 | */ | ||
380 | protected Stream<DirectedCommunicationLink> rawStreamAllValuesOfLink(final Object[] parameters) { | ||
381 | return rawStreamAllValues(POSITION_LINK, parameters).map(DirectedCommunicationLink.class::cast); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for Link. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | public Set<DirectedCommunicationLink> getAllValuesOfLink() { | ||
390 | return rawStreamAllValuesOfLink(emptyArray()).collect(Collectors.toSet()); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Retrieve the set of values that occur in matches for Link. | ||
395 | * @return the Set of all values or empty set if there are no matches | ||
396 | * | ||
397 | */ | ||
398 | public Stream<DirectedCommunicationLink> streamAllValuesOfLink() { | ||
399 | return rawStreamAllValuesOfLink(emptyArray()); | ||
400 | } | ||
401 | |||
402 | @Override | ||
403 | protected CommunicationLinkDoesNotStartAtContainingElement.Match tupleToMatch(final Tuple t) { | ||
404 | try { | ||
405 | return CommunicationLinkDoesNotStartAtContainingElement.Match.newMatch((DirectedCommunicationLink) t.get(POSITION_LINK)); | ||
406 | } catch(ClassCastException e) { | ||
407 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
408 | return null; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | @Override | ||
413 | protected CommunicationLinkDoesNotStartAtContainingElement.Match arrayToMatch(final Object[] match) { | ||
414 | try { | ||
415 | return CommunicationLinkDoesNotStartAtContainingElement.Match.newMatch((DirectedCommunicationLink) match[POSITION_LINK]); | ||
416 | } catch(ClassCastException e) { | ||
417 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
418 | return null; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | @Override | ||
423 | protected CommunicationLinkDoesNotStartAtContainingElement.Match arrayToMatchMutable(final Object[] match) { | ||
424 | try { | ||
425 | return CommunicationLinkDoesNotStartAtContainingElement.Match.newMutableMatch((DirectedCommunicationLink) match[POSITION_LINK]); | ||
426 | } catch(ClassCastException e) { | ||
427 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
428 | return null; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | /** | ||
433 | * @return the singleton instance of the query specification of this pattern | ||
434 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
435 | * | ||
436 | */ | ||
437 | public static IQuerySpecification<CommunicationLinkDoesNotStartAtContainingElement.Matcher> querySpecification() { | ||
438 | return CommunicationLinkDoesNotStartAtContainingElement.instance(); | ||
439 | } | ||
440 | } | ||
441 | |||
442 | private CommunicationLinkDoesNotStartAtContainingElement() { | ||
443 | super(GeneratedPQuery.INSTANCE); | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * @return the singleton instance of the query specification | ||
448 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
449 | * | ||
450 | */ | ||
451 | public static CommunicationLinkDoesNotStartAtContainingElement instance() { | ||
452 | try{ | ||
453 | return LazyHolder.INSTANCE; | ||
454 | } catch (ExceptionInInitializerError err) { | ||
455 | throw processInitializerError(err); | ||
456 | } | ||
457 | } | ||
458 | |||
459 | @Override | ||
460 | protected CommunicationLinkDoesNotStartAtContainingElement.Matcher instantiate(final ViatraQueryEngine engine) { | ||
461 | return CommunicationLinkDoesNotStartAtContainingElement.Matcher.on(engine); | ||
462 | } | ||
463 | |||
464 | @Override | ||
465 | public CommunicationLinkDoesNotStartAtContainingElement.Matcher instantiate() { | ||
466 | return CommunicationLinkDoesNotStartAtContainingElement.Matcher.create(); | ||
467 | } | ||
468 | |||
469 | @Override | ||
470 | public CommunicationLinkDoesNotStartAtContainingElement.Match newEmptyMatch() { | ||
471 | return CommunicationLinkDoesNotStartAtContainingElement.Match.newEmptyMatch(); | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | public CommunicationLinkDoesNotStartAtContainingElement.Match newMatch(final Object... parameters) { | ||
476 | return CommunicationLinkDoesNotStartAtContainingElement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink) parameters[0]); | ||
477 | } | ||
478 | |||
479 | /** | ||
480 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement (visibility: PUBLIC, simpleName: CommunicationLinkDoesNotStartAtContainingElement, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
481 | * <b>not</b> at the class load time of the outer class, | ||
482 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement (visibility: PUBLIC, simpleName: CommunicationLinkDoesNotStartAtContainingElement, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
483 | * | ||
484 | * <p> This workaround is required e.g. to support recursion. | ||
485 | * | ||
486 | */ | ||
487 | private static class LazyHolder { | ||
488 | private static final CommunicationLinkDoesNotStartAtContainingElement INSTANCE = new CommunicationLinkDoesNotStartAtContainingElement(); | ||
489 | |||
490 | /** | ||
491 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
492 | * This initialization order is required to support indirect recursion. | ||
493 | * | ||
494 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
495 | * | ||
496 | */ | ||
497 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
498 | |||
499 | public static Object ensureInitialized() { | ||
500 | INSTANCE.ensureInitializedInternal(); | ||
501 | return null; | ||
502 | } | ||
503 | } | ||
504 | |||
505 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
506 | private static final CommunicationLinkDoesNotStartAtContainingElement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
507 | |||
508 | private final PParameter parameter_Link = new PParameter("Link", "hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "DirectedCommunicationLink")), PParameterDirection.INOUT); | ||
509 | |||
510 | private final List<PParameter> parameters = Arrays.asList(parameter_Link); | ||
511 | |||
512 | private GeneratedPQuery() { | ||
513 | super(PVisibility.PUBLIC); | ||
514 | } | ||
515 | |||
516 | @Override | ||
517 | public String getFullyQualifiedName() { | ||
518 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLinkDoesNotStartAtContainingElement"; | ||
519 | } | ||
520 | |||
521 | @Override | ||
522 | public List<String> getParameterNames() { | ||
523 | return Arrays.asList("Link"); | ||
524 | } | ||
525 | |||
526 | @Override | ||
527 | public List<PParameter> getParameters() { | ||
528 | return parameters; | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public Set<PBody> doGetContainedBodies() { | ||
533 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
534 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
535 | { | ||
536 | PBody body = new PBody(this); | ||
537 | PVariable var_Link = body.getOrCreateVariableByName("Link"); | ||
538 | PVariable var_Element = body.getOrCreateVariableByName("Element"); | ||
539 | PVariable var_SourceComm = body.getOrCreateVariableByName("SourceComm"); | ||
540 | PVariable var_SourceElement = body.getOrCreateVariableByName("SourceElement"); | ||
541 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
542 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
543 | new ExportedParameter(body, var_Link, parameter_Link) | ||
544 | )); | ||
545 | // CommunicatingElement.communicationLink(Element, Link) | ||
546 | new TypeConstraint(body, Tuples.flatTupleOf(var_Element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
547 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
548 | new TypeConstraint(body, Tuples.flatTupleOf(var_Element, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "communicationLink"))); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
550 | new Equality(body, var__virtual_0_, var_Link); | ||
551 | // DirectedCommunicationLink.source(Link, SourceComm) | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
553 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
554 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
556 | new Equality(body, var__virtual_1_, var_SourceComm); | ||
557 | // CommunicatingElement.commSubsystem(SourceElement, SourceComm) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_SourceElement), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
559 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
560 | new TypeConstraint(body, Tuples.flatTupleOf(var_SourceElement, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
561 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
562 | new Equality(body, var__virtual_2_, var_SourceComm); | ||
563 | // Element != SourceElement | ||
564 | new Inequality(body, var_Element, var_SourceElement); | ||
565 | bodies.add(body); | ||
566 | } | ||
567 | { | ||
568 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
569 | annotation.addAttribute("severity", "error"); | ||
570 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
571 | new ParameterReference("Link") | ||
572 | })); | ||
573 | annotation.addAttribute("message", "Communication links must start from the containing element."); | ||
574 | addAnnotation(annotation); | ||
575 | } | ||
576 | return bodies; | ||
577 | } | ||
578 | } | ||
579 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CommunicationLoop.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CommunicationLoop.java new file mode 100644 index 00000000..f5835baf --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CommunicationLoop.java | |||
@@ -0,0 +1,557 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * // No communication loops may exist | ||
49 | * // No spacecraft may directly communicate with itself | ||
50 | * | ||
51 | * {@literal @}Constraint(severity = "error", key = {Element}, | ||
52 | * message = "Communication loop.") | ||
53 | * pattern communicationLoop(Element : CommunicatingElement) { | ||
54 | * find indirectCommunicationLink(Element, Element); | ||
55 | * } | ||
56 | * </pre></code> | ||
57 | * | ||
58 | * @see Matcher | ||
59 | * @see Match | ||
60 | * | ||
61 | */ | ||
62 | @SuppressWarnings("all") | ||
63 | public final class CommunicationLoop extends BaseGeneratedEMFQuerySpecification<CommunicationLoop.Matcher> { | ||
64 | /** | ||
65 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLoop pattern, | ||
66 | * to be used in conjunction with {@link Matcher}. | ||
67 | * | ||
68 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
69 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
70 | * usable to represent a match of the pattern in the result of a query, | ||
71 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
72 | * | ||
73 | * @see Matcher | ||
74 | * | ||
75 | */ | ||
76 | public static abstract class Match extends BasePatternMatch { | ||
77 | private CommunicatingElement fElement; | ||
78 | |||
79 | private static List<String> parameterNames = makeImmutableList("Element"); | ||
80 | |||
81 | private Match(final CommunicatingElement pElement) { | ||
82 | this.fElement = pElement; | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public Object get(final String parameterName) { | ||
87 | if ("Element".equals(parameterName)) return this.fElement; | ||
88 | return null; | ||
89 | } | ||
90 | |||
91 | public CommunicatingElement getElement() { | ||
92 | return this.fElement; | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public boolean set(final String parameterName, final Object newValue) { | ||
97 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
98 | if ("Element".equals(parameterName) ) { | ||
99 | this.fElement = (CommunicatingElement) newValue; | ||
100 | return true; | ||
101 | } | ||
102 | return false; | ||
103 | } | ||
104 | |||
105 | public void setElement(final CommunicatingElement pElement) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | this.fElement = pElement; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public String patternName() { | ||
112 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLoop"; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<String> parameterNames() { | ||
117 | return CommunicationLoop.Match.parameterNames; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public Object[] toArray() { | ||
122 | return new Object[]{fElement}; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public CommunicationLoop.Match toImmutable() { | ||
127 | return isMutable() ? newMatch(fElement) : this; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public String prettyPrint() { | ||
132 | StringBuilder result = new StringBuilder(); | ||
133 | result.append("\"Element\"=" + prettyPrintValue(fElement)); | ||
134 | return result.toString(); | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public int hashCode() { | ||
139 | return Objects.hash(fElement); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public boolean equals(final Object obj) { | ||
144 | if (this == obj) | ||
145 | return true; | ||
146 | if (obj == null) { | ||
147 | return false; | ||
148 | } | ||
149 | if ((obj instanceof CommunicationLoop.Match)) { | ||
150 | CommunicationLoop.Match other = (CommunicationLoop.Match) obj; | ||
151 | return Objects.equals(fElement, other.fElement); | ||
152 | } else { | ||
153 | // this should be infrequent | ||
154 | if (!(obj instanceof IPatternMatch)) { | ||
155 | return false; | ||
156 | } | ||
157 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
158 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public CommunicationLoop specification() { | ||
164 | return CommunicationLoop.instance(); | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * Returns an empty, mutable match. | ||
169 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
170 | * | ||
171 | * @return the empty match. | ||
172 | * | ||
173 | */ | ||
174 | public static CommunicationLoop.Match newEmptyMatch() { | ||
175 | return new Mutable(null); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns a mutable (partial) match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
183 | * @return the new, mutable (partial) match object. | ||
184 | * | ||
185 | */ | ||
186 | public static CommunicationLoop.Match newMutableMatch(final CommunicatingElement pElement) { | ||
187 | return new Mutable(pElement); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a new (partial) match. | ||
192 | * This can be used e.g. to call the matcher with a partial match. | ||
193 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
194 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
195 | * @return the (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static CommunicationLoop.Match newMatch(final CommunicatingElement pElement) { | ||
199 | return new Immutable(pElement); | ||
200 | } | ||
201 | |||
202 | private static final class Mutable extends CommunicationLoop.Match { | ||
203 | Mutable(final CommunicatingElement pElement) { | ||
204 | super(pElement); | ||
205 | } | ||
206 | |||
207 | @Override | ||
208 | public boolean isMutable() { | ||
209 | return true; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | private static final class Immutable extends CommunicationLoop.Match { | ||
214 | Immutable(final CommunicatingElement pElement) { | ||
215 | super(pElement); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return false; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | /** | ||
226 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLoop pattern, | ||
227 | * providing pattern-specific query methods. | ||
228 | * | ||
229 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
230 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
231 | * | ||
232 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
233 | * | ||
234 | * <p>Original source: | ||
235 | * <code><pre> | ||
236 | * // No communication loops may exist | ||
237 | * // No spacecraft may directly communicate with itself | ||
238 | * | ||
239 | * {@literal @}Constraint(severity = "error", key = {Element}, | ||
240 | * message = "Communication loop.") | ||
241 | * pattern communicationLoop(Element : CommunicatingElement) { | ||
242 | * find indirectCommunicationLink(Element, Element); | ||
243 | * } | ||
244 | * </pre></code> | ||
245 | * | ||
246 | * @see Match | ||
247 | * @see CommunicationLoop | ||
248 | * | ||
249 | */ | ||
250 | public static class Matcher extends BaseMatcher<CommunicationLoop.Match> { | ||
251 | /** | ||
252 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
253 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
254 | * | ||
255 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
256 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
257 | * | ||
258 | */ | ||
259 | public static CommunicationLoop.Matcher on(final ViatraQueryEngine engine) { | ||
260 | // check if matcher already exists | ||
261 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
262 | if (matcher == null) { | ||
263 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
264 | } | ||
265 | return matcher; | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
270 | * @return an initialized matcher | ||
271 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
272 | * | ||
273 | */ | ||
274 | public static CommunicationLoop.Matcher create() { | ||
275 | return new Matcher(); | ||
276 | } | ||
277 | |||
278 | private static final int POSITION_ELEMENT = 0; | ||
279 | |||
280 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CommunicationLoop.Matcher.class); | ||
281 | |||
282 | /** | ||
283 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
284 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
285 | * | ||
286 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
287 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
288 | * | ||
289 | */ | ||
290 | private Matcher() { | ||
291 | super(querySpecification()); | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
296 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
297 | * @return matches represented as a Match object. | ||
298 | * | ||
299 | */ | ||
300 | public Collection<CommunicationLoop.Match> getAllMatches(final CommunicatingElement pElement) { | ||
301 | return rawStreamAllMatches(new Object[]{pElement}).collect(Collectors.toSet()); | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
306 | * </p> | ||
307 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
308 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
309 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
310 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
311 | * @return a stream of matches represented as a Match object. | ||
312 | * | ||
313 | */ | ||
314 | public Stream<CommunicationLoop.Match> streamAllMatches(final CommunicatingElement pElement) { | ||
315 | return rawStreamAllMatches(new Object[]{pElement}); | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
320 | * Neither determinism nor randomness of selection is guaranteed. | ||
321 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
322 | * @return a match represented as a Match object, or null if no match is found. | ||
323 | * | ||
324 | */ | ||
325 | public Optional<CommunicationLoop.Match> getOneArbitraryMatch(final CommunicatingElement pElement) { | ||
326 | return rawGetOneArbitraryMatch(new Object[]{pElement}); | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
331 | * under any possible substitution of the unspecified parameters (if any). | ||
332 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
333 | * @return true if the input is a valid (partial) match of the pattern. | ||
334 | * | ||
335 | */ | ||
336 | public boolean hasMatch(final CommunicatingElement pElement) { | ||
337 | return rawHasMatch(new Object[]{pElement}); | ||
338 | } | ||
339 | |||
340 | /** | ||
341 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
342 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
343 | * @return the number of pattern matches found. | ||
344 | * | ||
345 | */ | ||
346 | public int countMatches(final CommunicatingElement pElement) { | ||
347 | return rawCountMatches(new Object[]{pElement}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
352 | * Neither determinism nor randomness of selection is guaranteed. | ||
353 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
354 | * @param processor the action that will process the selected match. | ||
355 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
356 | * | ||
357 | */ | ||
358 | public boolean forOneArbitraryMatch(final CommunicatingElement pElement, final Consumer<? super CommunicationLoop.Match> processor) { | ||
359 | return rawForOneArbitraryMatch(new Object[]{pElement}, processor); | ||
360 | } | ||
361 | |||
362 | /** | ||
363 | * Returns a new (partial) match. | ||
364 | * This can be used e.g. to call the matcher with a partial match. | ||
365 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
366 | * @param pElement the fixed value of pattern parameter Element, or null if not bound. | ||
367 | * @return the (partial) match object. | ||
368 | * | ||
369 | */ | ||
370 | public CommunicationLoop.Match newMatch(final CommunicatingElement pElement) { | ||
371 | return CommunicationLoop.Match.newMatch(pElement); | ||
372 | } | ||
373 | |||
374 | /** | ||
375 | * Retrieve the set of values that occur in matches for Element. | ||
376 | * @return the Set of all values or empty set if there are no matches | ||
377 | * | ||
378 | */ | ||
379 | protected Stream<CommunicatingElement> rawStreamAllValuesOfElement(final Object[] parameters) { | ||
380 | return rawStreamAllValues(POSITION_ELEMENT, parameters).map(CommunicatingElement.class::cast); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for Element. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | public Set<CommunicatingElement> getAllValuesOfElement() { | ||
389 | return rawStreamAllValuesOfElement(emptyArray()).collect(Collectors.toSet()); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for Element. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Stream<CommunicatingElement> streamAllValuesOfElement() { | ||
398 | return rawStreamAllValuesOfElement(emptyArray()); | ||
399 | } | ||
400 | |||
401 | @Override | ||
402 | protected CommunicationLoop.Match tupleToMatch(final Tuple t) { | ||
403 | try { | ||
404 | return CommunicationLoop.Match.newMatch((CommunicatingElement) t.get(POSITION_ELEMENT)); | ||
405 | } catch(ClassCastException e) { | ||
406 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
407 | return null; | ||
408 | } | ||
409 | } | ||
410 | |||
411 | @Override | ||
412 | protected CommunicationLoop.Match arrayToMatch(final Object[] match) { | ||
413 | try { | ||
414 | return CommunicationLoop.Match.newMatch((CommunicatingElement) match[POSITION_ELEMENT]); | ||
415 | } catch(ClassCastException e) { | ||
416 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
417 | return null; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | @Override | ||
422 | protected CommunicationLoop.Match arrayToMatchMutable(final Object[] match) { | ||
423 | try { | ||
424 | return CommunicationLoop.Match.newMutableMatch((CommunicatingElement) match[POSITION_ELEMENT]); | ||
425 | } catch(ClassCastException e) { | ||
426 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
427 | return null; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * @return the singleton instance of the query specification of this pattern | ||
433 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
434 | * | ||
435 | */ | ||
436 | public static IQuerySpecification<CommunicationLoop.Matcher> querySpecification() { | ||
437 | return CommunicationLoop.instance(); | ||
438 | } | ||
439 | } | ||
440 | |||
441 | private CommunicationLoop() { | ||
442 | super(GeneratedPQuery.INSTANCE); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * @return the singleton instance of the query specification | ||
447 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
448 | * | ||
449 | */ | ||
450 | public static CommunicationLoop instance() { | ||
451 | try{ | ||
452 | return LazyHolder.INSTANCE; | ||
453 | } catch (ExceptionInInitializerError err) { | ||
454 | throw processInitializerError(err); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | @Override | ||
459 | protected CommunicationLoop.Matcher instantiate(final ViatraQueryEngine engine) { | ||
460 | return CommunicationLoop.Matcher.on(engine); | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | public CommunicationLoop.Matcher instantiate() { | ||
465 | return CommunicationLoop.Matcher.create(); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public CommunicationLoop.Match newEmptyMatch() { | ||
470 | return CommunicationLoop.Match.newEmptyMatch(); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public CommunicationLoop.Match newMatch(final Object... parameters) { | ||
475 | return CommunicationLoop.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement) parameters[0]); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop (visibility: PUBLIC, simpleName: CommunicationLoop, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
480 | * <b>not</b> at the class load time of the outer class, | ||
481 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop (visibility: PUBLIC, simpleName: CommunicationLoop, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
482 | * | ||
483 | * <p> This workaround is required e.g. to support recursion. | ||
484 | * | ||
485 | */ | ||
486 | private static class LazyHolder { | ||
487 | private static final CommunicationLoop INSTANCE = new CommunicationLoop(); | ||
488 | |||
489 | /** | ||
490 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
491 | * This initialization order is required to support indirect recursion. | ||
492 | * | ||
493 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
494 | * | ||
495 | */ | ||
496 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
497 | |||
498 | public static Object ensureInitialized() { | ||
499 | INSTANCE.ensureInitializedInternal(); | ||
500 | return null; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
505 | private static final CommunicationLoop.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
506 | |||
507 | private final PParameter parameter_Element = new PParameter("Element", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); | ||
508 | |||
509 | private final List<PParameter> parameters = Arrays.asList(parameter_Element); | ||
510 | |||
511 | private GeneratedPQuery() { | ||
512 | super(PVisibility.PUBLIC); | ||
513 | } | ||
514 | |||
515 | @Override | ||
516 | public String getFullyQualifiedName() { | ||
517 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.communicationLoop"; | ||
518 | } | ||
519 | |||
520 | @Override | ||
521 | public List<String> getParameterNames() { | ||
522 | return Arrays.asList("Element"); | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public List<PParameter> getParameters() { | ||
527 | return parameters; | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public Set<PBody> doGetContainedBodies() { | ||
532 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
533 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
534 | { | ||
535 | PBody body = new PBody(this); | ||
536 | PVariable var_Element = body.getOrCreateVariableByName("Element"); | ||
537 | new TypeConstraint(body, Tuples.flatTupleOf(var_Element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
538 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
539 | new ExportedParameter(body, var_Element, parameter_Element) | ||
540 | )); | ||
541 | // find indirectCommunicationLink(Element, Element) | ||
542 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Element, var_Element), IndirectCommunicationLink.instance().getInternalQueryRepresentation()); | ||
543 | bodies.add(body); | ||
544 | } | ||
545 | { | ||
546 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
547 | annotation.addAttribute("severity", "error"); | ||
548 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
549 | new ParameterReference("Element") | ||
550 | })); | ||
551 | annotation.addAttribute("message", "Communication loop."); | ||
552 | addAnnotation(annotation); | ||
553 | } | ||
554 | return bodies; | ||
555 | } | ||
556 | } | ||
557 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java new file mode 100644 index 00000000..474719b2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java | |||
@@ -0,0 +1,544 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // Cost | ||
47 | * | ||
48 | * pattern costMetric(Cost : java Double) { | ||
49 | * Cost == sum find missionCost(_, #_); | ||
50 | * } | ||
51 | * </pre></code> | ||
52 | * | ||
53 | * @see Matcher | ||
54 | * @see Match | ||
55 | * | ||
56 | */ | ||
57 | @SuppressWarnings("all") | ||
58 | public final class CostMetric extends BaseGeneratedEMFQuerySpecification<CostMetric.Matcher> { | ||
59 | /** | ||
60 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric pattern, | ||
61 | * to be used in conjunction with {@link Matcher}. | ||
62 | * | ||
63 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
64 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
65 | * usable to represent a match of the pattern in the result of a query, | ||
66 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
67 | * | ||
68 | * @see Matcher | ||
69 | * | ||
70 | */ | ||
71 | public static abstract class Match extends BasePatternMatch { | ||
72 | private Double fCost; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("Cost"); | ||
75 | |||
76 | private Match(final Double pCost) { | ||
77 | this.fCost = pCost; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | if ("Cost".equals(parameterName)) return this.fCost; | ||
83 | return null; | ||
84 | } | ||
85 | |||
86 | public Double getCost() { | ||
87 | return this.fCost; | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public boolean set(final String parameterName, final Object newValue) { | ||
92 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
93 | if ("Cost".equals(parameterName) ) { | ||
94 | this.fCost = (Double) newValue; | ||
95 | return true; | ||
96 | } | ||
97 | return false; | ||
98 | } | ||
99 | |||
100 | public void setCost(final Double pCost) { | ||
101 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
102 | this.fCost = pCost; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String patternName() { | ||
107 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<String> parameterNames() { | ||
112 | return CostMetric.Match.parameterNames; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Object[] toArray() { | ||
117 | return new Object[]{fCost}; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public CostMetric.Match toImmutable() { | ||
122 | return isMutable() ? newMatch(fCost) : this; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public String prettyPrint() { | ||
127 | StringBuilder result = new StringBuilder(); | ||
128 | result.append("\"Cost\"=" + prettyPrintValue(fCost)); | ||
129 | return result.toString(); | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public int hashCode() { | ||
134 | return Objects.hash(fCost); | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public boolean equals(final Object obj) { | ||
139 | if (this == obj) | ||
140 | return true; | ||
141 | if (obj == null) { | ||
142 | return false; | ||
143 | } | ||
144 | if ((obj instanceof CostMetric.Match)) { | ||
145 | CostMetric.Match other = (CostMetric.Match) obj; | ||
146 | return Objects.equals(fCost, other.fCost); | ||
147 | } else { | ||
148 | // this should be infrequent | ||
149 | if (!(obj instanceof IPatternMatch)) { | ||
150 | return false; | ||
151 | } | ||
152 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
153 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public CostMetric specification() { | ||
159 | return CostMetric.instance(); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * Returns an empty, mutable match. | ||
164 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
165 | * | ||
166 | * @return the empty match. | ||
167 | * | ||
168 | */ | ||
169 | public static CostMetric.Match newEmptyMatch() { | ||
170 | return new Mutable(null); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns a mutable (partial) match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
178 | * @return the new, mutable (partial) match object. | ||
179 | * | ||
180 | */ | ||
181 | public static CostMetric.Match newMutableMatch(final Double pCost) { | ||
182 | return new Mutable(pCost); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * Returns a new (partial) match. | ||
187 | * This can be used e.g. to call the matcher with a partial match. | ||
188 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
189 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
190 | * @return the (partial) match object. | ||
191 | * | ||
192 | */ | ||
193 | public static CostMetric.Match newMatch(final Double pCost) { | ||
194 | return new Immutable(pCost); | ||
195 | } | ||
196 | |||
197 | private static final class Mutable extends CostMetric.Match { | ||
198 | Mutable(final Double pCost) { | ||
199 | super(pCost); | ||
200 | } | ||
201 | |||
202 | @Override | ||
203 | public boolean isMutable() { | ||
204 | return true; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | private static final class Immutable extends CostMetric.Match { | ||
209 | Immutable(final Double pCost) { | ||
210 | super(pCost); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return false; | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | |||
220 | /** | ||
221 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric pattern, | ||
222 | * providing pattern-specific query methods. | ||
223 | * | ||
224 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
225 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
226 | * | ||
227 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
228 | * | ||
229 | * <p>Original source: | ||
230 | * <code><pre> | ||
231 | * // Cost | ||
232 | * | ||
233 | * pattern costMetric(Cost : java Double) { | ||
234 | * Cost == sum find missionCost(_, #_); | ||
235 | * } | ||
236 | * </pre></code> | ||
237 | * | ||
238 | * @see Match | ||
239 | * @see CostMetric | ||
240 | * | ||
241 | */ | ||
242 | public static class Matcher extends BaseMatcher<CostMetric.Match> { | ||
243 | /** | ||
244 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
245 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
246 | * | ||
247 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
248 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
249 | * | ||
250 | */ | ||
251 | public static CostMetric.Matcher on(final ViatraQueryEngine engine) { | ||
252 | // check if matcher already exists | ||
253 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
254 | if (matcher == null) { | ||
255 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
256 | } | ||
257 | return matcher; | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
262 | * @return an initialized matcher | ||
263 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
264 | * | ||
265 | */ | ||
266 | public static CostMetric.Matcher create() { | ||
267 | return new Matcher(); | ||
268 | } | ||
269 | |||
270 | private static final int POSITION_COST = 0; | ||
271 | |||
272 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CostMetric.Matcher.class); | ||
273 | |||
274 | /** | ||
275 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
276 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
277 | * | ||
278 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
279 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
280 | * | ||
281 | */ | ||
282 | private Matcher() { | ||
283 | super(querySpecification()); | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
288 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
289 | * @return matches represented as a Match object. | ||
290 | * | ||
291 | */ | ||
292 | public Collection<CostMetric.Match> getAllMatches(final Double pCost) { | ||
293 | return rawStreamAllMatches(new Object[]{pCost}).collect(Collectors.toSet()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * </p> | ||
299 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
300 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
301 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
302 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
303 | * @return a stream of matches represented as a Match object. | ||
304 | * | ||
305 | */ | ||
306 | public Stream<CostMetric.Match> streamAllMatches(final Double pCost) { | ||
307 | return rawStreamAllMatches(new Object[]{pCost}); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
312 | * Neither determinism nor randomness of selection is guaranteed. | ||
313 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
314 | * @return a match represented as a Match object, or null if no match is found. | ||
315 | * | ||
316 | */ | ||
317 | public Optional<CostMetric.Match> getOneArbitraryMatch(final Double pCost) { | ||
318 | return rawGetOneArbitraryMatch(new Object[]{pCost}); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
323 | * under any possible substitution of the unspecified parameters (if any). | ||
324 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
325 | * @return true if the input is a valid (partial) match of the pattern. | ||
326 | * | ||
327 | */ | ||
328 | public boolean hasMatch(final Double pCost) { | ||
329 | return rawHasMatch(new Object[]{pCost}); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
334 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
335 | * @return the number of pattern matches found. | ||
336 | * | ||
337 | */ | ||
338 | public int countMatches(final Double pCost) { | ||
339 | return rawCountMatches(new Object[]{pCost}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
344 | * Neither determinism nor randomness of selection is guaranteed. | ||
345 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
346 | * @param processor the action that will process the selected match. | ||
347 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
348 | * | ||
349 | */ | ||
350 | public boolean forOneArbitraryMatch(final Double pCost, final Consumer<? super CostMetric.Match> processor) { | ||
351 | return rawForOneArbitraryMatch(new Object[]{pCost}, processor); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Returns a new (partial) match. | ||
356 | * This can be used e.g. to call the matcher with a partial match. | ||
357 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
358 | * @param pCost the fixed value of pattern parameter Cost, or null if not bound. | ||
359 | * @return the (partial) match object. | ||
360 | * | ||
361 | */ | ||
362 | public CostMetric.Match newMatch(final Double pCost) { | ||
363 | return CostMetric.Match.newMatch(pCost); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Retrieve the set of values that occur in matches for Cost. | ||
368 | * @return the Set of all values or empty set if there are no matches | ||
369 | * | ||
370 | */ | ||
371 | protected Stream<Double> rawStreamAllValuesOfCost(final Object[] parameters) { | ||
372 | return rawStreamAllValues(POSITION_COST, parameters).map(Double.class::cast); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Retrieve the set of values that occur in matches for Cost. | ||
377 | * @return the Set of all values or empty set if there are no matches | ||
378 | * | ||
379 | */ | ||
380 | public Set<Double> getAllValuesOfCost() { | ||
381 | return rawStreamAllValuesOfCost(emptyArray()).collect(Collectors.toSet()); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for Cost. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | public Stream<Double> streamAllValuesOfCost() { | ||
390 | return rawStreamAllValuesOfCost(emptyArray()); | ||
391 | } | ||
392 | |||
393 | @Override | ||
394 | protected CostMetric.Match tupleToMatch(final Tuple t) { | ||
395 | try { | ||
396 | return CostMetric.Match.newMatch((Double) t.get(POSITION_COST)); | ||
397 | } catch(ClassCastException e) { | ||
398 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
399 | return null; | ||
400 | } | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected CostMetric.Match arrayToMatch(final Object[] match) { | ||
405 | try { | ||
406 | return CostMetric.Match.newMatch((Double) match[POSITION_COST]); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected CostMetric.Match arrayToMatchMutable(final Object[] match) { | ||
415 | try { | ||
416 | return CostMetric.Match.newMutableMatch((Double) match[POSITION_COST]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * @return the singleton instance of the query specification of this pattern | ||
425 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
426 | * | ||
427 | */ | ||
428 | public static IQuerySpecification<CostMetric.Matcher> querySpecification() { | ||
429 | return CostMetric.instance(); | ||
430 | } | ||
431 | } | ||
432 | |||
433 | private CostMetric() { | ||
434 | super(GeneratedPQuery.INSTANCE); | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * @return the singleton instance of the query specification | ||
439 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
440 | * | ||
441 | */ | ||
442 | public static CostMetric instance() { | ||
443 | try{ | ||
444 | return LazyHolder.INSTANCE; | ||
445 | } catch (ExceptionInInitializerError err) { | ||
446 | throw processInitializerError(err); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | @Override | ||
451 | protected CostMetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
452 | return CostMetric.Matcher.on(engine); | ||
453 | } | ||
454 | |||
455 | @Override | ||
456 | public CostMetric.Matcher instantiate() { | ||
457 | return CostMetric.Matcher.create(); | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | public CostMetric.Match newEmptyMatch() { | ||
462 | return CostMetric.Match.newEmptyMatch(); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public CostMetric.Match newMatch(final Object... parameters) { | ||
467 | return CostMetric.Match.newMatch((java.lang.Double) parameters[0]); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
472 | * <b>not</b> at the class load time of the outer class, | ||
473 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
474 | * | ||
475 | * <p> This workaround is required e.g. to support recursion. | ||
476 | * | ||
477 | */ | ||
478 | private static class LazyHolder { | ||
479 | private static final CostMetric INSTANCE = new CostMetric(); | ||
480 | |||
481 | /** | ||
482 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
483 | * This initialization order is required to support indirect recursion. | ||
484 | * | ||
485 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
486 | * | ||
487 | */ | ||
488 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
489 | |||
490 | public static Object ensureInitialized() { | ||
491 | INSTANCE.ensureInitializedInternal(); | ||
492 | return null; | ||
493 | } | ||
494 | } | ||
495 | |||
496 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
497 | private static final CostMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
498 | |||
499 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
500 | |||
501 | private final List<PParameter> parameters = Arrays.asList(parameter_Cost); | ||
502 | |||
503 | private GeneratedPQuery() { | ||
504 | super(PVisibility.PUBLIC); | ||
505 | } | ||
506 | |||
507 | @Override | ||
508 | public String getFullyQualifiedName() { | ||
509 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric"; | ||
510 | } | ||
511 | |||
512 | @Override | ||
513 | public List<String> getParameterNames() { | ||
514 | return Arrays.asList("Cost"); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public List<PParameter> getParameters() { | ||
519 | return parameters; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public Set<PBody> doGetContainedBodies() { | ||
524 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
525 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
526 | { | ||
527 | PBody body = new PBody(this); | ||
528 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
529 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
530 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
531 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
532 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
533 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
534 | )); | ||
535 | // Cost == sum find missionCost(_, #_) | ||
536 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
537 | new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), MissionCost.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); | ||
538 | new Equality(body, var_Cost, var__virtual_0_); | ||
539 | bodies.add(body); | ||
540 | } | ||
541 | return bodies; | ||
542 | } | ||
543 | } | ||
544 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java new file mode 100644 index 00000000..23b02ce4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java | |||
@@ -0,0 +1,552 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // | ||
47 | * // Metrics | ||
48 | * // | ||
49 | * | ||
50 | * // Coverage | ||
51 | * | ||
52 | * pattern coverageMetric(Coverage : java Double) { | ||
53 | * Coverage == sum find missionCoverage(_, #_); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class CoverageMetric extends BaseGeneratedEMFQuerySpecification<CoverageMetric.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Double fCoverage; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("Coverage"); | ||
79 | |||
80 | private Match(final Double pCoverage) { | ||
81 | this.fCoverage = pCoverage; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | if ("Coverage".equals(parameterName)) return this.fCoverage; | ||
87 | return null; | ||
88 | } | ||
89 | |||
90 | public Double getCoverage() { | ||
91 | return this.fCoverage; | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public boolean set(final String parameterName, final Object newValue) { | ||
96 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
97 | if ("Coverage".equals(parameterName) ) { | ||
98 | this.fCoverage = (Double) newValue; | ||
99 | return true; | ||
100 | } | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | public void setCoverage(final Double pCoverage) { | ||
105 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
106 | this.fCoverage = pCoverage; | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public String patternName() { | ||
111 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric"; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public List<String> parameterNames() { | ||
116 | return CoverageMetric.Match.parameterNames; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public Object[] toArray() { | ||
121 | return new Object[]{fCoverage}; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public CoverageMetric.Match toImmutable() { | ||
126 | return isMutable() ? newMatch(fCoverage) : this; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public String prettyPrint() { | ||
131 | StringBuilder result = new StringBuilder(); | ||
132 | result.append("\"Coverage\"=" + prettyPrintValue(fCoverage)); | ||
133 | return result.toString(); | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public int hashCode() { | ||
138 | return Objects.hash(fCoverage); | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public boolean equals(final Object obj) { | ||
143 | if (this == obj) | ||
144 | return true; | ||
145 | if (obj == null) { | ||
146 | return false; | ||
147 | } | ||
148 | if ((obj instanceof CoverageMetric.Match)) { | ||
149 | CoverageMetric.Match other = (CoverageMetric.Match) obj; | ||
150 | return Objects.equals(fCoverage, other.fCoverage); | ||
151 | } else { | ||
152 | // this should be infrequent | ||
153 | if (!(obj instanceof IPatternMatch)) { | ||
154 | return false; | ||
155 | } | ||
156 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
157 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | @Override | ||
162 | public CoverageMetric specification() { | ||
163 | return CoverageMetric.instance(); | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * Returns an empty, mutable match. | ||
168 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
169 | * | ||
170 | * @return the empty match. | ||
171 | * | ||
172 | */ | ||
173 | public static CoverageMetric.Match newEmptyMatch() { | ||
174 | return new Mutable(null); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * Returns a mutable (partial) match. | ||
179 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
180 | * | ||
181 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
182 | * @return the new, mutable (partial) match object. | ||
183 | * | ||
184 | */ | ||
185 | public static CoverageMetric.Match newMutableMatch(final Double pCoverage) { | ||
186 | return new Mutable(pCoverage); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a new (partial) match. | ||
191 | * This can be used e.g. to call the matcher with a partial match. | ||
192 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
193 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
194 | * @return the (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static CoverageMetric.Match newMatch(final Double pCoverage) { | ||
198 | return new Immutable(pCoverage); | ||
199 | } | ||
200 | |||
201 | private static final class Mutable extends CoverageMetric.Match { | ||
202 | Mutable(final Double pCoverage) { | ||
203 | super(pCoverage); | ||
204 | } | ||
205 | |||
206 | @Override | ||
207 | public boolean isMutable() { | ||
208 | return true; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | private static final class Immutable extends CoverageMetric.Match { | ||
213 | Immutable(final Double pCoverage) { | ||
214 | super(pCoverage); | ||
215 | } | ||
216 | |||
217 | @Override | ||
218 | public boolean isMutable() { | ||
219 | return false; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric pattern, | ||
226 | * providing pattern-specific query methods. | ||
227 | * | ||
228 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
229 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
230 | * | ||
231 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
232 | * | ||
233 | * <p>Original source: | ||
234 | * <code><pre> | ||
235 | * // | ||
236 | * // Metrics | ||
237 | * // | ||
238 | * | ||
239 | * // Coverage | ||
240 | * | ||
241 | * pattern coverageMetric(Coverage : java Double) { | ||
242 | * Coverage == sum find missionCoverage(_, #_); | ||
243 | * } | ||
244 | * </pre></code> | ||
245 | * | ||
246 | * @see Match | ||
247 | * @see CoverageMetric | ||
248 | * | ||
249 | */ | ||
250 | public static class Matcher extends BaseMatcher<CoverageMetric.Match> { | ||
251 | /** | ||
252 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
253 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
254 | * | ||
255 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
256 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
257 | * | ||
258 | */ | ||
259 | public static CoverageMetric.Matcher on(final ViatraQueryEngine engine) { | ||
260 | // check if matcher already exists | ||
261 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
262 | if (matcher == null) { | ||
263 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
264 | } | ||
265 | return matcher; | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
270 | * @return an initialized matcher | ||
271 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
272 | * | ||
273 | */ | ||
274 | public static CoverageMetric.Matcher create() { | ||
275 | return new Matcher(); | ||
276 | } | ||
277 | |||
278 | private static final int POSITION_COVERAGE = 0; | ||
279 | |||
280 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CoverageMetric.Matcher.class); | ||
281 | |||
282 | /** | ||
283 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
284 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
285 | * | ||
286 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
287 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
288 | * | ||
289 | */ | ||
290 | private Matcher() { | ||
291 | super(querySpecification()); | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
296 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
297 | * @return matches represented as a Match object. | ||
298 | * | ||
299 | */ | ||
300 | public Collection<CoverageMetric.Match> getAllMatches(final Double pCoverage) { | ||
301 | return rawStreamAllMatches(new Object[]{pCoverage}).collect(Collectors.toSet()); | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
306 | * </p> | ||
307 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
308 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
309 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
310 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
311 | * @return a stream of matches represented as a Match object. | ||
312 | * | ||
313 | */ | ||
314 | public Stream<CoverageMetric.Match> streamAllMatches(final Double pCoverage) { | ||
315 | return rawStreamAllMatches(new Object[]{pCoverage}); | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
320 | * Neither determinism nor randomness of selection is guaranteed. | ||
321 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
322 | * @return a match represented as a Match object, or null if no match is found. | ||
323 | * | ||
324 | */ | ||
325 | public Optional<CoverageMetric.Match> getOneArbitraryMatch(final Double pCoverage) { | ||
326 | return rawGetOneArbitraryMatch(new Object[]{pCoverage}); | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
331 | * under any possible substitution of the unspecified parameters (if any). | ||
332 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
333 | * @return true if the input is a valid (partial) match of the pattern. | ||
334 | * | ||
335 | */ | ||
336 | public boolean hasMatch(final Double pCoverage) { | ||
337 | return rawHasMatch(new Object[]{pCoverage}); | ||
338 | } | ||
339 | |||
340 | /** | ||
341 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
342 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
343 | * @return the number of pattern matches found. | ||
344 | * | ||
345 | */ | ||
346 | public int countMatches(final Double pCoverage) { | ||
347 | return rawCountMatches(new Object[]{pCoverage}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
352 | * Neither determinism nor randomness of selection is guaranteed. | ||
353 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
354 | * @param processor the action that will process the selected match. | ||
355 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
356 | * | ||
357 | */ | ||
358 | public boolean forOneArbitraryMatch(final Double pCoverage, final Consumer<? super CoverageMetric.Match> processor) { | ||
359 | return rawForOneArbitraryMatch(new Object[]{pCoverage}, processor); | ||
360 | } | ||
361 | |||
362 | /** | ||
363 | * Returns a new (partial) match. | ||
364 | * This can be used e.g. to call the matcher with a partial match. | ||
365 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
366 | * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. | ||
367 | * @return the (partial) match object. | ||
368 | * | ||
369 | */ | ||
370 | public CoverageMetric.Match newMatch(final Double pCoverage) { | ||
371 | return CoverageMetric.Match.newMatch(pCoverage); | ||
372 | } | ||
373 | |||
374 | /** | ||
375 | * Retrieve the set of values that occur in matches for Coverage. | ||
376 | * @return the Set of all values or empty set if there are no matches | ||
377 | * | ||
378 | */ | ||
379 | protected Stream<Double> rawStreamAllValuesOfCoverage(final Object[] parameters) { | ||
380 | return rawStreamAllValues(POSITION_COVERAGE, parameters).map(Double.class::cast); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for Coverage. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | public Set<Double> getAllValuesOfCoverage() { | ||
389 | return rawStreamAllValuesOfCoverage(emptyArray()).collect(Collectors.toSet()); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for Coverage. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Stream<Double> streamAllValuesOfCoverage() { | ||
398 | return rawStreamAllValuesOfCoverage(emptyArray()); | ||
399 | } | ||
400 | |||
401 | @Override | ||
402 | protected CoverageMetric.Match tupleToMatch(final Tuple t) { | ||
403 | try { | ||
404 | return CoverageMetric.Match.newMatch((Double) t.get(POSITION_COVERAGE)); | ||
405 | } catch(ClassCastException e) { | ||
406 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
407 | return null; | ||
408 | } | ||
409 | } | ||
410 | |||
411 | @Override | ||
412 | protected CoverageMetric.Match arrayToMatch(final Object[] match) { | ||
413 | try { | ||
414 | return CoverageMetric.Match.newMatch((Double) match[POSITION_COVERAGE]); | ||
415 | } catch(ClassCastException e) { | ||
416 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
417 | return null; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | @Override | ||
422 | protected CoverageMetric.Match arrayToMatchMutable(final Object[] match) { | ||
423 | try { | ||
424 | return CoverageMetric.Match.newMutableMatch((Double) match[POSITION_COVERAGE]); | ||
425 | } catch(ClassCastException e) { | ||
426 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
427 | return null; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * @return the singleton instance of the query specification of this pattern | ||
433 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
434 | * | ||
435 | */ | ||
436 | public static IQuerySpecification<CoverageMetric.Matcher> querySpecification() { | ||
437 | return CoverageMetric.instance(); | ||
438 | } | ||
439 | } | ||
440 | |||
441 | private CoverageMetric() { | ||
442 | super(GeneratedPQuery.INSTANCE); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * @return the singleton instance of the query specification | ||
447 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
448 | * | ||
449 | */ | ||
450 | public static CoverageMetric instance() { | ||
451 | try{ | ||
452 | return LazyHolder.INSTANCE; | ||
453 | } catch (ExceptionInInitializerError err) { | ||
454 | throw processInitializerError(err); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | @Override | ||
459 | protected CoverageMetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
460 | return CoverageMetric.Matcher.on(engine); | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | public CoverageMetric.Matcher instantiate() { | ||
465 | return CoverageMetric.Matcher.create(); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public CoverageMetric.Match newEmptyMatch() { | ||
470 | return CoverageMetric.Match.newEmptyMatch(); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public CoverageMetric.Match newMatch(final Object... parameters) { | ||
475 | return CoverageMetric.Match.newMatch((java.lang.Double) parameters[0]); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric (visibility: PUBLIC, simpleName: CoverageMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
480 | * <b>not</b> at the class load time of the outer class, | ||
481 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric (visibility: PUBLIC, simpleName: CoverageMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
482 | * | ||
483 | * <p> This workaround is required e.g. to support recursion. | ||
484 | * | ||
485 | */ | ||
486 | private static class LazyHolder { | ||
487 | private static final CoverageMetric INSTANCE = new CoverageMetric(); | ||
488 | |||
489 | /** | ||
490 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
491 | * This initialization order is required to support indirect recursion. | ||
492 | * | ||
493 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
494 | * | ||
495 | */ | ||
496 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
497 | |||
498 | public static Object ensureInitialized() { | ||
499 | INSTANCE.ensureInitializedInternal(); | ||
500 | return null; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
505 | private static final CoverageMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
506 | |||
507 | private final PParameter parameter_Coverage = new PParameter("Coverage", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
508 | |||
509 | private final List<PParameter> parameters = Arrays.asList(parameter_Coverage); | ||
510 | |||
511 | private GeneratedPQuery() { | ||
512 | super(PVisibility.PUBLIC); | ||
513 | } | ||
514 | |||
515 | @Override | ||
516 | public String getFullyQualifiedName() { | ||
517 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric"; | ||
518 | } | ||
519 | |||
520 | @Override | ||
521 | public List<String> getParameterNames() { | ||
522 | return Arrays.asList("Coverage"); | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public List<PParameter> getParameters() { | ||
527 | return parameters; | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public Set<PBody> doGetContainedBodies() { | ||
532 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
533 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
534 | { | ||
535 | PBody body = new PBody(this); | ||
536 | PVariable var_Coverage = body.getOrCreateVariableByName("Coverage"); | ||
537 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
538 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
539 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Coverage), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_Coverage, parameter_Coverage) | ||
542 | )); | ||
543 | // Coverage == sum find missionCoverage(_, #_) | ||
544 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
545 | new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), MissionCoverage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); | ||
546 | new Equality(body, var_Coverage, var__virtual_0_); | ||
547 | bodies.add(body); | ||
548 | } | ||
549 | return bodies; | ||
550 | } | ||
551 | } | ||
552 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CubeSatWithKaAntenna.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CubeSatWithKaAntenna.java new file mode 100644 index 00000000..c15563ff --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CubeSatWithKaAntenna.java | |||
@@ -0,0 +1,573 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EDataType; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
46 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
47 | |||
48 | /** | ||
49 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
50 | * | ||
51 | * <p>Original source: | ||
52 | * <code><pre> | ||
53 | * // Only a Small Satellite can be configured with a Ka-band communication system | ||
54 | * | ||
55 | * {@literal @}Constraint(severity = "error", key = {Spacecraft}, | ||
56 | * message = "Only a Small Satellite can be configured with a Ka-band communication system.") | ||
57 | * pattern cubeSatWithKaAntenna(Spacecraft : Spacecraft) { | ||
58 | * CommunicatingElement.commSubsystem.band(Spacecraft, TransceiverBand::Ka); | ||
59 | * neg find smallSat(Spacecraft); | ||
60 | * } | ||
61 | * </pre></code> | ||
62 | * | ||
63 | * @see Matcher | ||
64 | * @see Match | ||
65 | * | ||
66 | */ | ||
67 | @SuppressWarnings("all") | ||
68 | public final class CubeSatWithKaAntenna extends BaseGeneratedEMFQuerySpecification<CubeSatWithKaAntenna.Matcher> { | ||
69 | /** | ||
70 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.cubeSatWithKaAntenna pattern, | ||
71 | * to be used in conjunction with {@link Matcher}. | ||
72 | * | ||
73 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
74 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
75 | * usable to represent a match of the pattern in the result of a query, | ||
76 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
77 | * | ||
78 | * @see Matcher | ||
79 | * | ||
80 | */ | ||
81 | public static abstract class Match extends BasePatternMatch { | ||
82 | private Spacecraft fSpacecraft; | ||
83 | |||
84 | private static List<String> parameterNames = makeImmutableList("Spacecraft"); | ||
85 | |||
86 | private Match(final Spacecraft pSpacecraft) { | ||
87 | this.fSpacecraft = pSpacecraft; | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final String parameterName) { | ||
92 | if ("Spacecraft".equals(parameterName)) return this.fSpacecraft; | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | public Spacecraft getSpacecraft() { | ||
97 | return this.fSpacecraft; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public boolean set(final String parameterName, final Object newValue) { | ||
102 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
103 | if ("Spacecraft".equals(parameterName) ) { | ||
104 | this.fSpacecraft = (Spacecraft) newValue; | ||
105 | return true; | ||
106 | } | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public void setSpacecraft(final Spacecraft pSpacecraft) { | ||
111 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
112 | this.fSpacecraft = pSpacecraft; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public String patternName() { | ||
117 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.cubeSatWithKaAntenna"; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<String> parameterNames() { | ||
122 | return CubeSatWithKaAntenna.Match.parameterNames; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Object[] toArray() { | ||
127 | return new Object[]{fSpacecraft}; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public CubeSatWithKaAntenna.Match toImmutable() { | ||
132 | return isMutable() ? newMatch(fSpacecraft) : this; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String prettyPrint() { | ||
137 | StringBuilder result = new StringBuilder(); | ||
138 | result.append("\"Spacecraft\"=" + prettyPrintValue(fSpacecraft)); | ||
139 | return result.toString(); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public int hashCode() { | ||
144 | return Objects.hash(fSpacecraft); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public boolean equals(final Object obj) { | ||
149 | if (this == obj) | ||
150 | return true; | ||
151 | if (obj == null) { | ||
152 | return false; | ||
153 | } | ||
154 | if ((obj instanceof CubeSatWithKaAntenna.Match)) { | ||
155 | CubeSatWithKaAntenna.Match other = (CubeSatWithKaAntenna.Match) obj; | ||
156 | return Objects.equals(fSpacecraft, other.fSpacecraft); | ||
157 | } else { | ||
158 | // this should be infrequent | ||
159 | if (!(obj instanceof IPatternMatch)) { | ||
160 | return false; | ||
161 | } | ||
162 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
163 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public CubeSatWithKaAntenna specification() { | ||
169 | return CubeSatWithKaAntenna.instance(); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Returns an empty, mutable match. | ||
174 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
175 | * | ||
176 | * @return the empty match. | ||
177 | * | ||
178 | */ | ||
179 | public static CubeSatWithKaAntenna.Match newEmptyMatch() { | ||
180 | return new Mutable(null); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns a mutable (partial) match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
188 | * @return the new, mutable (partial) match object. | ||
189 | * | ||
190 | */ | ||
191 | public static CubeSatWithKaAntenna.Match newMutableMatch(final Spacecraft pSpacecraft) { | ||
192 | return new Mutable(pSpacecraft); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns a new (partial) match. | ||
197 | * This can be used e.g. to call the matcher with a partial match. | ||
198 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
199 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
200 | * @return the (partial) match object. | ||
201 | * | ||
202 | */ | ||
203 | public static CubeSatWithKaAntenna.Match newMatch(final Spacecraft pSpacecraft) { | ||
204 | return new Immutable(pSpacecraft); | ||
205 | } | ||
206 | |||
207 | private static final class Mutable extends CubeSatWithKaAntenna.Match { | ||
208 | Mutable(final Spacecraft pSpacecraft) { | ||
209 | super(pSpacecraft); | ||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public boolean isMutable() { | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | private static final class Immutable extends CubeSatWithKaAntenna.Match { | ||
219 | Immutable(final Spacecraft pSpacecraft) { | ||
220 | super(pSpacecraft); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.cubeSatWithKaAntenna pattern, | ||
232 | * providing pattern-specific query methods. | ||
233 | * | ||
234 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
235 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
236 | * | ||
237 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
238 | * | ||
239 | * <p>Original source: | ||
240 | * <code><pre> | ||
241 | * // Only a Small Satellite can be configured with a Ka-band communication system | ||
242 | * | ||
243 | * {@literal @}Constraint(severity = "error", key = {Spacecraft}, | ||
244 | * message = "Only a Small Satellite can be configured with a Ka-band communication system.") | ||
245 | * pattern cubeSatWithKaAntenna(Spacecraft : Spacecraft) { | ||
246 | * CommunicatingElement.commSubsystem.band(Spacecraft, TransceiverBand::Ka); | ||
247 | * neg find smallSat(Spacecraft); | ||
248 | * } | ||
249 | * </pre></code> | ||
250 | * | ||
251 | * @see Match | ||
252 | * @see CubeSatWithKaAntenna | ||
253 | * | ||
254 | */ | ||
255 | public static class Matcher extends BaseMatcher<CubeSatWithKaAntenna.Match> { | ||
256 | /** | ||
257 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
258 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
259 | * | ||
260 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
261 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
262 | * | ||
263 | */ | ||
264 | public static CubeSatWithKaAntenna.Matcher on(final ViatraQueryEngine engine) { | ||
265 | // check if matcher already exists | ||
266 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
267 | if (matcher == null) { | ||
268 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
269 | } | ||
270 | return matcher; | ||
271 | } | ||
272 | |||
273 | /** | ||
274 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
275 | * @return an initialized matcher | ||
276 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
277 | * | ||
278 | */ | ||
279 | public static CubeSatWithKaAntenna.Matcher create() { | ||
280 | return new Matcher(); | ||
281 | } | ||
282 | |||
283 | private static final int POSITION_SPACECRAFT = 0; | ||
284 | |||
285 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CubeSatWithKaAntenna.Matcher.class); | ||
286 | |||
287 | /** | ||
288 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
289 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
290 | * | ||
291 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
293 | * | ||
294 | */ | ||
295 | private Matcher() { | ||
296 | super(querySpecification()); | ||
297 | } | ||
298 | |||
299 | /** | ||
300 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
301 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
302 | * @return matches represented as a Match object. | ||
303 | * | ||
304 | */ | ||
305 | public Collection<CubeSatWithKaAntenna.Match> getAllMatches(final Spacecraft pSpacecraft) { | ||
306 | return rawStreamAllMatches(new Object[]{pSpacecraft}).collect(Collectors.toSet()); | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
311 | * </p> | ||
312 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
313 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
314 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
315 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
316 | * @return a stream of matches represented as a Match object. | ||
317 | * | ||
318 | */ | ||
319 | public Stream<CubeSatWithKaAntenna.Match> streamAllMatches(final Spacecraft pSpacecraft) { | ||
320 | return rawStreamAllMatches(new Object[]{pSpacecraft}); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
325 | * Neither determinism nor randomness of selection is guaranteed. | ||
326 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
327 | * @return a match represented as a Match object, or null if no match is found. | ||
328 | * | ||
329 | */ | ||
330 | public Optional<CubeSatWithKaAntenna.Match> getOneArbitraryMatch(final Spacecraft pSpacecraft) { | ||
331 | return rawGetOneArbitraryMatch(new Object[]{pSpacecraft}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
336 | * under any possible substitution of the unspecified parameters (if any). | ||
337 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
338 | * @return true if the input is a valid (partial) match of the pattern. | ||
339 | * | ||
340 | */ | ||
341 | public boolean hasMatch(final Spacecraft pSpacecraft) { | ||
342 | return rawHasMatch(new Object[]{pSpacecraft}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
347 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
348 | * @return the number of pattern matches found. | ||
349 | * | ||
350 | */ | ||
351 | public int countMatches(final Spacecraft pSpacecraft) { | ||
352 | return rawCountMatches(new Object[]{pSpacecraft}); | ||
353 | } | ||
354 | |||
355 | /** | ||
356 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
357 | * Neither determinism nor randomness of selection is guaranteed. | ||
358 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
359 | * @param processor the action that will process the selected match. | ||
360 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
361 | * | ||
362 | */ | ||
363 | public boolean forOneArbitraryMatch(final Spacecraft pSpacecraft, final Consumer<? super CubeSatWithKaAntenna.Match> processor) { | ||
364 | return rawForOneArbitraryMatch(new Object[]{pSpacecraft}, processor); | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * Returns a new (partial) match. | ||
369 | * This can be used e.g. to call the matcher with a partial match. | ||
370 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
371 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
372 | * @return the (partial) match object. | ||
373 | * | ||
374 | */ | ||
375 | public CubeSatWithKaAntenna.Match newMatch(final Spacecraft pSpacecraft) { | ||
376 | return CubeSatWithKaAntenna.Match.newMatch(pSpacecraft); | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * Retrieve the set of values that occur in matches for Spacecraft. | ||
381 | * @return the Set of all values or empty set if there are no matches | ||
382 | * | ||
383 | */ | ||
384 | protected Stream<Spacecraft> rawStreamAllValuesOfSpacecraft(final Object[] parameters) { | ||
385 | return rawStreamAllValues(POSITION_SPACECRAFT, parameters).map(Spacecraft.class::cast); | ||
386 | } | ||
387 | |||
388 | /** | ||
389 | * Retrieve the set of values that occur in matches for Spacecraft. | ||
390 | * @return the Set of all values or empty set if there are no matches | ||
391 | * | ||
392 | */ | ||
393 | public Set<Spacecraft> getAllValuesOfSpacecraft() { | ||
394 | return rawStreamAllValuesOfSpacecraft(emptyArray()).collect(Collectors.toSet()); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Retrieve the set of values that occur in matches for Spacecraft. | ||
399 | * @return the Set of all values or empty set if there are no matches | ||
400 | * | ||
401 | */ | ||
402 | public Stream<Spacecraft> streamAllValuesOfSpacecraft() { | ||
403 | return rawStreamAllValuesOfSpacecraft(emptyArray()); | ||
404 | } | ||
405 | |||
406 | @Override | ||
407 | protected CubeSatWithKaAntenna.Match tupleToMatch(final Tuple t) { | ||
408 | try { | ||
409 | return CubeSatWithKaAntenna.Match.newMatch((Spacecraft) t.get(POSITION_SPACECRAFT)); | ||
410 | } catch(ClassCastException e) { | ||
411 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
412 | return null; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | @Override | ||
417 | protected CubeSatWithKaAntenna.Match arrayToMatch(final Object[] match) { | ||
418 | try { | ||
419 | return CubeSatWithKaAntenna.Match.newMatch((Spacecraft) match[POSITION_SPACECRAFT]); | ||
420 | } catch(ClassCastException e) { | ||
421 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
422 | return null; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | @Override | ||
427 | protected CubeSatWithKaAntenna.Match arrayToMatchMutable(final Object[] match) { | ||
428 | try { | ||
429 | return CubeSatWithKaAntenna.Match.newMutableMatch((Spacecraft) match[POSITION_SPACECRAFT]); | ||
430 | } catch(ClassCastException e) { | ||
431 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
432 | return null; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * @return the singleton instance of the query specification of this pattern | ||
438 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
439 | * | ||
440 | */ | ||
441 | public static IQuerySpecification<CubeSatWithKaAntenna.Matcher> querySpecification() { | ||
442 | return CubeSatWithKaAntenna.instance(); | ||
443 | } | ||
444 | } | ||
445 | |||
446 | private CubeSatWithKaAntenna() { | ||
447 | super(GeneratedPQuery.INSTANCE); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * @return the singleton instance of the query specification | ||
452 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
453 | * | ||
454 | */ | ||
455 | public static CubeSatWithKaAntenna instance() { | ||
456 | try{ | ||
457 | return LazyHolder.INSTANCE; | ||
458 | } catch (ExceptionInInitializerError err) { | ||
459 | throw processInitializerError(err); | ||
460 | } | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | protected CubeSatWithKaAntenna.Matcher instantiate(final ViatraQueryEngine engine) { | ||
465 | return CubeSatWithKaAntenna.Matcher.on(engine); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public CubeSatWithKaAntenna.Matcher instantiate() { | ||
470 | return CubeSatWithKaAntenna.Matcher.create(); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public CubeSatWithKaAntenna.Match newEmptyMatch() { | ||
475 | return CubeSatWithKaAntenna.Match.newEmptyMatch(); | ||
476 | } | ||
477 | |||
478 | @Override | ||
479 | public CubeSatWithKaAntenna.Match newMatch(final Object... parameters) { | ||
480 | return CubeSatWithKaAntenna.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft) parameters[0]); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna (visibility: PUBLIC, simpleName: CubeSatWithKaAntenna, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
485 | * <b>not</b> at the class load time of the outer class, | ||
486 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna (visibility: PUBLIC, simpleName: CubeSatWithKaAntenna, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
487 | * | ||
488 | * <p> This workaround is required e.g. to support recursion. | ||
489 | * | ||
490 | */ | ||
491 | private static class LazyHolder { | ||
492 | private static final CubeSatWithKaAntenna INSTANCE = new CubeSatWithKaAntenna(); | ||
493 | |||
494 | /** | ||
495 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
496 | * This initialization order is required to support indirect recursion. | ||
497 | * | ||
498 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
499 | * | ||
500 | */ | ||
501 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
502 | |||
503 | public static Object ensureInitialized() { | ||
504 | INSTANCE.ensureInitializedInternal(); | ||
505 | return null; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
510 | private static final CubeSatWithKaAntenna.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
511 | |||
512 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
513 | |||
514 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft); | ||
515 | |||
516 | private GeneratedPQuery() { | ||
517 | super(PVisibility.PUBLIC); | ||
518 | } | ||
519 | |||
520 | @Override | ||
521 | public String getFullyQualifiedName() { | ||
522 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.cubeSatWithKaAntenna"; | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public List<String> getParameterNames() { | ||
527 | return Arrays.asList("Spacecraft"); | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public List<PParameter> getParameters() { | ||
532 | return parameters; | ||
533 | } | ||
534 | |||
535 | @Override | ||
536 | public Set<PBody> doGetContainedBodies() { | ||
537 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
538 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
539 | { | ||
540 | PBody body = new PBody(this); | ||
541 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
543 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
544 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft) | ||
545 | )); | ||
546 | // CommunicatingElement.commSubsystem.band(Spacecraft, TransceiverBand::Ka) | ||
547 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
548 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "Ka").getInstance()); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
550 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
551 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
553 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
554 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
556 | new Equality(body, var__virtual_2_, var__virtual_0_); | ||
557 | // neg find smallSat(Spacecraft) | ||
558 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Spacecraft), SmallSat.instance().getInternalQueryRepresentation()); | ||
559 | bodies.add(body); | ||
560 | } | ||
561 | { | ||
562 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
563 | annotation.addAttribute("severity", "error"); | ||
564 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
565 | new ParameterReference("Spacecraft") | ||
566 | })); | ||
567 | annotation.addAttribute("message", "Only a Small Satellite can be configured with a Ka-band communication system."); | ||
568 | addAnnotation(annotation); | ||
569 | } | ||
570 | return bodies; | ||
571 | } | ||
572 | } | ||
573 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/IncompatibleSourceAndTargetBand.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/IncompatibleSourceAndTargetBand.java new file mode 100644 index 00000000..4cacc34b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/IncompatibleSourceAndTargetBand.java | |||
@@ -0,0 +1,586 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EDataType; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
45 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
46 | |||
47 | /** | ||
48 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
49 | * | ||
50 | * <p>Original source: | ||
51 | * <code><pre> | ||
52 | * // Source and target communication systems must be compatible. | ||
53 | * | ||
54 | * {@literal @}Constraint(severity = "error", key = {Link}, | ||
55 | * message = "Two ends of a communication link must use the same band.") | ||
56 | * pattern incompatibleSourceAndTargetBand(Link : DirectedCommunicationLink) { | ||
57 | * DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
58 | * DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
59 | * CommSubsystem.band(SourceSubsystem, Band); | ||
60 | * neg find commSubsystemBand(TargetSubsystem, Band); | ||
61 | * } | ||
62 | * </pre></code> | ||
63 | * | ||
64 | * @see Matcher | ||
65 | * @see Match | ||
66 | * | ||
67 | */ | ||
68 | @SuppressWarnings("all") | ||
69 | public final class IncompatibleSourceAndTargetBand extends BaseGeneratedEMFQuerySpecification<IncompatibleSourceAndTargetBand.Matcher> { | ||
70 | /** | ||
71 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetBand pattern, | ||
72 | * to be used in conjunction with {@link Matcher}. | ||
73 | * | ||
74 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
75 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
76 | * usable to represent a match of the pattern in the result of a query, | ||
77 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
78 | * | ||
79 | * @see Matcher | ||
80 | * | ||
81 | */ | ||
82 | public static abstract class Match extends BasePatternMatch { | ||
83 | private DirectedCommunicationLink fLink; | ||
84 | |||
85 | private static List<String> parameterNames = makeImmutableList("Link"); | ||
86 | |||
87 | private Match(final DirectedCommunicationLink pLink) { | ||
88 | this.fLink = pLink; | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final String parameterName) { | ||
93 | if ("Link".equals(parameterName)) return this.fLink; | ||
94 | return null; | ||
95 | } | ||
96 | |||
97 | public DirectedCommunicationLink getLink() { | ||
98 | return this.fLink; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("Link".equals(parameterName) ) { | ||
105 | this.fLink = (DirectedCommunicationLink) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setLink(final DirectedCommunicationLink pLink) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fLink = pLink; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetBand"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return IncompatibleSourceAndTargetBand.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fLink}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public IncompatibleSourceAndTargetBand.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fLink) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"Link\"=" + prettyPrintValue(fLink)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fLink); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof IncompatibleSourceAndTargetBand.Match)) { | ||
156 | IncompatibleSourceAndTargetBand.Match other = (IncompatibleSourceAndTargetBand.Match) obj; | ||
157 | return Objects.equals(fLink, other.fLink); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public IncompatibleSourceAndTargetBand specification() { | ||
170 | return IncompatibleSourceAndTargetBand.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static IncompatibleSourceAndTargetBand.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static IncompatibleSourceAndTargetBand.Match newMutableMatch(final DirectedCommunicationLink pLink) { | ||
193 | return new Mutable(pLink); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static IncompatibleSourceAndTargetBand.Match newMatch(final DirectedCommunicationLink pLink) { | ||
205 | return new Immutable(pLink); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends IncompatibleSourceAndTargetBand.Match { | ||
209 | Mutable(final DirectedCommunicationLink pLink) { | ||
210 | super(pLink); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends IncompatibleSourceAndTargetBand.Match { | ||
220 | Immutable(final DirectedCommunicationLink pLink) { | ||
221 | super(pLink); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetBand pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * // Source and target communication systems must be compatible. | ||
243 | * | ||
244 | * {@literal @}Constraint(severity = "error", key = {Link}, | ||
245 | * message = "Two ends of a communication link must use the same band.") | ||
246 | * pattern incompatibleSourceAndTargetBand(Link : DirectedCommunicationLink) { | ||
247 | * DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
248 | * DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
249 | * CommSubsystem.band(SourceSubsystem, Band); | ||
250 | * neg find commSubsystemBand(TargetSubsystem, Band); | ||
251 | * } | ||
252 | * </pre></code> | ||
253 | * | ||
254 | * @see Match | ||
255 | * @see IncompatibleSourceAndTargetBand | ||
256 | * | ||
257 | */ | ||
258 | public static class Matcher extends BaseMatcher<IncompatibleSourceAndTargetBand.Match> { | ||
259 | /** | ||
260 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
261 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
262 | * | ||
263 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
264 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
265 | * | ||
266 | */ | ||
267 | public static IncompatibleSourceAndTargetBand.Matcher on(final ViatraQueryEngine engine) { | ||
268 | // check if matcher already exists | ||
269 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
270 | if (matcher == null) { | ||
271 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
272 | } | ||
273 | return matcher; | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
278 | * @return an initialized matcher | ||
279 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
280 | * | ||
281 | */ | ||
282 | public static IncompatibleSourceAndTargetBand.Matcher create() { | ||
283 | return new Matcher(); | ||
284 | } | ||
285 | |||
286 | private static final int POSITION_LINK = 0; | ||
287 | |||
288 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IncompatibleSourceAndTargetBand.Matcher.class); | ||
289 | |||
290 | /** | ||
291 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
292 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
293 | * | ||
294 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
295 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
296 | * | ||
297 | */ | ||
298 | private Matcher() { | ||
299 | super(querySpecification()); | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
304 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
305 | * @return matches represented as a Match object. | ||
306 | * | ||
307 | */ | ||
308 | public Collection<IncompatibleSourceAndTargetBand.Match> getAllMatches(final DirectedCommunicationLink pLink) { | ||
309 | return rawStreamAllMatches(new Object[]{pLink}).collect(Collectors.toSet()); | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
314 | * </p> | ||
315 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
316 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
317 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
318 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
319 | * @return a stream of matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Stream<IncompatibleSourceAndTargetBand.Match> streamAllMatches(final DirectedCommunicationLink pLink) { | ||
323 | return rawStreamAllMatches(new Object[]{pLink}); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
328 | * Neither determinism nor randomness of selection is guaranteed. | ||
329 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
330 | * @return a match represented as a Match object, or null if no match is found. | ||
331 | * | ||
332 | */ | ||
333 | public Optional<IncompatibleSourceAndTargetBand.Match> getOneArbitraryMatch(final DirectedCommunicationLink pLink) { | ||
334 | return rawGetOneArbitraryMatch(new Object[]{pLink}); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
339 | * under any possible substitution of the unspecified parameters (if any). | ||
340 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
341 | * @return true if the input is a valid (partial) match of the pattern. | ||
342 | * | ||
343 | */ | ||
344 | public boolean hasMatch(final DirectedCommunicationLink pLink) { | ||
345 | return rawHasMatch(new Object[]{pLink}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
350 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
351 | * @return the number of pattern matches found. | ||
352 | * | ||
353 | */ | ||
354 | public int countMatches(final DirectedCommunicationLink pLink) { | ||
355 | return rawCountMatches(new Object[]{pLink}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
360 | * Neither determinism nor randomness of selection is guaranteed. | ||
361 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
362 | * @param processor the action that will process the selected match. | ||
363 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
364 | * | ||
365 | */ | ||
366 | public boolean forOneArbitraryMatch(final DirectedCommunicationLink pLink, final Consumer<? super IncompatibleSourceAndTargetBand.Match> processor) { | ||
367 | return rawForOneArbitraryMatch(new Object[]{pLink}, processor); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns a new (partial) match. | ||
372 | * This can be used e.g. to call the matcher with a partial match. | ||
373 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
374 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
375 | * @return the (partial) match object. | ||
376 | * | ||
377 | */ | ||
378 | public IncompatibleSourceAndTargetBand.Match newMatch(final DirectedCommunicationLink pLink) { | ||
379 | return IncompatibleSourceAndTargetBand.Match.newMatch(pLink); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Retrieve the set of values that occur in matches for Link. | ||
384 | * @return the Set of all values or empty set if there are no matches | ||
385 | * | ||
386 | */ | ||
387 | protected Stream<DirectedCommunicationLink> rawStreamAllValuesOfLink(final Object[] parameters) { | ||
388 | return rawStreamAllValues(POSITION_LINK, parameters).map(DirectedCommunicationLink.class::cast); | ||
389 | } | ||
390 | |||
391 | /** | ||
392 | * Retrieve the set of values that occur in matches for Link. | ||
393 | * @return the Set of all values or empty set if there are no matches | ||
394 | * | ||
395 | */ | ||
396 | public Set<DirectedCommunicationLink> getAllValuesOfLink() { | ||
397 | return rawStreamAllValuesOfLink(emptyArray()).collect(Collectors.toSet()); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Retrieve the set of values that occur in matches for Link. | ||
402 | * @return the Set of all values or empty set if there are no matches | ||
403 | * | ||
404 | */ | ||
405 | public Stream<DirectedCommunicationLink> streamAllValuesOfLink() { | ||
406 | return rawStreamAllValuesOfLink(emptyArray()); | ||
407 | } | ||
408 | |||
409 | @Override | ||
410 | protected IncompatibleSourceAndTargetBand.Match tupleToMatch(final Tuple t) { | ||
411 | try { | ||
412 | return IncompatibleSourceAndTargetBand.Match.newMatch((DirectedCommunicationLink) t.get(POSITION_LINK)); | ||
413 | } catch(ClassCastException e) { | ||
414 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
415 | return null; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | @Override | ||
420 | protected IncompatibleSourceAndTargetBand.Match arrayToMatch(final Object[] match) { | ||
421 | try { | ||
422 | return IncompatibleSourceAndTargetBand.Match.newMatch((DirectedCommunicationLink) match[POSITION_LINK]); | ||
423 | } catch(ClassCastException e) { | ||
424 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
425 | return null; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | @Override | ||
430 | protected IncompatibleSourceAndTargetBand.Match arrayToMatchMutable(final Object[] match) { | ||
431 | try { | ||
432 | return IncompatibleSourceAndTargetBand.Match.newMutableMatch((DirectedCommunicationLink) match[POSITION_LINK]); | ||
433 | } catch(ClassCastException e) { | ||
434 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
435 | return null; | ||
436 | } | ||
437 | } | ||
438 | |||
439 | /** | ||
440 | * @return the singleton instance of the query specification of this pattern | ||
441 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
442 | * | ||
443 | */ | ||
444 | public static IQuerySpecification<IncompatibleSourceAndTargetBand.Matcher> querySpecification() { | ||
445 | return IncompatibleSourceAndTargetBand.instance(); | ||
446 | } | ||
447 | } | ||
448 | |||
449 | private IncompatibleSourceAndTargetBand() { | ||
450 | super(GeneratedPQuery.INSTANCE); | ||
451 | } | ||
452 | |||
453 | /** | ||
454 | * @return the singleton instance of the query specification | ||
455 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
456 | * | ||
457 | */ | ||
458 | public static IncompatibleSourceAndTargetBand instance() { | ||
459 | try{ | ||
460 | return LazyHolder.INSTANCE; | ||
461 | } catch (ExceptionInInitializerError err) { | ||
462 | throw processInitializerError(err); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | protected IncompatibleSourceAndTargetBand.Matcher instantiate(final ViatraQueryEngine engine) { | ||
468 | return IncompatibleSourceAndTargetBand.Matcher.on(engine); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public IncompatibleSourceAndTargetBand.Matcher instantiate() { | ||
473 | return IncompatibleSourceAndTargetBand.Matcher.create(); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public IncompatibleSourceAndTargetBand.Match newEmptyMatch() { | ||
478 | return IncompatibleSourceAndTargetBand.Match.newEmptyMatch(); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public IncompatibleSourceAndTargetBand.Match newMatch(final Object... parameters) { | ||
483 | return IncompatibleSourceAndTargetBand.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink) parameters[0]); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand (visibility: PUBLIC, simpleName: IncompatibleSourceAndTargetBand, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
488 | * <b>not</b> at the class load time of the outer class, | ||
489 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand (visibility: PUBLIC, simpleName: IncompatibleSourceAndTargetBand, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
490 | * | ||
491 | * <p> This workaround is required e.g. to support recursion. | ||
492 | * | ||
493 | */ | ||
494 | private static class LazyHolder { | ||
495 | private static final IncompatibleSourceAndTargetBand INSTANCE = new IncompatibleSourceAndTargetBand(); | ||
496 | |||
497 | /** | ||
498 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
499 | * This initialization order is required to support indirect recursion. | ||
500 | * | ||
501 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
502 | * | ||
503 | */ | ||
504 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
505 | |||
506 | public static Object ensureInitialized() { | ||
507 | INSTANCE.ensureInitializedInternal(); | ||
508 | return null; | ||
509 | } | ||
510 | } | ||
511 | |||
512 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
513 | private static final IncompatibleSourceAndTargetBand.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
514 | |||
515 | private final PParameter parameter_Link = new PParameter("Link", "hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "DirectedCommunicationLink")), PParameterDirection.INOUT); | ||
516 | |||
517 | private final List<PParameter> parameters = Arrays.asList(parameter_Link); | ||
518 | |||
519 | private GeneratedPQuery() { | ||
520 | super(PVisibility.PUBLIC); | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public String getFullyQualifiedName() { | ||
525 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetBand"; | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public List<String> getParameterNames() { | ||
530 | return Arrays.asList("Link"); | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public List<PParameter> getParameters() { | ||
535 | return parameters; | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public Set<PBody> doGetContainedBodies() { | ||
540 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
541 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
542 | { | ||
543 | PBody body = new PBody(this); | ||
544 | PVariable var_Link = body.getOrCreateVariableByName("Link"); | ||
545 | PVariable var_SourceSubsystem = body.getOrCreateVariableByName("SourceSubsystem"); | ||
546 | PVariable var_TargetSubsystem = body.getOrCreateVariableByName("TargetSubsystem"); | ||
547 | PVariable var_Band = body.getOrCreateVariableByName("Band"); | ||
548 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
549 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
550 | new ExportedParameter(body, var_Link, parameter_Link) | ||
551 | )); | ||
552 | // DirectedCommunicationLink.source(Link, SourceSubsystem) | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
554 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
557 | new Equality(body, var__virtual_0_, var_SourceSubsystem); | ||
558 | // DirectedCommunicationLink.target(Link, TargetSubsystem) | ||
559 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
560 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
561 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); | ||
562 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
563 | new Equality(body, var__virtual_1_, var_TargetSubsystem); | ||
564 | // CommSubsystem.band(SourceSubsystem, Band) | ||
565 | new TypeConstraint(body, Tuples.flatTupleOf(var_SourceSubsystem), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
566 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
567 | new TypeConstraint(body, Tuples.flatTupleOf(var_SourceSubsystem, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
568 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
569 | new Equality(body, var__virtual_2_, var_Band); | ||
570 | // neg find commSubsystemBand(TargetSubsystem, Band) | ||
571 | new NegativePatternCall(body, Tuples.flatTupleOf(var_TargetSubsystem, var_Band), CommSubsystemBand.instance().getInternalQueryRepresentation()); | ||
572 | bodies.add(body); | ||
573 | } | ||
574 | { | ||
575 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
576 | annotation.addAttribute("severity", "error"); | ||
577 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
578 | new ParameterReference("Link") | ||
579 | })); | ||
580 | annotation.addAttribute("message", "Two ends of a communication link must use the same band."); | ||
581 | addAnnotation(annotation); | ||
582 | } | ||
583 | return bodies; | ||
584 | } | ||
585 | } | ||
586 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/IncompatibleSourceAndTargetGain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/IncompatibleSourceAndTargetGain.java new file mode 100644 index 00000000..3f247613 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/IncompatibleSourceAndTargetGain.java | |||
@@ -0,0 +1,582 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EDataType; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
45 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
46 | |||
47 | /** | ||
48 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
49 | * | ||
50 | * <p>Original source: | ||
51 | * <code><pre> | ||
52 | * {@literal @}Constraint(severity = "error", key = {Link}, | ||
53 | * message = "Two ends of a communication link must use the same antenna gain.") | ||
54 | * pattern incompatibleSourceAndTargetGain(Link : DirectedCommunicationLink) { | ||
55 | * DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
56 | * DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
57 | * CommSubsystem.gain(SourceSubsystem, Gain); | ||
58 | * neg find commSubsystemGain(TargetSubsystem, Gain); | ||
59 | * } | ||
60 | * </pre></code> | ||
61 | * | ||
62 | * @see Matcher | ||
63 | * @see Match | ||
64 | * | ||
65 | */ | ||
66 | @SuppressWarnings("all") | ||
67 | public final class IncompatibleSourceAndTargetGain extends BaseGeneratedEMFQuerySpecification<IncompatibleSourceAndTargetGain.Matcher> { | ||
68 | /** | ||
69 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetGain pattern, | ||
70 | * to be used in conjunction with {@link Matcher}. | ||
71 | * | ||
72 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
73 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
74 | * usable to represent a match of the pattern in the result of a query, | ||
75 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
76 | * | ||
77 | * @see Matcher | ||
78 | * | ||
79 | */ | ||
80 | public static abstract class Match extends BasePatternMatch { | ||
81 | private DirectedCommunicationLink fLink; | ||
82 | |||
83 | private static List<String> parameterNames = makeImmutableList("Link"); | ||
84 | |||
85 | private Match(final DirectedCommunicationLink pLink) { | ||
86 | this.fLink = pLink; | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final String parameterName) { | ||
91 | if ("Link".equals(parameterName)) return this.fLink; | ||
92 | return null; | ||
93 | } | ||
94 | |||
95 | public DirectedCommunicationLink getLink() { | ||
96 | return this.fLink; | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public boolean set(final String parameterName, final Object newValue) { | ||
101 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
102 | if ("Link".equals(parameterName) ) { | ||
103 | this.fLink = (DirectedCommunicationLink) newValue; | ||
104 | return true; | ||
105 | } | ||
106 | return false; | ||
107 | } | ||
108 | |||
109 | public void setLink(final DirectedCommunicationLink pLink) { | ||
110 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
111 | this.fLink = pLink; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public String patternName() { | ||
116 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetGain"; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public List<String> parameterNames() { | ||
121 | return IncompatibleSourceAndTargetGain.Match.parameterNames; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public Object[] toArray() { | ||
126 | return new Object[]{fLink}; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public IncompatibleSourceAndTargetGain.Match toImmutable() { | ||
131 | return isMutable() ? newMatch(fLink) : this; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String prettyPrint() { | ||
136 | StringBuilder result = new StringBuilder(); | ||
137 | result.append("\"Link\"=" + prettyPrintValue(fLink)); | ||
138 | return result.toString(); | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public int hashCode() { | ||
143 | return Objects.hash(fLink); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public boolean equals(final Object obj) { | ||
148 | if (this == obj) | ||
149 | return true; | ||
150 | if (obj == null) { | ||
151 | return false; | ||
152 | } | ||
153 | if ((obj instanceof IncompatibleSourceAndTargetGain.Match)) { | ||
154 | IncompatibleSourceAndTargetGain.Match other = (IncompatibleSourceAndTargetGain.Match) obj; | ||
155 | return Objects.equals(fLink, other.fLink); | ||
156 | } else { | ||
157 | // this should be infrequent | ||
158 | if (!(obj instanceof IPatternMatch)) { | ||
159 | return false; | ||
160 | } | ||
161 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
162 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | @Override | ||
167 | public IncompatibleSourceAndTargetGain specification() { | ||
168 | return IncompatibleSourceAndTargetGain.instance(); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * Returns an empty, mutable match. | ||
173 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
174 | * | ||
175 | * @return the empty match. | ||
176 | * | ||
177 | */ | ||
178 | public static IncompatibleSourceAndTargetGain.Match newEmptyMatch() { | ||
179 | return new Mutable(null); | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * Returns a mutable (partial) match. | ||
184 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
185 | * | ||
186 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
187 | * @return the new, mutable (partial) match object. | ||
188 | * | ||
189 | */ | ||
190 | public static IncompatibleSourceAndTargetGain.Match newMutableMatch(final DirectedCommunicationLink pLink) { | ||
191 | return new Mutable(pLink); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * Returns a new (partial) match. | ||
196 | * This can be used e.g. to call the matcher with a partial match. | ||
197 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
198 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
199 | * @return the (partial) match object. | ||
200 | * | ||
201 | */ | ||
202 | public static IncompatibleSourceAndTargetGain.Match newMatch(final DirectedCommunicationLink pLink) { | ||
203 | return new Immutable(pLink); | ||
204 | } | ||
205 | |||
206 | private static final class Mutable extends IncompatibleSourceAndTargetGain.Match { | ||
207 | Mutable(final DirectedCommunicationLink pLink) { | ||
208 | super(pLink); | ||
209 | } | ||
210 | |||
211 | @Override | ||
212 | public boolean isMutable() { | ||
213 | return true; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | private static final class Immutable extends IncompatibleSourceAndTargetGain.Match { | ||
218 | Immutable(final DirectedCommunicationLink pLink) { | ||
219 | super(pLink); | ||
220 | } | ||
221 | |||
222 | @Override | ||
223 | public boolean isMutable() { | ||
224 | return false; | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetGain pattern, | ||
231 | * providing pattern-specific query methods. | ||
232 | * | ||
233 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
234 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
235 | * | ||
236 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
237 | * | ||
238 | * <p>Original source: | ||
239 | * <code><pre> | ||
240 | * {@literal @}Constraint(severity = "error", key = {Link}, | ||
241 | * message = "Two ends of a communication link must use the same antenna gain.") | ||
242 | * pattern incompatibleSourceAndTargetGain(Link : DirectedCommunicationLink) { | ||
243 | * DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
244 | * DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
245 | * CommSubsystem.gain(SourceSubsystem, Gain); | ||
246 | * neg find commSubsystemGain(TargetSubsystem, Gain); | ||
247 | * } | ||
248 | * </pre></code> | ||
249 | * | ||
250 | * @see Match | ||
251 | * @see IncompatibleSourceAndTargetGain | ||
252 | * | ||
253 | */ | ||
254 | public static class Matcher extends BaseMatcher<IncompatibleSourceAndTargetGain.Match> { | ||
255 | /** | ||
256 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
257 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
258 | * | ||
259 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
260 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
261 | * | ||
262 | */ | ||
263 | public static IncompatibleSourceAndTargetGain.Matcher on(final ViatraQueryEngine engine) { | ||
264 | // check if matcher already exists | ||
265 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
266 | if (matcher == null) { | ||
267 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
268 | } | ||
269 | return matcher; | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
274 | * @return an initialized matcher | ||
275 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
276 | * | ||
277 | */ | ||
278 | public static IncompatibleSourceAndTargetGain.Matcher create() { | ||
279 | return new Matcher(); | ||
280 | } | ||
281 | |||
282 | private static final int POSITION_LINK = 0; | ||
283 | |||
284 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IncompatibleSourceAndTargetGain.Matcher.class); | ||
285 | |||
286 | /** | ||
287 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
288 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
289 | * | ||
290 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
291 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
292 | * | ||
293 | */ | ||
294 | private Matcher() { | ||
295 | super(querySpecification()); | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
300 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
301 | * @return matches represented as a Match object. | ||
302 | * | ||
303 | */ | ||
304 | public Collection<IncompatibleSourceAndTargetGain.Match> getAllMatches(final DirectedCommunicationLink pLink) { | ||
305 | return rawStreamAllMatches(new Object[]{pLink}).collect(Collectors.toSet()); | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
310 | * </p> | ||
311 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
312 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
313 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
314 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
315 | * @return a stream of matches represented as a Match object. | ||
316 | * | ||
317 | */ | ||
318 | public Stream<IncompatibleSourceAndTargetGain.Match> streamAllMatches(final DirectedCommunicationLink pLink) { | ||
319 | return rawStreamAllMatches(new Object[]{pLink}); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
324 | * Neither determinism nor randomness of selection is guaranteed. | ||
325 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
326 | * @return a match represented as a Match object, or null if no match is found. | ||
327 | * | ||
328 | */ | ||
329 | public Optional<IncompatibleSourceAndTargetGain.Match> getOneArbitraryMatch(final DirectedCommunicationLink pLink) { | ||
330 | return rawGetOneArbitraryMatch(new Object[]{pLink}); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
335 | * under any possible substitution of the unspecified parameters (if any). | ||
336 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
337 | * @return true if the input is a valid (partial) match of the pattern. | ||
338 | * | ||
339 | */ | ||
340 | public boolean hasMatch(final DirectedCommunicationLink pLink) { | ||
341 | return rawHasMatch(new Object[]{pLink}); | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
346 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
347 | * @return the number of pattern matches found. | ||
348 | * | ||
349 | */ | ||
350 | public int countMatches(final DirectedCommunicationLink pLink) { | ||
351 | return rawCountMatches(new Object[]{pLink}); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
356 | * Neither determinism nor randomness of selection is guaranteed. | ||
357 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
358 | * @param processor the action that will process the selected match. | ||
359 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
360 | * | ||
361 | */ | ||
362 | public boolean forOneArbitraryMatch(final DirectedCommunicationLink pLink, final Consumer<? super IncompatibleSourceAndTargetGain.Match> processor) { | ||
363 | return rawForOneArbitraryMatch(new Object[]{pLink}, processor); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Returns a new (partial) match. | ||
368 | * This can be used e.g. to call the matcher with a partial match. | ||
369 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
370 | * @param pLink the fixed value of pattern parameter Link, or null if not bound. | ||
371 | * @return the (partial) match object. | ||
372 | * | ||
373 | */ | ||
374 | public IncompatibleSourceAndTargetGain.Match newMatch(final DirectedCommunicationLink pLink) { | ||
375 | return IncompatibleSourceAndTargetGain.Match.newMatch(pLink); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Retrieve the set of values that occur in matches for Link. | ||
380 | * @return the Set of all values or empty set if there are no matches | ||
381 | * | ||
382 | */ | ||
383 | protected Stream<DirectedCommunicationLink> rawStreamAllValuesOfLink(final Object[] parameters) { | ||
384 | return rawStreamAllValues(POSITION_LINK, parameters).map(DirectedCommunicationLink.class::cast); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for Link. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | public Set<DirectedCommunicationLink> getAllValuesOfLink() { | ||
393 | return rawStreamAllValuesOfLink(emptyArray()).collect(Collectors.toSet()); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for Link. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Stream<DirectedCommunicationLink> streamAllValuesOfLink() { | ||
402 | return rawStreamAllValuesOfLink(emptyArray()); | ||
403 | } | ||
404 | |||
405 | @Override | ||
406 | protected IncompatibleSourceAndTargetGain.Match tupleToMatch(final Tuple t) { | ||
407 | try { | ||
408 | return IncompatibleSourceAndTargetGain.Match.newMatch((DirectedCommunicationLink) t.get(POSITION_LINK)); | ||
409 | } catch(ClassCastException e) { | ||
410 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
411 | return null; | ||
412 | } | ||
413 | } | ||
414 | |||
415 | @Override | ||
416 | protected IncompatibleSourceAndTargetGain.Match arrayToMatch(final Object[] match) { | ||
417 | try { | ||
418 | return IncompatibleSourceAndTargetGain.Match.newMatch((DirectedCommunicationLink) match[POSITION_LINK]); | ||
419 | } catch(ClassCastException e) { | ||
420 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
421 | return null; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | @Override | ||
426 | protected IncompatibleSourceAndTargetGain.Match arrayToMatchMutable(final Object[] match) { | ||
427 | try { | ||
428 | return IncompatibleSourceAndTargetGain.Match.newMutableMatch((DirectedCommunicationLink) match[POSITION_LINK]); | ||
429 | } catch(ClassCastException e) { | ||
430 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
431 | return null; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * @return the singleton instance of the query specification of this pattern | ||
437 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
438 | * | ||
439 | */ | ||
440 | public static IQuerySpecification<IncompatibleSourceAndTargetGain.Matcher> querySpecification() { | ||
441 | return IncompatibleSourceAndTargetGain.instance(); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | private IncompatibleSourceAndTargetGain() { | ||
446 | super(GeneratedPQuery.INSTANCE); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * @return the singleton instance of the query specification | ||
451 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
452 | * | ||
453 | */ | ||
454 | public static IncompatibleSourceAndTargetGain instance() { | ||
455 | try{ | ||
456 | return LazyHolder.INSTANCE; | ||
457 | } catch (ExceptionInInitializerError err) { | ||
458 | throw processInitializerError(err); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | @Override | ||
463 | protected IncompatibleSourceAndTargetGain.Matcher instantiate(final ViatraQueryEngine engine) { | ||
464 | return IncompatibleSourceAndTargetGain.Matcher.on(engine); | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | public IncompatibleSourceAndTargetGain.Matcher instantiate() { | ||
469 | return IncompatibleSourceAndTargetGain.Matcher.create(); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public IncompatibleSourceAndTargetGain.Match newEmptyMatch() { | ||
474 | return IncompatibleSourceAndTargetGain.Match.newEmptyMatch(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public IncompatibleSourceAndTargetGain.Match newMatch(final Object... parameters) { | ||
479 | return IncompatibleSourceAndTargetGain.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink) parameters[0]); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain (visibility: PUBLIC, simpleName: IncompatibleSourceAndTargetGain, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
484 | * <b>not</b> at the class load time of the outer class, | ||
485 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain (visibility: PUBLIC, simpleName: IncompatibleSourceAndTargetGain, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
486 | * | ||
487 | * <p> This workaround is required e.g. to support recursion. | ||
488 | * | ||
489 | */ | ||
490 | private static class LazyHolder { | ||
491 | private static final IncompatibleSourceAndTargetGain INSTANCE = new IncompatibleSourceAndTargetGain(); | ||
492 | |||
493 | /** | ||
494 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
495 | * This initialization order is required to support indirect recursion. | ||
496 | * | ||
497 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
498 | * | ||
499 | */ | ||
500 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
501 | |||
502 | public static Object ensureInitialized() { | ||
503 | INSTANCE.ensureInitializedInternal(); | ||
504 | return null; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
509 | private static final IncompatibleSourceAndTargetGain.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
510 | |||
511 | private final PParameter parameter_Link = new PParameter("Link", "hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "DirectedCommunicationLink")), PParameterDirection.INOUT); | ||
512 | |||
513 | private final List<PParameter> parameters = Arrays.asList(parameter_Link); | ||
514 | |||
515 | private GeneratedPQuery() { | ||
516 | super(PVisibility.PUBLIC); | ||
517 | } | ||
518 | |||
519 | @Override | ||
520 | public String getFullyQualifiedName() { | ||
521 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incompatibleSourceAndTargetGain"; | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public List<String> getParameterNames() { | ||
526 | return Arrays.asList("Link"); | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<PParameter> getParameters() { | ||
531 | return parameters; | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public Set<PBody> doGetContainedBodies() { | ||
536 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
537 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
538 | { | ||
539 | PBody body = new PBody(this); | ||
540 | PVariable var_Link = body.getOrCreateVariableByName("Link"); | ||
541 | PVariable var_SourceSubsystem = body.getOrCreateVariableByName("SourceSubsystem"); | ||
542 | PVariable var_TargetSubsystem = body.getOrCreateVariableByName("TargetSubsystem"); | ||
543 | PVariable var_Gain = body.getOrCreateVariableByName("Gain"); | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
545 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
546 | new ExportedParameter(body, var_Link, parameter_Link) | ||
547 | )); | ||
548 | // DirectedCommunicationLink.source(Link, SourceSubsystem) | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
550 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
551 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
553 | new Equality(body, var__virtual_0_, var_SourceSubsystem); | ||
554 | // DirectedCommunicationLink.target(Link, TargetSubsystem) | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
556 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
557 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
559 | new Equality(body, var__virtual_1_, var_TargetSubsystem); | ||
560 | // CommSubsystem.gain(SourceSubsystem, Gain) | ||
561 | new TypeConstraint(body, Tuples.flatTupleOf(var_SourceSubsystem), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
562 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
563 | new TypeConstraint(body, Tuples.flatTupleOf(var_SourceSubsystem, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "gain"))); | ||
564 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "AntennaGain"))); | ||
565 | new Equality(body, var__virtual_2_, var_Gain); | ||
566 | // neg find commSubsystemGain(TargetSubsystem, Gain) | ||
567 | new NegativePatternCall(body, Tuples.flatTupleOf(var_TargetSubsystem, var_Gain), CommSubsystemGain.instance().getInternalQueryRepresentation()); | ||
568 | bodies.add(body); | ||
569 | } | ||
570 | { | ||
571 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
572 | annotation.addAttribute("severity", "error"); | ||
573 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
574 | new ParameterReference("Link") | ||
575 | })); | ||
576 | annotation.addAttribute("message", "Two ends of a communication link must use the same antenna gain."); | ||
577 | addAnnotation(annotation); | ||
578 | } | ||
579 | return bodies; | ||
580 | } | ||
581 | } | ||
582 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/KaAntennaGainLow.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/KaAntennaGainLow.java new file mode 100644 index 00000000..18f6c32f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/KaAntennaGainLow.java | |||
@@ -0,0 +1,574 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.emf.ecore.EDataType; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * // Ka-band transmitters may only be combined with a medium or high gain antenna | ||
52 | * | ||
53 | * {@literal @}Constraint(severity = "error", key = {Comm}, | ||
54 | * message = "Ka-band transceiver must be combined with a medium or high gain antenna.") | ||
55 | * pattern kaAntennaGainLow(Comm : CommSubsystem) { | ||
56 | * CommSubsystem.band(Comm, TransceiverBand::Ka); | ||
57 | * CommSubsystem.gain(Comm, AntennaGain::LOW); | ||
58 | * } | ||
59 | * </pre></code> | ||
60 | * | ||
61 | * @see Matcher | ||
62 | * @see Match | ||
63 | * | ||
64 | */ | ||
65 | @SuppressWarnings("all") | ||
66 | public final class KaAntennaGainLow extends BaseGeneratedEMFQuerySpecification<KaAntennaGainLow.Matcher> { | ||
67 | /** | ||
68 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.kaAntennaGainLow pattern, | ||
69 | * to be used in conjunction with {@link Matcher}. | ||
70 | * | ||
71 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
72 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
73 | * usable to represent a match of the pattern in the result of a query, | ||
74 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
75 | * | ||
76 | * @see Matcher | ||
77 | * | ||
78 | */ | ||
79 | public static abstract class Match extends BasePatternMatch { | ||
80 | private CommSubsystem fComm; | ||
81 | |||
82 | private static List<String> parameterNames = makeImmutableList("Comm"); | ||
83 | |||
84 | private Match(final CommSubsystem pComm) { | ||
85 | this.fComm = pComm; | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final String parameterName) { | ||
90 | if ("Comm".equals(parameterName)) return this.fComm; | ||
91 | return null; | ||
92 | } | ||
93 | |||
94 | public CommSubsystem getComm() { | ||
95 | return this.fComm; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public boolean set(final String parameterName, final Object newValue) { | ||
100 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
101 | if ("Comm".equals(parameterName) ) { | ||
102 | this.fComm = (CommSubsystem) newValue; | ||
103 | return true; | ||
104 | } | ||
105 | return false; | ||
106 | } | ||
107 | |||
108 | public void setComm(final CommSubsystem pComm) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | this.fComm = pComm; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public String patternName() { | ||
115 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.kaAntennaGainLow"; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public List<String> parameterNames() { | ||
120 | return KaAntennaGainLow.Match.parameterNames; | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public Object[] toArray() { | ||
125 | return new Object[]{fComm}; | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public KaAntennaGainLow.Match toImmutable() { | ||
130 | return isMutable() ? newMatch(fComm) : this; | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public String prettyPrint() { | ||
135 | StringBuilder result = new StringBuilder(); | ||
136 | result.append("\"Comm\"=" + prettyPrintValue(fComm)); | ||
137 | return result.toString(); | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public int hashCode() { | ||
142 | return Objects.hash(fComm); | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public boolean equals(final Object obj) { | ||
147 | if (this == obj) | ||
148 | return true; | ||
149 | if (obj == null) { | ||
150 | return false; | ||
151 | } | ||
152 | if ((obj instanceof KaAntennaGainLow.Match)) { | ||
153 | KaAntennaGainLow.Match other = (KaAntennaGainLow.Match) obj; | ||
154 | return Objects.equals(fComm, other.fComm); | ||
155 | } else { | ||
156 | // this should be infrequent | ||
157 | if (!(obj instanceof IPatternMatch)) { | ||
158 | return false; | ||
159 | } | ||
160 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
161 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public KaAntennaGainLow specification() { | ||
167 | return KaAntennaGainLow.instance(); | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * Returns an empty, mutable match. | ||
172 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
173 | * | ||
174 | * @return the empty match. | ||
175 | * | ||
176 | */ | ||
177 | public static KaAntennaGainLow.Match newEmptyMatch() { | ||
178 | return new Mutable(null); | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * Returns a mutable (partial) match. | ||
183 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
184 | * | ||
185 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
186 | * @return the new, mutable (partial) match object. | ||
187 | * | ||
188 | */ | ||
189 | public static KaAntennaGainLow.Match newMutableMatch(final CommSubsystem pComm) { | ||
190 | return new Mutable(pComm); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns a new (partial) match. | ||
195 | * This can be used e.g. to call the matcher with a partial match. | ||
196 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
197 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
198 | * @return the (partial) match object. | ||
199 | * | ||
200 | */ | ||
201 | public static KaAntennaGainLow.Match newMatch(final CommSubsystem pComm) { | ||
202 | return new Immutable(pComm); | ||
203 | } | ||
204 | |||
205 | private static final class Mutable extends KaAntennaGainLow.Match { | ||
206 | Mutable(final CommSubsystem pComm) { | ||
207 | super(pComm); | ||
208 | } | ||
209 | |||
210 | @Override | ||
211 | public boolean isMutable() { | ||
212 | return true; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | private static final class Immutable extends KaAntennaGainLow.Match { | ||
217 | Immutable(final CommSubsystem pComm) { | ||
218 | super(pComm); | ||
219 | } | ||
220 | |||
221 | @Override | ||
222 | public boolean isMutable() { | ||
223 | return false; | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | |||
228 | /** | ||
229 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.kaAntennaGainLow pattern, | ||
230 | * providing pattern-specific query methods. | ||
231 | * | ||
232 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
233 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
234 | * | ||
235 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
236 | * | ||
237 | * <p>Original source: | ||
238 | * <code><pre> | ||
239 | * // Ka-band transmitters may only be combined with a medium or high gain antenna | ||
240 | * | ||
241 | * {@literal @}Constraint(severity = "error", key = {Comm}, | ||
242 | * message = "Ka-band transceiver must be combined with a medium or high gain antenna.") | ||
243 | * pattern kaAntennaGainLow(Comm : CommSubsystem) { | ||
244 | * CommSubsystem.band(Comm, TransceiverBand::Ka); | ||
245 | * CommSubsystem.gain(Comm, AntennaGain::LOW); | ||
246 | * } | ||
247 | * </pre></code> | ||
248 | * | ||
249 | * @see Match | ||
250 | * @see KaAntennaGainLow | ||
251 | * | ||
252 | */ | ||
253 | public static class Matcher extends BaseMatcher<KaAntennaGainLow.Match> { | ||
254 | /** | ||
255 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
256 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
257 | * | ||
258 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
259 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
260 | * | ||
261 | */ | ||
262 | public static KaAntennaGainLow.Matcher on(final ViatraQueryEngine engine) { | ||
263 | // check if matcher already exists | ||
264 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
265 | if (matcher == null) { | ||
266 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
267 | } | ||
268 | return matcher; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * @return an initialized matcher | ||
274 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
275 | * | ||
276 | */ | ||
277 | public static KaAntennaGainLow.Matcher create() { | ||
278 | return new Matcher(); | ||
279 | } | ||
280 | |||
281 | private static final int POSITION_COMM = 0; | ||
282 | |||
283 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(KaAntennaGainLow.Matcher.class); | ||
284 | |||
285 | /** | ||
286 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
287 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
288 | * | ||
289 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * | ||
292 | */ | ||
293 | private Matcher() { | ||
294 | super(querySpecification()); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
299 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
300 | * @return matches represented as a Match object. | ||
301 | * | ||
302 | */ | ||
303 | public Collection<KaAntennaGainLow.Match> getAllMatches(final CommSubsystem pComm) { | ||
304 | return rawStreamAllMatches(new Object[]{pComm}).collect(Collectors.toSet()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
309 | * </p> | ||
310 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
311 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
312 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
313 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
314 | * @return a stream of matches represented as a Match object. | ||
315 | * | ||
316 | */ | ||
317 | public Stream<KaAntennaGainLow.Match> streamAllMatches(final CommSubsystem pComm) { | ||
318 | return rawStreamAllMatches(new Object[]{pComm}); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
323 | * Neither determinism nor randomness of selection is guaranteed. | ||
324 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
325 | * @return a match represented as a Match object, or null if no match is found. | ||
326 | * | ||
327 | */ | ||
328 | public Optional<KaAntennaGainLow.Match> getOneArbitraryMatch(final CommSubsystem pComm) { | ||
329 | return rawGetOneArbitraryMatch(new Object[]{pComm}); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
334 | * under any possible substitution of the unspecified parameters (if any). | ||
335 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
336 | * @return true if the input is a valid (partial) match of the pattern. | ||
337 | * | ||
338 | */ | ||
339 | public boolean hasMatch(final CommSubsystem pComm) { | ||
340 | return rawHasMatch(new Object[]{pComm}); | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
345 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
346 | * @return the number of pattern matches found. | ||
347 | * | ||
348 | */ | ||
349 | public int countMatches(final CommSubsystem pComm) { | ||
350 | return rawCountMatches(new Object[]{pComm}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
355 | * Neither determinism nor randomness of selection is guaranteed. | ||
356 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
357 | * @param processor the action that will process the selected match. | ||
358 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
359 | * | ||
360 | */ | ||
361 | public boolean forOneArbitraryMatch(final CommSubsystem pComm, final Consumer<? super KaAntennaGainLow.Match> processor) { | ||
362 | return rawForOneArbitraryMatch(new Object[]{pComm}, processor); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns a new (partial) match. | ||
367 | * This can be used e.g. to call the matcher with a partial match. | ||
368 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
369 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
370 | * @return the (partial) match object. | ||
371 | * | ||
372 | */ | ||
373 | public KaAntennaGainLow.Match newMatch(final CommSubsystem pComm) { | ||
374 | return KaAntennaGainLow.Match.newMatch(pComm); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Retrieve the set of values that occur in matches for Comm. | ||
379 | * @return the Set of all values or empty set if there are no matches | ||
380 | * | ||
381 | */ | ||
382 | protected Stream<CommSubsystem> rawStreamAllValuesOfComm(final Object[] parameters) { | ||
383 | return rawStreamAllValues(POSITION_COMM, parameters).map(CommSubsystem.class::cast); | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * Retrieve the set of values that occur in matches for Comm. | ||
388 | * @return the Set of all values or empty set if there are no matches | ||
389 | * | ||
390 | */ | ||
391 | public Set<CommSubsystem> getAllValuesOfComm() { | ||
392 | return rawStreamAllValuesOfComm(emptyArray()).collect(Collectors.toSet()); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Retrieve the set of values that occur in matches for Comm. | ||
397 | * @return the Set of all values or empty set if there are no matches | ||
398 | * | ||
399 | */ | ||
400 | public Stream<CommSubsystem> streamAllValuesOfComm() { | ||
401 | return rawStreamAllValuesOfComm(emptyArray()); | ||
402 | } | ||
403 | |||
404 | @Override | ||
405 | protected KaAntennaGainLow.Match tupleToMatch(final Tuple t) { | ||
406 | try { | ||
407 | return KaAntennaGainLow.Match.newMatch((CommSubsystem) t.get(POSITION_COMM)); | ||
408 | } catch(ClassCastException e) { | ||
409 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
410 | return null; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | @Override | ||
415 | protected KaAntennaGainLow.Match arrayToMatch(final Object[] match) { | ||
416 | try { | ||
417 | return KaAntennaGainLow.Match.newMatch((CommSubsystem) match[POSITION_COMM]); | ||
418 | } catch(ClassCastException e) { | ||
419 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
420 | return null; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | @Override | ||
425 | protected KaAntennaGainLow.Match arrayToMatchMutable(final Object[] match) { | ||
426 | try { | ||
427 | return KaAntennaGainLow.Match.newMutableMatch((CommSubsystem) match[POSITION_COMM]); | ||
428 | } catch(ClassCastException e) { | ||
429 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
430 | return null; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * @return the singleton instance of the query specification of this pattern | ||
436 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
437 | * | ||
438 | */ | ||
439 | public static IQuerySpecification<KaAntennaGainLow.Matcher> querySpecification() { | ||
440 | return KaAntennaGainLow.instance(); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | private KaAntennaGainLow() { | ||
445 | super(GeneratedPQuery.INSTANCE); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * @return the singleton instance of the query specification | ||
450 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
451 | * | ||
452 | */ | ||
453 | public static KaAntennaGainLow instance() { | ||
454 | try{ | ||
455 | return LazyHolder.INSTANCE; | ||
456 | } catch (ExceptionInInitializerError err) { | ||
457 | throw processInitializerError(err); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | @Override | ||
462 | protected KaAntennaGainLow.Matcher instantiate(final ViatraQueryEngine engine) { | ||
463 | return KaAntennaGainLow.Matcher.on(engine); | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | public KaAntennaGainLow.Matcher instantiate() { | ||
468 | return KaAntennaGainLow.Matcher.create(); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public KaAntennaGainLow.Match newEmptyMatch() { | ||
473 | return KaAntennaGainLow.Match.newEmptyMatch(); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public KaAntennaGainLow.Match newMatch(final Object... parameters) { | ||
478 | return KaAntennaGainLow.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem) parameters[0]); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow (visibility: PUBLIC, simpleName: KaAntennaGainLow, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
483 | * <b>not</b> at the class load time of the outer class, | ||
484 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow (visibility: PUBLIC, simpleName: KaAntennaGainLow, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
485 | * | ||
486 | * <p> This workaround is required e.g. to support recursion. | ||
487 | * | ||
488 | */ | ||
489 | private static class LazyHolder { | ||
490 | private static final KaAntennaGainLow INSTANCE = new KaAntennaGainLow(); | ||
491 | |||
492 | /** | ||
493 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
494 | * This initialization order is required to support indirect recursion. | ||
495 | * | ||
496 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
497 | * | ||
498 | */ | ||
499 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
500 | |||
501 | public static Object ensureInitialized() { | ||
502 | INSTANCE.ensureInitializedInternal(); | ||
503 | return null; | ||
504 | } | ||
505 | } | ||
506 | |||
507 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
508 | private static final KaAntennaGainLow.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
509 | |||
510 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
511 | |||
512 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm); | ||
513 | |||
514 | private GeneratedPQuery() { | ||
515 | super(PVisibility.PUBLIC); | ||
516 | } | ||
517 | |||
518 | @Override | ||
519 | public String getFullyQualifiedName() { | ||
520 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.kaAntennaGainLow"; | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public List<String> getParameterNames() { | ||
525 | return Arrays.asList("Comm"); | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public List<PParameter> getParameters() { | ||
530 | return parameters; | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public Set<PBody> doGetContainedBodies() { | ||
535 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
536 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
537 | { | ||
538 | PBody body = new PBody(this); | ||
539 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
540 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
541 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
542 | new ExportedParameter(body, var_Comm, parameter_Comm) | ||
543 | )); | ||
544 | // CommSubsystem.band(Comm, TransceiverBand::Ka) | ||
545 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
546 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "Ka").getInstance()); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
548 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
551 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
552 | // CommSubsystem.gain(Comm, AntennaGain::LOW) | ||
553 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
554 | new ConstantValue(body, var__virtual_2_, getEnumLiteral("http://www.example.org/satellite", "AntennaGain", "LOW").getInstance()); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
556 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
557 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "gain"))); | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "AntennaGain"))); | ||
559 | new Equality(body, var__virtual_3_, var__virtual_2_); | ||
560 | bodies.add(body); | ||
561 | } | ||
562 | { | ||
563 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
564 | annotation.addAttribute("severity", "error"); | ||
565 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
566 | new ParameterReference("Comm") | ||
567 | })); | ||
568 | annotation.addAttribute("message", "Ka-band transceiver must be combined with a medium or high gain antenna."); | ||
569 | addAnnotation(annotation); | ||
570 | } | ||
571 | return bodies; | ||
572 | } | ||
573 | } | ||
574 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/NoLinkToGroundStation.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/NoLinkToGroundStation.java new file mode 100644 index 00000000..598f3a6b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/NoLinkToGroundStation.java | |||
@@ -0,0 +1,575 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
43 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
44 | |||
45 | /** | ||
46 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
47 | * | ||
48 | * <p>Original source: | ||
49 | * <code><pre> | ||
50 | * // All spacecraft must have some communication path to the ground station | ||
51 | * | ||
52 | * {@literal @}Constraint(severity = "error", key = {Spacecraft}, | ||
53 | * message = "Spacecraft has no communication path to the ground station.") | ||
54 | * pattern noLinkToGroundStation(Spacecraft : Spacecraft) { | ||
55 | * ConstellationMission.groundStationNetwork(Mission, GroundStation); | ||
56 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
57 | * neg find indirectCommunicationLink(Spacecraft, GroundStation); | ||
58 | * } | ||
59 | * </pre></code> | ||
60 | * | ||
61 | * @see Matcher | ||
62 | * @see Match | ||
63 | * | ||
64 | */ | ||
65 | @SuppressWarnings("all") | ||
66 | public final class NoLinkToGroundStation extends BaseGeneratedEMFQuerySpecification<NoLinkToGroundStation.Matcher> { | ||
67 | /** | ||
68 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.noLinkToGroundStation pattern, | ||
69 | * to be used in conjunction with {@link Matcher}. | ||
70 | * | ||
71 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
72 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
73 | * usable to represent a match of the pattern in the result of a query, | ||
74 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
75 | * | ||
76 | * @see Matcher | ||
77 | * | ||
78 | */ | ||
79 | public static abstract class Match extends BasePatternMatch { | ||
80 | private Spacecraft fSpacecraft; | ||
81 | |||
82 | private static List<String> parameterNames = makeImmutableList("Spacecraft"); | ||
83 | |||
84 | private Match(final Spacecraft pSpacecraft) { | ||
85 | this.fSpacecraft = pSpacecraft; | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final String parameterName) { | ||
90 | if ("Spacecraft".equals(parameterName)) return this.fSpacecraft; | ||
91 | return null; | ||
92 | } | ||
93 | |||
94 | public Spacecraft getSpacecraft() { | ||
95 | return this.fSpacecraft; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public boolean set(final String parameterName, final Object newValue) { | ||
100 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
101 | if ("Spacecraft".equals(parameterName) ) { | ||
102 | this.fSpacecraft = (Spacecraft) newValue; | ||
103 | return true; | ||
104 | } | ||
105 | return false; | ||
106 | } | ||
107 | |||
108 | public void setSpacecraft(final Spacecraft pSpacecraft) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | this.fSpacecraft = pSpacecraft; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public String patternName() { | ||
115 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.noLinkToGroundStation"; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public List<String> parameterNames() { | ||
120 | return NoLinkToGroundStation.Match.parameterNames; | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public Object[] toArray() { | ||
125 | return new Object[]{fSpacecraft}; | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public NoLinkToGroundStation.Match toImmutable() { | ||
130 | return isMutable() ? newMatch(fSpacecraft) : this; | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public String prettyPrint() { | ||
135 | StringBuilder result = new StringBuilder(); | ||
136 | result.append("\"Spacecraft\"=" + prettyPrintValue(fSpacecraft)); | ||
137 | return result.toString(); | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public int hashCode() { | ||
142 | return Objects.hash(fSpacecraft); | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public boolean equals(final Object obj) { | ||
147 | if (this == obj) | ||
148 | return true; | ||
149 | if (obj == null) { | ||
150 | return false; | ||
151 | } | ||
152 | if ((obj instanceof NoLinkToGroundStation.Match)) { | ||
153 | NoLinkToGroundStation.Match other = (NoLinkToGroundStation.Match) obj; | ||
154 | return Objects.equals(fSpacecraft, other.fSpacecraft); | ||
155 | } else { | ||
156 | // this should be infrequent | ||
157 | if (!(obj instanceof IPatternMatch)) { | ||
158 | return false; | ||
159 | } | ||
160 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
161 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public NoLinkToGroundStation specification() { | ||
167 | return NoLinkToGroundStation.instance(); | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * Returns an empty, mutable match. | ||
172 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
173 | * | ||
174 | * @return the empty match. | ||
175 | * | ||
176 | */ | ||
177 | public static NoLinkToGroundStation.Match newEmptyMatch() { | ||
178 | return new Mutable(null); | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * Returns a mutable (partial) match. | ||
183 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
184 | * | ||
185 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
186 | * @return the new, mutable (partial) match object. | ||
187 | * | ||
188 | */ | ||
189 | public static NoLinkToGroundStation.Match newMutableMatch(final Spacecraft pSpacecraft) { | ||
190 | return new Mutable(pSpacecraft); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns a new (partial) match. | ||
195 | * This can be used e.g. to call the matcher with a partial match. | ||
196 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
197 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
198 | * @return the (partial) match object. | ||
199 | * | ||
200 | */ | ||
201 | public static NoLinkToGroundStation.Match newMatch(final Spacecraft pSpacecraft) { | ||
202 | return new Immutable(pSpacecraft); | ||
203 | } | ||
204 | |||
205 | private static final class Mutable extends NoLinkToGroundStation.Match { | ||
206 | Mutable(final Spacecraft pSpacecraft) { | ||
207 | super(pSpacecraft); | ||
208 | } | ||
209 | |||
210 | @Override | ||
211 | public boolean isMutable() { | ||
212 | return true; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | private static final class Immutable extends NoLinkToGroundStation.Match { | ||
217 | Immutable(final Spacecraft pSpacecraft) { | ||
218 | super(pSpacecraft); | ||
219 | } | ||
220 | |||
221 | @Override | ||
222 | public boolean isMutable() { | ||
223 | return false; | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | |||
228 | /** | ||
229 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.noLinkToGroundStation pattern, | ||
230 | * providing pattern-specific query methods. | ||
231 | * | ||
232 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
233 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
234 | * | ||
235 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
236 | * | ||
237 | * <p>Original source: | ||
238 | * <code><pre> | ||
239 | * // All spacecraft must have some communication path to the ground station | ||
240 | * | ||
241 | * {@literal @}Constraint(severity = "error", key = {Spacecraft}, | ||
242 | * message = "Spacecraft has no communication path to the ground station.") | ||
243 | * pattern noLinkToGroundStation(Spacecraft : Spacecraft) { | ||
244 | * ConstellationMission.groundStationNetwork(Mission, GroundStation); | ||
245 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
246 | * neg find indirectCommunicationLink(Spacecraft, GroundStation); | ||
247 | * } | ||
248 | * </pre></code> | ||
249 | * | ||
250 | * @see Match | ||
251 | * @see NoLinkToGroundStation | ||
252 | * | ||
253 | */ | ||
254 | public static class Matcher extends BaseMatcher<NoLinkToGroundStation.Match> { | ||
255 | /** | ||
256 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
257 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
258 | * | ||
259 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
260 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
261 | * | ||
262 | */ | ||
263 | public static NoLinkToGroundStation.Matcher on(final ViatraQueryEngine engine) { | ||
264 | // check if matcher already exists | ||
265 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
266 | if (matcher == null) { | ||
267 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
268 | } | ||
269 | return matcher; | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
274 | * @return an initialized matcher | ||
275 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
276 | * | ||
277 | */ | ||
278 | public static NoLinkToGroundStation.Matcher create() { | ||
279 | return new Matcher(); | ||
280 | } | ||
281 | |||
282 | private static final int POSITION_SPACECRAFT = 0; | ||
283 | |||
284 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NoLinkToGroundStation.Matcher.class); | ||
285 | |||
286 | /** | ||
287 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
288 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
289 | * | ||
290 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
291 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
292 | * | ||
293 | */ | ||
294 | private Matcher() { | ||
295 | super(querySpecification()); | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
300 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
301 | * @return matches represented as a Match object. | ||
302 | * | ||
303 | */ | ||
304 | public Collection<NoLinkToGroundStation.Match> getAllMatches(final Spacecraft pSpacecraft) { | ||
305 | return rawStreamAllMatches(new Object[]{pSpacecraft}).collect(Collectors.toSet()); | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
310 | * </p> | ||
311 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
312 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
313 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
314 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
315 | * @return a stream of matches represented as a Match object. | ||
316 | * | ||
317 | */ | ||
318 | public Stream<NoLinkToGroundStation.Match> streamAllMatches(final Spacecraft pSpacecraft) { | ||
319 | return rawStreamAllMatches(new Object[]{pSpacecraft}); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
324 | * Neither determinism nor randomness of selection is guaranteed. | ||
325 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
326 | * @return a match represented as a Match object, or null if no match is found. | ||
327 | * | ||
328 | */ | ||
329 | public Optional<NoLinkToGroundStation.Match> getOneArbitraryMatch(final Spacecraft pSpacecraft) { | ||
330 | return rawGetOneArbitraryMatch(new Object[]{pSpacecraft}); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
335 | * under any possible substitution of the unspecified parameters (if any). | ||
336 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
337 | * @return true if the input is a valid (partial) match of the pattern. | ||
338 | * | ||
339 | */ | ||
340 | public boolean hasMatch(final Spacecraft pSpacecraft) { | ||
341 | return rawHasMatch(new Object[]{pSpacecraft}); | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
346 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
347 | * @return the number of pattern matches found. | ||
348 | * | ||
349 | */ | ||
350 | public int countMatches(final Spacecraft pSpacecraft) { | ||
351 | return rawCountMatches(new Object[]{pSpacecraft}); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
356 | * Neither determinism nor randomness of selection is guaranteed. | ||
357 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
358 | * @param processor the action that will process the selected match. | ||
359 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
360 | * | ||
361 | */ | ||
362 | public boolean forOneArbitraryMatch(final Spacecraft pSpacecraft, final Consumer<? super NoLinkToGroundStation.Match> processor) { | ||
363 | return rawForOneArbitraryMatch(new Object[]{pSpacecraft}, processor); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Returns a new (partial) match. | ||
368 | * This can be used e.g. to call the matcher with a partial match. | ||
369 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
370 | * @param pSpacecraft the fixed value of pattern parameter Spacecraft, or null if not bound. | ||
371 | * @return the (partial) match object. | ||
372 | * | ||
373 | */ | ||
374 | public NoLinkToGroundStation.Match newMatch(final Spacecraft pSpacecraft) { | ||
375 | return NoLinkToGroundStation.Match.newMatch(pSpacecraft); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Retrieve the set of values that occur in matches for Spacecraft. | ||
380 | * @return the Set of all values or empty set if there are no matches | ||
381 | * | ||
382 | */ | ||
383 | protected Stream<Spacecraft> rawStreamAllValuesOfSpacecraft(final Object[] parameters) { | ||
384 | return rawStreamAllValues(POSITION_SPACECRAFT, parameters).map(Spacecraft.class::cast); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for Spacecraft. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | public Set<Spacecraft> getAllValuesOfSpacecraft() { | ||
393 | return rawStreamAllValuesOfSpacecraft(emptyArray()).collect(Collectors.toSet()); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for Spacecraft. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Stream<Spacecraft> streamAllValuesOfSpacecraft() { | ||
402 | return rawStreamAllValuesOfSpacecraft(emptyArray()); | ||
403 | } | ||
404 | |||
405 | @Override | ||
406 | protected NoLinkToGroundStation.Match tupleToMatch(final Tuple t) { | ||
407 | try { | ||
408 | return NoLinkToGroundStation.Match.newMatch((Spacecraft) t.get(POSITION_SPACECRAFT)); | ||
409 | } catch(ClassCastException e) { | ||
410 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
411 | return null; | ||
412 | } | ||
413 | } | ||
414 | |||
415 | @Override | ||
416 | protected NoLinkToGroundStation.Match arrayToMatch(final Object[] match) { | ||
417 | try { | ||
418 | return NoLinkToGroundStation.Match.newMatch((Spacecraft) match[POSITION_SPACECRAFT]); | ||
419 | } catch(ClassCastException e) { | ||
420 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
421 | return null; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | @Override | ||
426 | protected NoLinkToGroundStation.Match arrayToMatchMutable(final Object[] match) { | ||
427 | try { | ||
428 | return NoLinkToGroundStation.Match.newMutableMatch((Spacecraft) match[POSITION_SPACECRAFT]); | ||
429 | } catch(ClassCastException e) { | ||
430 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
431 | return null; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * @return the singleton instance of the query specification of this pattern | ||
437 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
438 | * | ||
439 | */ | ||
440 | public static IQuerySpecification<NoLinkToGroundStation.Matcher> querySpecification() { | ||
441 | return NoLinkToGroundStation.instance(); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | private NoLinkToGroundStation() { | ||
446 | super(GeneratedPQuery.INSTANCE); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * @return the singleton instance of the query specification | ||
451 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
452 | * | ||
453 | */ | ||
454 | public static NoLinkToGroundStation instance() { | ||
455 | try{ | ||
456 | return LazyHolder.INSTANCE; | ||
457 | } catch (ExceptionInInitializerError err) { | ||
458 | throw processInitializerError(err); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | @Override | ||
463 | protected NoLinkToGroundStation.Matcher instantiate(final ViatraQueryEngine engine) { | ||
464 | return NoLinkToGroundStation.Matcher.on(engine); | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | public NoLinkToGroundStation.Matcher instantiate() { | ||
469 | return NoLinkToGroundStation.Matcher.create(); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public NoLinkToGroundStation.Match newEmptyMatch() { | ||
474 | return NoLinkToGroundStation.Match.newEmptyMatch(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public NoLinkToGroundStation.Match newMatch(final Object... parameters) { | ||
479 | return NoLinkToGroundStation.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft) parameters[0]); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation (visibility: PUBLIC, simpleName: NoLinkToGroundStation, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
484 | * <b>not</b> at the class load time of the outer class, | ||
485 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation (visibility: PUBLIC, simpleName: NoLinkToGroundStation, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
486 | * | ||
487 | * <p> This workaround is required e.g. to support recursion. | ||
488 | * | ||
489 | */ | ||
490 | private static class LazyHolder { | ||
491 | private static final NoLinkToGroundStation INSTANCE = new NoLinkToGroundStation(); | ||
492 | |||
493 | /** | ||
494 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
495 | * This initialization order is required to support indirect recursion. | ||
496 | * | ||
497 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
498 | * | ||
499 | */ | ||
500 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
501 | |||
502 | public static Object ensureInitialized() { | ||
503 | INSTANCE.ensureInitializedInternal(); | ||
504 | return null; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
509 | private static final NoLinkToGroundStation.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
510 | |||
511 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
512 | |||
513 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft); | ||
514 | |||
515 | private GeneratedPQuery() { | ||
516 | super(PVisibility.PUBLIC); | ||
517 | } | ||
518 | |||
519 | @Override | ||
520 | public String getFullyQualifiedName() { | ||
521 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.noLinkToGroundStation"; | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public List<String> getParameterNames() { | ||
526 | return Arrays.asList("Spacecraft"); | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<PParameter> getParameters() { | ||
531 | return parameters; | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public Set<PBody> doGetContainedBodies() { | ||
536 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
537 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
538 | { | ||
539 | PBody body = new PBody(this); | ||
540 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
541 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
542 | PVariable var_GroundStation = body.getOrCreateVariableByName("GroundStation"); | ||
543 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
544 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
545 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft) | ||
546 | )); | ||
547 | // ConstellationMission.groundStationNetwork(Mission, GroundStation) | ||
548 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
549 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "groundStationNetwork"))); | ||
551 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); | ||
552 | new Equality(body, var__virtual_0_, var_GroundStation); | ||
553 | // ConstellationMission.spacecraft(Mission, Spacecraft) | ||
554 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
555 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); | ||
557 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
558 | new Equality(body, var__virtual_1_, var_Spacecraft); | ||
559 | // neg find indirectCommunicationLink(Spacecraft, GroundStation) | ||
560 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_GroundStation), IndirectCommunicationLink.instance().getInternalQueryRepresentation()); | ||
561 | bodies.add(body); | ||
562 | } | ||
563 | { | ||
564 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
565 | annotation.addAttribute("severity", "error"); | ||
566 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
567 | new ParameterReference("Spacecraft") | ||
568 | })); | ||
569 | annotation.addAttribute("message", "Spacecraft has no communication path to the ground station."); | ||
570 | addAnnotation(annotation); | ||
571 | } | ||
572 | return bodies; | ||
573 | } | ||
574 | } | ||
575 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/NotEnoughInterferometryPayloads.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/NotEnoughInterferometryPayloads.java new file mode 100644 index 00000000..39af9d5b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/NotEnoughInterferometryPayloads.java | |||
@@ -0,0 +1,548 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // At least two spacecraft must have the interferometry payload configured | ||
47 | * | ||
48 | * //{@literal @}Constraint(severity = "error", key = {Mission}, | ||
49 | * // message = "Interferometry mission needs at least two spacecraft configured with the interferometry payload.") | ||
50 | * pattern notEnoughInterferometryPayloads(Mission : InterferometryMission) { | ||
51 | * InterferometryMission(Mission); | ||
52 | * neg find atLeastTwoInterferometryPayloads(Mission); | ||
53 | * } | ||
54 | * </pre></code> | ||
55 | * | ||
56 | * @see Matcher | ||
57 | * @see Match | ||
58 | * | ||
59 | */ | ||
60 | @SuppressWarnings("all") | ||
61 | public final class NotEnoughInterferometryPayloads extends BaseGeneratedEMFQuerySpecification<NotEnoughInterferometryPayloads.Matcher> { | ||
62 | /** | ||
63 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.notEnoughInterferometryPayloads pattern, | ||
64 | * to be used in conjunction with {@link Matcher}. | ||
65 | * | ||
66 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
67 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
68 | * usable to represent a match of the pattern in the result of a query, | ||
69 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
70 | * | ||
71 | * @see Matcher | ||
72 | * | ||
73 | */ | ||
74 | public static abstract class Match extends BasePatternMatch { | ||
75 | private InterferometryMission fMission; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("Mission"); | ||
78 | |||
79 | private Match(final InterferometryMission pMission) { | ||
80 | this.fMission = pMission; | ||
81 | } | ||
82 | |||
83 | @Override | ||
84 | public Object get(final String parameterName) { | ||
85 | if ("Mission".equals(parameterName)) return this.fMission; | ||
86 | return null; | ||
87 | } | ||
88 | |||
89 | public InterferometryMission getMission() { | ||
90 | return this.fMission; | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public boolean set(final String parameterName, final Object newValue) { | ||
95 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
96 | if ("Mission".equals(parameterName) ) { | ||
97 | this.fMission = (InterferometryMission) newValue; | ||
98 | return true; | ||
99 | } | ||
100 | return false; | ||
101 | } | ||
102 | |||
103 | public void setMission(final InterferometryMission pMission) { | ||
104 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
105 | this.fMission = pMission; | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public String patternName() { | ||
110 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.notEnoughInterferometryPayloads"; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public List<String> parameterNames() { | ||
115 | return NotEnoughInterferometryPayloads.Match.parameterNames; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public Object[] toArray() { | ||
120 | return new Object[]{fMission}; | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public NotEnoughInterferometryPayloads.Match toImmutable() { | ||
125 | return isMutable() ? newMatch(fMission) : this; | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public String prettyPrint() { | ||
130 | StringBuilder result = new StringBuilder(); | ||
131 | result.append("\"Mission\"=" + prettyPrintValue(fMission)); | ||
132 | return result.toString(); | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public int hashCode() { | ||
137 | return Objects.hash(fMission); | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public boolean equals(final Object obj) { | ||
142 | if (this == obj) | ||
143 | return true; | ||
144 | if (obj == null) { | ||
145 | return false; | ||
146 | } | ||
147 | if ((obj instanceof NotEnoughInterferometryPayloads.Match)) { | ||
148 | NotEnoughInterferometryPayloads.Match other = (NotEnoughInterferometryPayloads.Match) obj; | ||
149 | return Objects.equals(fMission, other.fMission); | ||
150 | } else { | ||
151 | // this should be infrequent | ||
152 | if (!(obj instanceof IPatternMatch)) { | ||
153 | return false; | ||
154 | } | ||
155 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
156 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | @Override | ||
161 | public NotEnoughInterferometryPayloads specification() { | ||
162 | return NotEnoughInterferometryPayloads.instance(); | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * Returns an empty, mutable match. | ||
167 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
168 | * | ||
169 | * @return the empty match. | ||
170 | * | ||
171 | */ | ||
172 | public static NotEnoughInterferometryPayloads.Match newEmptyMatch() { | ||
173 | return new Mutable(null); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns a mutable (partial) match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
181 | * @return the new, mutable (partial) match object. | ||
182 | * | ||
183 | */ | ||
184 | public static NotEnoughInterferometryPayloads.Match newMutableMatch(final InterferometryMission pMission) { | ||
185 | return new Mutable(pMission); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Returns a new (partial) match. | ||
190 | * This can be used e.g. to call the matcher with a partial match. | ||
191 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
192 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
193 | * @return the (partial) match object. | ||
194 | * | ||
195 | */ | ||
196 | public static NotEnoughInterferometryPayloads.Match newMatch(final InterferometryMission pMission) { | ||
197 | return new Immutable(pMission); | ||
198 | } | ||
199 | |||
200 | private static final class Mutable extends NotEnoughInterferometryPayloads.Match { | ||
201 | Mutable(final InterferometryMission pMission) { | ||
202 | super(pMission); | ||
203 | } | ||
204 | |||
205 | @Override | ||
206 | public boolean isMutable() { | ||
207 | return true; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | private static final class Immutable extends NotEnoughInterferometryPayloads.Match { | ||
212 | Immutable(final InterferometryMission pMission) { | ||
213 | super(pMission); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return false; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | /** | ||
224 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.notEnoughInterferometryPayloads pattern, | ||
225 | * providing pattern-specific query methods. | ||
226 | * | ||
227 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
228 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
229 | * | ||
230 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
231 | * | ||
232 | * <p>Original source: | ||
233 | * <code><pre> | ||
234 | * // At least two spacecraft must have the interferometry payload configured | ||
235 | * | ||
236 | * //{@literal @}Constraint(severity = "error", key = {Mission}, | ||
237 | * // message = "Interferometry mission needs at least two spacecraft configured with the interferometry payload.") | ||
238 | * pattern notEnoughInterferometryPayloads(Mission : InterferometryMission) { | ||
239 | * InterferometryMission(Mission); | ||
240 | * neg find atLeastTwoInterferometryPayloads(Mission); | ||
241 | * } | ||
242 | * </pre></code> | ||
243 | * | ||
244 | * @see Match | ||
245 | * @see NotEnoughInterferometryPayloads | ||
246 | * | ||
247 | */ | ||
248 | public static class Matcher extends BaseMatcher<NotEnoughInterferometryPayloads.Match> { | ||
249 | /** | ||
250 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
251 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
252 | * | ||
253 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
254 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
255 | * | ||
256 | */ | ||
257 | public static NotEnoughInterferometryPayloads.Matcher on(final ViatraQueryEngine engine) { | ||
258 | // check if matcher already exists | ||
259 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
260 | if (matcher == null) { | ||
261 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
262 | } | ||
263 | return matcher; | ||
264 | } | ||
265 | |||
266 | /** | ||
267 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
268 | * @return an initialized matcher | ||
269 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
270 | * | ||
271 | */ | ||
272 | public static NotEnoughInterferometryPayloads.Matcher create() { | ||
273 | return new Matcher(); | ||
274 | } | ||
275 | |||
276 | private static final int POSITION_MISSION = 0; | ||
277 | |||
278 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughInterferometryPayloads.Matcher.class); | ||
279 | |||
280 | /** | ||
281 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
282 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
283 | * | ||
284 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * | ||
287 | */ | ||
288 | private Matcher() { | ||
289 | super(querySpecification()); | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
294 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
295 | * @return matches represented as a Match object. | ||
296 | * | ||
297 | */ | ||
298 | public Collection<NotEnoughInterferometryPayloads.Match> getAllMatches(final InterferometryMission pMission) { | ||
299 | return rawStreamAllMatches(new Object[]{pMission}).collect(Collectors.toSet()); | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
304 | * </p> | ||
305 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
306 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
307 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
308 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
309 | * @return a stream of matches represented as a Match object. | ||
310 | * | ||
311 | */ | ||
312 | public Stream<NotEnoughInterferometryPayloads.Match> streamAllMatches(final InterferometryMission pMission) { | ||
313 | return rawStreamAllMatches(new Object[]{pMission}); | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
318 | * Neither determinism nor randomness of selection is guaranteed. | ||
319 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
320 | * @return a match represented as a Match object, or null if no match is found. | ||
321 | * | ||
322 | */ | ||
323 | public Optional<NotEnoughInterferometryPayloads.Match> getOneArbitraryMatch(final InterferometryMission pMission) { | ||
324 | return rawGetOneArbitraryMatch(new Object[]{pMission}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
329 | * under any possible substitution of the unspecified parameters (if any). | ||
330 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
331 | * @return true if the input is a valid (partial) match of the pattern. | ||
332 | * | ||
333 | */ | ||
334 | public boolean hasMatch(final InterferometryMission pMission) { | ||
335 | return rawHasMatch(new Object[]{pMission}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
340 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
341 | * @return the number of pattern matches found. | ||
342 | * | ||
343 | */ | ||
344 | public int countMatches(final InterferometryMission pMission) { | ||
345 | return rawCountMatches(new Object[]{pMission}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
350 | * Neither determinism nor randomness of selection is guaranteed. | ||
351 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
352 | * @param processor the action that will process the selected match. | ||
353 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
354 | * | ||
355 | */ | ||
356 | public boolean forOneArbitraryMatch(final InterferometryMission pMission, final Consumer<? super NotEnoughInterferometryPayloads.Match> processor) { | ||
357 | return rawForOneArbitraryMatch(new Object[]{pMission}, processor); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Returns a new (partial) match. | ||
362 | * This can be used e.g. to call the matcher with a partial match. | ||
363 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
364 | * @param pMission the fixed value of pattern parameter Mission, or null if not bound. | ||
365 | * @return the (partial) match object. | ||
366 | * | ||
367 | */ | ||
368 | public NotEnoughInterferometryPayloads.Match newMatch(final InterferometryMission pMission) { | ||
369 | return NotEnoughInterferometryPayloads.Match.newMatch(pMission); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Retrieve the set of values that occur in matches for Mission. | ||
374 | * @return the Set of all values or empty set if there are no matches | ||
375 | * | ||
376 | */ | ||
377 | protected Stream<InterferometryMission> rawStreamAllValuesOfMission(final Object[] parameters) { | ||
378 | return rawStreamAllValues(POSITION_MISSION, parameters).map(InterferometryMission.class::cast); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Retrieve the set of values that occur in matches for Mission. | ||
383 | * @return the Set of all values or empty set if there are no matches | ||
384 | * | ||
385 | */ | ||
386 | public Set<InterferometryMission> getAllValuesOfMission() { | ||
387 | return rawStreamAllValuesOfMission(emptyArray()).collect(Collectors.toSet()); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Retrieve the set of values that occur in matches for Mission. | ||
392 | * @return the Set of all values or empty set if there are no matches | ||
393 | * | ||
394 | */ | ||
395 | public Stream<InterferometryMission> streamAllValuesOfMission() { | ||
396 | return rawStreamAllValuesOfMission(emptyArray()); | ||
397 | } | ||
398 | |||
399 | @Override | ||
400 | protected NotEnoughInterferometryPayloads.Match tupleToMatch(final Tuple t) { | ||
401 | try { | ||
402 | return NotEnoughInterferometryPayloads.Match.newMatch((InterferometryMission) t.get(POSITION_MISSION)); | ||
403 | } catch(ClassCastException e) { | ||
404 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
405 | return null; | ||
406 | } | ||
407 | } | ||
408 | |||
409 | @Override | ||
410 | protected NotEnoughInterferometryPayloads.Match arrayToMatch(final Object[] match) { | ||
411 | try { | ||
412 | return NotEnoughInterferometryPayloads.Match.newMatch((InterferometryMission) match[POSITION_MISSION]); | ||
413 | } catch(ClassCastException e) { | ||
414 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
415 | return null; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | @Override | ||
420 | protected NotEnoughInterferometryPayloads.Match arrayToMatchMutable(final Object[] match) { | ||
421 | try { | ||
422 | return NotEnoughInterferometryPayloads.Match.newMutableMatch((InterferometryMission) match[POSITION_MISSION]); | ||
423 | } catch(ClassCastException e) { | ||
424 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
425 | return null; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * @return the singleton instance of the query specification of this pattern | ||
431 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
432 | * | ||
433 | */ | ||
434 | public static IQuerySpecification<NotEnoughInterferometryPayloads.Matcher> querySpecification() { | ||
435 | return NotEnoughInterferometryPayloads.instance(); | ||
436 | } | ||
437 | } | ||
438 | |||
439 | private NotEnoughInterferometryPayloads() { | ||
440 | super(GeneratedPQuery.INSTANCE); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * @return the singleton instance of the query specification | ||
445 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
446 | * | ||
447 | */ | ||
448 | public static NotEnoughInterferometryPayloads instance() { | ||
449 | try{ | ||
450 | return LazyHolder.INSTANCE; | ||
451 | } catch (ExceptionInInitializerError err) { | ||
452 | throw processInitializerError(err); | ||
453 | } | ||
454 | } | ||
455 | |||
456 | @Override | ||
457 | protected NotEnoughInterferometryPayloads.Matcher instantiate(final ViatraQueryEngine engine) { | ||
458 | return NotEnoughInterferometryPayloads.Matcher.on(engine); | ||
459 | } | ||
460 | |||
461 | @Override | ||
462 | public NotEnoughInterferometryPayloads.Matcher instantiate() { | ||
463 | return NotEnoughInterferometryPayloads.Matcher.create(); | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | public NotEnoughInterferometryPayloads.Match newEmptyMatch() { | ||
468 | return NotEnoughInterferometryPayloads.Match.newEmptyMatch(); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public NotEnoughInterferometryPayloads.Match newMatch(final Object... parameters) { | ||
473 | return NotEnoughInterferometryPayloads.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission) parameters[0]); | ||
474 | } | ||
475 | |||
476 | /** | ||
477 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads (visibility: PUBLIC, simpleName: NotEnoughInterferometryPayloads, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
478 | * <b>not</b> at the class load time of the outer class, | ||
479 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads (visibility: PUBLIC, simpleName: NotEnoughInterferometryPayloads, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
480 | * | ||
481 | * <p> This workaround is required e.g. to support recursion. | ||
482 | * | ||
483 | */ | ||
484 | private static class LazyHolder { | ||
485 | private static final NotEnoughInterferometryPayloads INSTANCE = new NotEnoughInterferometryPayloads(); | ||
486 | |||
487 | /** | ||
488 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
489 | * This initialization order is required to support indirect recursion. | ||
490 | * | ||
491 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
492 | * | ||
493 | */ | ||
494 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
495 | |||
496 | public static Object ensureInitialized() { | ||
497 | INSTANCE.ensureInitializedInternal(); | ||
498 | return null; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
503 | private static final NotEnoughInterferometryPayloads.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
504 | |||
505 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
506 | |||
507 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission); | ||
508 | |||
509 | private GeneratedPQuery() { | ||
510 | super(PVisibility.PUBLIC); | ||
511 | } | ||
512 | |||
513 | @Override | ||
514 | public String getFullyQualifiedName() { | ||
515 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.notEnoughInterferometryPayloads"; | ||
516 | } | ||
517 | |||
518 | @Override | ||
519 | public List<String> getParameterNames() { | ||
520 | return Arrays.asList("Mission"); | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public List<PParameter> getParameters() { | ||
525 | return parameters; | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public Set<PBody> doGetContainedBodies() { | ||
530 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
531 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
532 | { | ||
533 | PBody body = new PBody(this); | ||
534 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
535 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
536 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
537 | new ExportedParameter(body, var_Mission, parameter_Mission) | ||
538 | )); | ||
539 | // InterferometryMission(Mission) | ||
540 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
541 | // neg find atLeastTwoInterferometryPayloads(Mission) | ||
542 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Mission), AtLeastTwoInterferometryPayloads.instance().getInternalQueryRepresentation()); | ||
543 | bodies.add(body); | ||
544 | } | ||
545 | return bodies; | ||
546 | } | ||
547 | } | ||
548 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java new file mode 100644 index 00000000..b6601c28 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java | |||
@@ -0,0 +1,196 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand; | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain; | ||
13 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow; | ||
14 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation; | ||
15 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads; | ||
16 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink; | ||
17 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric; | ||
18 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow; | ||
19 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
22 | |||
23 | /** | ||
24 | * A pattern group formed of all public patterns defined in SatelliteQueries.vql. | ||
25 | * | ||
26 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare | ||
27 | * a VIATRA Query engine for matching all patterns originally defined in file SatelliteQueries.vql, | ||
28 | * in order to achieve better performance than one-by-one on-demand matcher initialization. | ||
29 | * | ||
30 | * <p> From package hu.bme.mit.inf.dslreasoner.domains.satellite.queries, the group contains the definition of the following patterns: <ul> | ||
31 | * <li>communicationLinkDoesNotStartAtContainingElement</li> | ||
32 | * <li>notEnoughInterferometryPayloads</li> | ||
33 | * <li>noLinkToGroundStation</li> | ||
34 | * <li>communicationLoop</li> | ||
35 | * <li>incompatibleSourceAndTargetBand</li> | ||
36 | * <li>incompatibleSourceAndTargetGain</li> | ||
37 | * <li>uhfAntennaGainNotLow</li> | ||
38 | * <li>xAntennaGainNotMedium</li> | ||
39 | * <li>kaAntennaGainLow</li> | ||
40 | * <li>threeUCubeSatWithNonUhfCrossLink</li> | ||
41 | * <li>cubeSatWithKaAntenna</li> | ||
42 | * <li>coverageMetric</li> | ||
43 | * <li>timeMetric</li> | ||
44 | * <li>costMetric</li> | ||
45 | * </ul> | ||
46 | * | ||
47 | * @see IQueryGroup | ||
48 | * | ||
49 | */ | ||
50 | @SuppressWarnings("all") | ||
51 | public final class SatelliteQueries extends BaseGeneratedPatternGroup { | ||
52 | /** | ||
53 | * Access the pattern group. | ||
54 | * | ||
55 | * @return the singleton instance of the group | ||
56 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
57 | * | ||
58 | */ | ||
59 | public static SatelliteQueries instance() { | ||
60 | if (INSTANCE == null) { | ||
61 | INSTANCE = new SatelliteQueries(); | ||
62 | } | ||
63 | return INSTANCE; | ||
64 | } | ||
65 | |||
66 | private static SatelliteQueries INSTANCE; | ||
67 | |||
68 | private SatelliteQueries() { | ||
69 | querySpecifications.add(CommunicationLinkDoesNotStartAtContainingElement.instance()); | ||
70 | querySpecifications.add(NotEnoughInterferometryPayloads.instance()); | ||
71 | querySpecifications.add(NoLinkToGroundStation.instance()); | ||
72 | querySpecifications.add(CommunicationLoop.instance()); | ||
73 | querySpecifications.add(IncompatibleSourceAndTargetBand.instance()); | ||
74 | querySpecifications.add(IncompatibleSourceAndTargetGain.instance()); | ||
75 | querySpecifications.add(UhfAntennaGainNotLow.instance()); | ||
76 | querySpecifications.add(XAntennaGainNotMedium.instance()); | ||
77 | querySpecifications.add(KaAntennaGainLow.instance()); | ||
78 | querySpecifications.add(ThreeUCubeSatWithNonUhfCrossLink.instance()); | ||
79 | querySpecifications.add(CubeSatWithKaAntenna.instance()); | ||
80 | querySpecifications.add(CoverageMetric.instance()); | ||
81 | querySpecifications.add(TimeMetric.instance()); | ||
82 | querySpecifications.add(CostMetric.instance()); | ||
83 | } | ||
84 | |||
85 | public CommunicationLinkDoesNotStartAtContainingElement getCommunicationLinkDoesNotStartAtContainingElement() { | ||
86 | return CommunicationLinkDoesNotStartAtContainingElement.instance(); | ||
87 | } | ||
88 | |||
89 | public CommunicationLinkDoesNotStartAtContainingElement.Matcher getCommunicationLinkDoesNotStartAtContainingElement(final ViatraQueryEngine engine) { | ||
90 | return CommunicationLinkDoesNotStartAtContainingElement.Matcher.on(engine); | ||
91 | } | ||
92 | |||
93 | public NotEnoughInterferometryPayloads getNotEnoughInterferometryPayloads() { | ||
94 | return NotEnoughInterferometryPayloads.instance(); | ||
95 | } | ||
96 | |||
97 | public NotEnoughInterferometryPayloads.Matcher getNotEnoughInterferometryPayloads(final ViatraQueryEngine engine) { | ||
98 | return NotEnoughInterferometryPayloads.Matcher.on(engine); | ||
99 | } | ||
100 | |||
101 | public NoLinkToGroundStation getNoLinkToGroundStation() { | ||
102 | return NoLinkToGroundStation.instance(); | ||
103 | } | ||
104 | |||
105 | public NoLinkToGroundStation.Matcher getNoLinkToGroundStation(final ViatraQueryEngine engine) { | ||
106 | return NoLinkToGroundStation.Matcher.on(engine); | ||
107 | } | ||
108 | |||
109 | public CommunicationLoop getCommunicationLoop() { | ||
110 | return CommunicationLoop.instance(); | ||
111 | } | ||
112 | |||
113 | public CommunicationLoop.Matcher getCommunicationLoop(final ViatraQueryEngine engine) { | ||
114 | return CommunicationLoop.Matcher.on(engine); | ||
115 | } | ||
116 | |||
117 | public IncompatibleSourceAndTargetBand getIncompatibleSourceAndTargetBand() { | ||
118 | return IncompatibleSourceAndTargetBand.instance(); | ||
119 | } | ||
120 | |||
121 | public IncompatibleSourceAndTargetBand.Matcher getIncompatibleSourceAndTargetBand(final ViatraQueryEngine engine) { | ||
122 | return IncompatibleSourceAndTargetBand.Matcher.on(engine); | ||
123 | } | ||
124 | |||
125 | public IncompatibleSourceAndTargetGain getIncompatibleSourceAndTargetGain() { | ||
126 | return IncompatibleSourceAndTargetGain.instance(); | ||
127 | } | ||
128 | |||
129 | public IncompatibleSourceAndTargetGain.Matcher getIncompatibleSourceAndTargetGain(final ViatraQueryEngine engine) { | ||
130 | return IncompatibleSourceAndTargetGain.Matcher.on(engine); | ||
131 | } | ||
132 | |||
133 | public UhfAntennaGainNotLow getUhfAntennaGainNotLow() { | ||
134 | return UhfAntennaGainNotLow.instance(); | ||
135 | } | ||
136 | |||
137 | public UhfAntennaGainNotLow.Matcher getUhfAntennaGainNotLow(final ViatraQueryEngine engine) { | ||
138 | return UhfAntennaGainNotLow.Matcher.on(engine); | ||
139 | } | ||
140 | |||
141 | public XAntennaGainNotMedium getXAntennaGainNotMedium() { | ||
142 | return XAntennaGainNotMedium.instance(); | ||
143 | } | ||
144 | |||
145 | public XAntennaGainNotMedium.Matcher getXAntennaGainNotMedium(final ViatraQueryEngine engine) { | ||
146 | return XAntennaGainNotMedium.Matcher.on(engine); | ||
147 | } | ||
148 | |||
149 | public KaAntennaGainLow getKaAntennaGainLow() { | ||
150 | return KaAntennaGainLow.instance(); | ||
151 | } | ||
152 | |||
153 | public KaAntennaGainLow.Matcher getKaAntennaGainLow(final ViatraQueryEngine engine) { | ||
154 | return KaAntennaGainLow.Matcher.on(engine); | ||
155 | } | ||
156 | |||
157 | public ThreeUCubeSatWithNonUhfCrossLink getThreeUCubeSatWithNonUhfCrossLink() { | ||
158 | return ThreeUCubeSatWithNonUhfCrossLink.instance(); | ||
159 | } | ||
160 | |||
161 | public ThreeUCubeSatWithNonUhfCrossLink.Matcher getThreeUCubeSatWithNonUhfCrossLink(final ViatraQueryEngine engine) { | ||
162 | return ThreeUCubeSatWithNonUhfCrossLink.Matcher.on(engine); | ||
163 | } | ||
164 | |||
165 | public CubeSatWithKaAntenna getCubeSatWithKaAntenna() { | ||
166 | return CubeSatWithKaAntenna.instance(); | ||
167 | } | ||
168 | |||
169 | public CubeSatWithKaAntenna.Matcher getCubeSatWithKaAntenna(final ViatraQueryEngine engine) { | ||
170 | return CubeSatWithKaAntenna.Matcher.on(engine); | ||
171 | } | ||
172 | |||
173 | public CoverageMetric getCoverageMetric() { | ||
174 | return CoverageMetric.instance(); | ||
175 | } | ||
176 | |||
177 | public CoverageMetric.Matcher getCoverageMetric(final ViatraQueryEngine engine) { | ||
178 | return CoverageMetric.Matcher.on(engine); | ||
179 | } | ||
180 | |||
181 | public TimeMetric getTimeMetric() { | ||
182 | return TimeMetric.instance(); | ||
183 | } | ||
184 | |||
185 | public TimeMetric.Matcher getTimeMetric(final ViatraQueryEngine engine) { | ||
186 | return TimeMetric.Matcher.on(engine); | ||
187 | } | ||
188 | |||
189 | public CostMetric getCostMetric() { | ||
190 | return CostMetric.instance(); | ||
191 | } | ||
192 | |||
193 | public CostMetric.Matcher getCostMetric(final ViatraQueryEngine engine) { | ||
194 | return CostMetric.Matcher.on(engine); | ||
195 | } | ||
196 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java new file mode 100644 index 00000000..6500c9d3 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java | |||
@@ -0,0 +1,613 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.emf.ecore.EDataType; | ||
22 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
23 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
28 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
31 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
46 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
47 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
48 | |||
49 | /** | ||
50 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
51 | * | ||
52 | * <p>Original source: | ||
53 | * <code><pre> | ||
54 | * // 3U CubeSats are assumed to only be able to downlink to Earth using an X-band trasmitter, | ||
55 | * // but cross-link using UHF | ||
56 | * | ||
57 | * {@literal @}Constraint(severity = "error", key = {Sat}, | ||
58 | * message = "3U CubeSats can only cross-link using UHF.") | ||
59 | * pattern threeUCubeSatWithNonUhfCrossLink(Sat : Spacecraft) { | ||
60 | * Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U); | ||
61 | * CommunicatingElement.commSubsystem(Sat, SourceComm); | ||
62 | * neg find commSubsystemBandUhf(SourceComm); | ||
63 | * DirectedCommunicationLink.source(Link, SourceComm); | ||
64 | * DirectedCommunicationLink.target(Link, TargetComm); | ||
65 | * CommunicatingElement.commSubsystem(Target, TargetComm); | ||
66 | * neg find groundStationNetwork(Target); | ||
67 | * } | ||
68 | * </pre></code> | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * @see Match | ||
72 | * | ||
73 | */ | ||
74 | @SuppressWarnings("all") | ||
75 | public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuerySpecification<ThreeUCubeSatWithNonUhfCrossLink.Matcher> { | ||
76 | /** | ||
77 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.threeUCubeSatWithNonUhfCrossLink pattern, | ||
78 | * to be used in conjunction with {@link Matcher}. | ||
79 | * | ||
80 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
81 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
82 | * usable to represent a match of the pattern in the result of a query, | ||
83 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
84 | * | ||
85 | * @see Matcher | ||
86 | * | ||
87 | */ | ||
88 | public static abstract class Match extends BasePatternMatch { | ||
89 | private Spacecraft fSat; | ||
90 | |||
91 | private static List<String> parameterNames = makeImmutableList("Sat"); | ||
92 | |||
93 | private Match(final Spacecraft pSat) { | ||
94 | this.fSat = pSat; | ||
95 | } | ||
96 | |||
97 | @Override | ||
98 | public Object get(final String parameterName) { | ||
99 | if ("Sat".equals(parameterName)) return this.fSat; | ||
100 | return null; | ||
101 | } | ||
102 | |||
103 | public Spacecraft getSat() { | ||
104 | return this.fSat; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("Sat".equals(parameterName) ) { | ||
111 | this.fSat = (Spacecraft) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | return false; | ||
115 | } | ||
116 | |||
117 | public void setSat(final Spacecraft pSat) { | ||
118 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
119 | this.fSat = pSat; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public String patternName() { | ||
124 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.threeUCubeSatWithNonUhfCrossLink"; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public List<String> parameterNames() { | ||
129 | return ThreeUCubeSatWithNonUhfCrossLink.Match.parameterNames; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public Object[] toArray() { | ||
134 | return new Object[]{fSat}; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public ThreeUCubeSatWithNonUhfCrossLink.Match toImmutable() { | ||
139 | return isMutable() ? newMatch(fSat) : this; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public String prettyPrint() { | ||
144 | StringBuilder result = new StringBuilder(); | ||
145 | result.append("\"Sat\"=" + prettyPrintValue(fSat)); | ||
146 | return result.toString(); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public int hashCode() { | ||
151 | return Objects.hash(fSat); | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public boolean equals(final Object obj) { | ||
156 | if (this == obj) | ||
157 | return true; | ||
158 | if (obj == null) { | ||
159 | return false; | ||
160 | } | ||
161 | if ((obj instanceof ThreeUCubeSatWithNonUhfCrossLink.Match)) { | ||
162 | ThreeUCubeSatWithNonUhfCrossLink.Match other = (ThreeUCubeSatWithNonUhfCrossLink.Match) obj; | ||
163 | return Objects.equals(fSat, other.fSat); | ||
164 | } else { | ||
165 | // this should be infrequent | ||
166 | if (!(obj instanceof IPatternMatch)) { | ||
167 | return false; | ||
168 | } | ||
169 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
170 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public ThreeUCubeSatWithNonUhfCrossLink specification() { | ||
176 | return ThreeUCubeSatWithNonUhfCrossLink.instance(); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Returns an empty, mutable match. | ||
181 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
182 | * | ||
183 | * @return the empty match. | ||
184 | * | ||
185 | */ | ||
186 | public static ThreeUCubeSatWithNonUhfCrossLink.Match newEmptyMatch() { | ||
187 | return new Mutable(null); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a mutable (partial) match. | ||
192 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
193 | * | ||
194 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
195 | * @return the new, mutable (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static ThreeUCubeSatWithNonUhfCrossLink.Match newMutableMatch(final Spacecraft pSat) { | ||
199 | return new Mutable(pSat); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Returns a new (partial) match. | ||
204 | * This can be used e.g. to call the matcher with a partial match. | ||
205 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
206 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
207 | * @return the (partial) match object. | ||
208 | * | ||
209 | */ | ||
210 | public static ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final Spacecraft pSat) { | ||
211 | return new Immutable(pSat); | ||
212 | } | ||
213 | |||
214 | private static final class Mutable extends ThreeUCubeSatWithNonUhfCrossLink.Match { | ||
215 | Mutable(final Spacecraft pSat) { | ||
216 | super(pSat); | ||
217 | } | ||
218 | |||
219 | @Override | ||
220 | public boolean isMutable() { | ||
221 | return true; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | private static final class Immutable extends ThreeUCubeSatWithNonUhfCrossLink.Match { | ||
226 | Immutable(final Spacecraft pSat) { | ||
227 | super(pSat); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return false; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.threeUCubeSatWithNonUhfCrossLink pattern, | ||
239 | * providing pattern-specific query methods. | ||
240 | * | ||
241 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
242 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
243 | * | ||
244 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
245 | * | ||
246 | * <p>Original source: | ||
247 | * <code><pre> | ||
248 | * // 3U CubeSats are assumed to only be able to downlink to Earth using an X-band trasmitter, | ||
249 | * // but cross-link using UHF | ||
250 | * | ||
251 | * {@literal @}Constraint(severity = "error", key = {Sat}, | ||
252 | * message = "3U CubeSats can only cross-link using UHF.") | ||
253 | * pattern threeUCubeSatWithNonUhfCrossLink(Sat : Spacecraft) { | ||
254 | * Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U); | ||
255 | * CommunicatingElement.commSubsystem(Sat, SourceComm); | ||
256 | * neg find commSubsystemBandUhf(SourceComm); | ||
257 | * DirectedCommunicationLink.source(Link, SourceComm); | ||
258 | * DirectedCommunicationLink.target(Link, TargetComm); | ||
259 | * CommunicatingElement.commSubsystem(Target, TargetComm); | ||
260 | * neg find groundStationNetwork(Target); | ||
261 | * } | ||
262 | * </pre></code> | ||
263 | * | ||
264 | * @see Match | ||
265 | * @see ThreeUCubeSatWithNonUhfCrossLink | ||
266 | * | ||
267 | */ | ||
268 | public static class Matcher extends BaseMatcher<ThreeUCubeSatWithNonUhfCrossLink.Match> { | ||
269 | /** | ||
270 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
271 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
272 | * | ||
273 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
274 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
275 | * | ||
276 | */ | ||
277 | public static ThreeUCubeSatWithNonUhfCrossLink.Matcher on(final ViatraQueryEngine engine) { | ||
278 | // check if matcher already exists | ||
279 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
280 | if (matcher == null) { | ||
281 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
282 | } | ||
283 | return matcher; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
288 | * @return an initialized matcher | ||
289 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
290 | * | ||
291 | */ | ||
292 | public static ThreeUCubeSatWithNonUhfCrossLink.Matcher create() { | ||
293 | return new Matcher(); | ||
294 | } | ||
295 | |||
296 | private static final int POSITION_SAT = 0; | ||
297 | |||
298 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ThreeUCubeSatWithNonUhfCrossLink.Matcher.class); | ||
299 | |||
300 | /** | ||
301 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
302 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
303 | * | ||
304 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
305 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
306 | * | ||
307 | */ | ||
308 | private Matcher() { | ||
309 | super(querySpecification()); | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
314 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
315 | * @return matches represented as a Match object. | ||
316 | * | ||
317 | */ | ||
318 | public Collection<ThreeUCubeSatWithNonUhfCrossLink.Match> getAllMatches(final Spacecraft pSat) { | ||
319 | return rawStreamAllMatches(new Object[]{pSat}).collect(Collectors.toSet()); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
324 | * </p> | ||
325 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
326 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
327 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
328 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
329 | * @return a stream of matches represented as a Match object. | ||
330 | * | ||
331 | */ | ||
332 | public Stream<ThreeUCubeSatWithNonUhfCrossLink.Match> streamAllMatches(final Spacecraft pSat) { | ||
333 | return rawStreamAllMatches(new Object[]{pSat}); | ||
334 | } | ||
335 | |||
336 | /** | ||
337 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
338 | * Neither determinism nor randomness of selection is guaranteed. | ||
339 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
340 | * @return a match represented as a Match object, or null if no match is found. | ||
341 | * | ||
342 | */ | ||
343 | public Optional<ThreeUCubeSatWithNonUhfCrossLink.Match> getOneArbitraryMatch(final Spacecraft pSat) { | ||
344 | return rawGetOneArbitraryMatch(new Object[]{pSat}); | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
349 | * under any possible substitution of the unspecified parameters (if any). | ||
350 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
351 | * @return true if the input is a valid (partial) match of the pattern. | ||
352 | * | ||
353 | */ | ||
354 | public boolean hasMatch(final Spacecraft pSat) { | ||
355 | return rawHasMatch(new Object[]{pSat}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
360 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
361 | * @return the number of pattern matches found. | ||
362 | * | ||
363 | */ | ||
364 | public int countMatches(final Spacecraft pSat) { | ||
365 | return rawCountMatches(new Object[]{pSat}); | ||
366 | } | ||
367 | |||
368 | /** | ||
369 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
370 | * Neither determinism nor randomness of selection is guaranteed. | ||
371 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
372 | * @param processor the action that will process the selected match. | ||
373 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
374 | * | ||
375 | */ | ||
376 | public boolean forOneArbitraryMatch(final Spacecraft pSat, final Consumer<? super ThreeUCubeSatWithNonUhfCrossLink.Match> processor) { | ||
377 | return rawForOneArbitraryMatch(new Object[]{pSat}, processor); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Returns a new (partial) match. | ||
382 | * This can be used e.g. to call the matcher with a partial match. | ||
383 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
384 | * @param pSat the fixed value of pattern parameter Sat, or null if not bound. | ||
385 | * @return the (partial) match object. | ||
386 | * | ||
387 | */ | ||
388 | public ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final Spacecraft pSat) { | ||
389 | return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch(pSat); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for Sat. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | protected Stream<Spacecraft> rawStreamAllValuesOfSat(final Object[] parameters) { | ||
398 | return rawStreamAllValues(POSITION_SAT, parameters).map(Spacecraft.class::cast); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for Sat. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | public Set<Spacecraft> getAllValuesOfSat() { | ||
407 | return rawStreamAllValuesOfSat(emptyArray()).collect(Collectors.toSet()); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * Retrieve the set of values that occur in matches for Sat. | ||
412 | * @return the Set of all values or empty set if there are no matches | ||
413 | * | ||
414 | */ | ||
415 | public Stream<Spacecraft> streamAllValuesOfSat() { | ||
416 | return rawStreamAllValuesOfSat(emptyArray()); | ||
417 | } | ||
418 | |||
419 | @Override | ||
420 | protected ThreeUCubeSatWithNonUhfCrossLink.Match tupleToMatch(final Tuple t) { | ||
421 | try { | ||
422 | return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((Spacecraft) t.get(POSITION_SAT)); | ||
423 | } catch(ClassCastException e) { | ||
424 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
425 | return null; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | @Override | ||
430 | protected ThreeUCubeSatWithNonUhfCrossLink.Match arrayToMatch(final Object[] match) { | ||
431 | try { | ||
432 | return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((Spacecraft) match[POSITION_SAT]); | ||
433 | } catch(ClassCastException e) { | ||
434 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
435 | return null; | ||
436 | } | ||
437 | } | ||
438 | |||
439 | @Override | ||
440 | protected ThreeUCubeSatWithNonUhfCrossLink.Match arrayToMatchMutable(final Object[] match) { | ||
441 | try { | ||
442 | return ThreeUCubeSatWithNonUhfCrossLink.Match.newMutableMatch((Spacecraft) match[POSITION_SAT]); | ||
443 | } catch(ClassCastException e) { | ||
444 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
445 | return null; | ||
446 | } | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * @return the singleton instance of the query specification of this pattern | ||
451 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
452 | * | ||
453 | */ | ||
454 | public static IQuerySpecification<ThreeUCubeSatWithNonUhfCrossLink.Matcher> querySpecification() { | ||
455 | return ThreeUCubeSatWithNonUhfCrossLink.instance(); | ||
456 | } | ||
457 | } | ||
458 | |||
459 | private ThreeUCubeSatWithNonUhfCrossLink() { | ||
460 | super(GeneratedPQuery.INSTANCE); | ||
461 | } | ||
462 | |||
463 | /** | ||
464 | * @return the singleton instance of the query specification | ||
465 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
466 | * | ||
467 | */ | ||
468 | public static ThreeUCubeSatWithNonUhfCrossLink instance() { | ||
469 | try{ | ||
470 | return LazyHolder.INSTANCE; | ||
471 | } catch (ExceptionInInitializerError err) { | ||
472 | throw processInitializerError(err); | ||
473 | } | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | protected ThreeUCubeSatWithNonUhfCrossLink.Matcher instantiate(final ViatraQueryEngine engine) { | ||
478 | return ThreeUCubeSatWithNonUhfCrossLink.Matcher.on(engine); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public ThreeUCubeSatWithNonUhfCrossLink.Matcher instantiate() { | ||
483 | return ThreeUCubeSatWithNonUhfCrossLink.Matcher.create(); | ||
484 | } | ||
485 | |||
486 | @Override | ||
487 | public ThreeUCubeSatWithNonUhfCrossLink.Match newEmptyMatch() { | ||
488 | return ThreeUCubeSatWithNonUhfCrossLink.Match.newEmptyMatch(); | ||
489 | } | ||
490 | |||
491 | @Override | ||
492 | public ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final Object... parameters) { | ||
493 | return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft) parameters[0]); | ||
494 | } | ||
495 | |||
496 | /** | ||
497 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink (visibility: PUBLIC, simpleName: ThreeUCubeSatWithNonUhfCrossLink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
498 | * <b>not</b> at the class load time of the outer class, | ||
499 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink (visibility: PUBLIC, simpleName: ThreeUCubeSatWithNonUhfCrossLink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
500 | * | ||
501 | * <p> This workaround is required e.g. to support recursion. | ||
502 | * | ||
503 | */ | ||
504 | private static class LazyHolder { | ||
505 | private static final ThreeUCubeSatWithNonUhfCrossLink INSTANCE = new ThreeUCubeSatWithNonUhfCrossLink(); | ||
506 | |||
507 | /** | ||
508 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
509 | * This initialization order is required to support indirect recursion. | ||
510 | * | ||
511 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
512 | * | ||
513 | */ | ||
514 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
515 | |||
516 | public static Object ensureInitialized() { | ||
517 | INSTANCE.ensureInitializedInternal(); | ||
518 | return null; | ||
519 | } | ||
520 | } | ||
521 | |||
522 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
523 | private static final ThreeUCubeSatWithNonUhfCrossLink.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
524 | |||
525 | private final PParameter parameter_Sat = new PParameter("Sat", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
526 | |||
527 | private final List<PParameter> parameters = Arrays.asList(parameter_Sat); | ||
528 | |||
529 | private GeneratedPQuery() { | ||
530 | super(PVisibility.PUBLIC); | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public String getFullyQualifiedName() { | ||
535 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.threeUCubeSatWithNonUhfCrossLink"; | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public List<String> getParameterNames() { | ||
540 | return Arrays.asList("Sat"); | ||
541 | } | ||
542 | |||
543 | @Override | ||
544 | public List<PParameter> getParameters() { | ||
545 | return parameters; | ||
546 | } | ||
547 | |||
548 | @Override | ||
549 | public Set<PBody> doGetContainedBodies() { | ||
550 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
551 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
552 | { | ||
553 | PBody body = new PBody(this); | ||
554 | PVariable var_Sat = body.getOrCreateVariableByName("Sat"); | ||
555 | PVariable var_SourceComm = body.getOrCreateVariableByName("SourceComm"); | ||
556 | PVariable var_Link = body.getOrCreateVariableByName("Link"); | ||
557 | PVariable var_TargetComm = body.getOrCreateVariableByName("TargetComm"); | ||
558 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
559 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
560 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
561 | new ExportedParameter(body, var_Sat, parameter_Sat) | ||
562 | )); | ||
563 | // Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U) | ||
564 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
565 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat3U").getInstance()); | ||
566 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
567 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
568 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
569 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
570 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
571 | // CommunicatingElement.commSubsystem(Sat, SourceComm) | ||
572 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
573 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
574 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
575 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
576 | new Equality(body, var__virtual_2_, var_SourceComm); | ||
577 | // neg find commSubsystemBandUhf(SourceComm) | ||
578 | new NegativePatternCall(body, Tuples.flatTupleOf(var_SourceComm), CommSubsystemBandUhf.instance().getInternalQueryRepresentation()); | ||
579 | // DirectedCommunicationLink.source(Link, SourceComm) | ||
580 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
581 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
582 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); | ||
583 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
584 | new Equality(body, var__virtual_3_, var_SourceComm); | ||
585 | // DirectedCommunicationLink.target(Link, TargetComm) | ||
586 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
587 | PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); | ||
588 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); | ||
589 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
590 | new Equality(body, var__virtual_4_, var_TargetComm); | ||
591 | // CommunicatingElement.commSubsystem(Target, TargetComm) | ||
592 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
593 | PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}"); | ||
594 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
595 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
596 | new Equality(body, var__virtual_5_, var_TargetComm); | ||
597 | // neg find groundStationNetwork(Target) | ||
598 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Target), GroundStationNetwork.instance().getInternalQueryRepresentation()); | ||
599 | bodies.add(body); | ||
600 | } | ||
601 | { | ||
602 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
603 | annotation.addAttribute("severity", "error"); | ||
604 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
605 | new ParameterReference("Sat") | ||
606 | })); | ||
607 | annotation.addAttribute("message", "3U CubeSats can only cross-link using UHF."); | ||
608 | addAnnotation(annotation); | ||
609 | } | ||
610 | return bodies; | ||
611 | } | ||
612 | } | ||
613 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java new file mode 100644 index 00000000..45d4cc35 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java | |||
@@ -0,0 +1,544 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * // Time | ||
47 | * | ||
48 | * pattern timeMetric(Time : java Double) { | ||
49 | * Time == sum find missionTime(_, #_); | ||
50 | * } | ||
51 | * </pre></code> | ||
52 | * | ||
53 | * @see Matcher | ||
54 | * @see Match | ||
55 | * | ||
56 | */ | ||
57 | @SuppressWarnings("all") | ||
58 | public final class TimeMetric extends BaseGeneratedEMFQuerySpecification<TimeMetric.Matcher> { | ||
59 | /** | ||
60 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric pattern, | ||
61 | * to be used in conjunction with {@link Matcher}. | ||
62 | * | ||
63 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
64 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
65 | * usable to represent a match of the pattern in the result of a query, | ||
66 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
67 | * | ||
68 | * @see Matcher | ||
69 | * | ||
70 | */ | ||
71 | public static abstract class Match extends BasePatternMatch { | ||
72 | private Double fTime; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("Time"); | ||
75 | |||
76 | private Match(final Double pTime) { | ||
77 | this.fTime = pTime; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | if ("Time".equals(parameterName)) return this.fTime; | ||
83 | return null; | ||
84 | } | ||
85 | |||
86 | public Double getTime() { | ||
87 | return this.fTime; | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public boolean set(final String parameterName, final Object newValue) { | ||
92 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
93 | if ("Time".equals(parameterName) ) { | ||
94 | this.fTime = (Double) newValue; | ||
95 | return true; | ||
96 | } | ||
97 | return false; | ||
98 | } | ||
99 | |||
100 | public void setTime(final Double pTime) { | ||
101 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
102 | this.fTime = pTime; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String patternName() { | ||
107 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<String> parameterNames() { | ||
112 | return TimeMetric.Match.parameterNames; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Object[] toArray() { | ||
117 | return new Object[]{fTime}; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public TimeMetric.Match toImmutable() { | ||
122 | return isMutable() ? newMatch(fTime) : this; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public String prettyPrint() { | ||
127 | StringBuilder result = new StringBuilder(); | ||
128 | result.append("\"Time\"=" + prettyPrintValue(fTime)); | ||
129 | return result.toString(); | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public int hashCode() { | ||
134 | return Objects.hash(fTime); | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public boolean equals(final Object obj) { | ||
139 | if (this == obj) | ||
140 | return true; | ||
141 | if (obj == null) { | ||
142 | return false; | ||
143 | } | ||
144 | if ((obj instanceof TimeMetric.Match)) { | ||
145 | TimeMetric.Match other = (TimeMetric.Match) obj; | ||
146 | return Objects.equals(fTime, other.fTime); | ||
147 | } else { | ||
148 | // this should be infrequent | ||
149 | if (!(obj instanceof IPatternMatch)) { | ||
150 | return false; | ||
151 | } | ||
152 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
153 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public TimeMetric specification() { | ||
159 | return TimeMetric.instance(); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * Returns an empty, mutable match. | ||
164 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
165 | * | ||
166 | * @return the empty match. | ||
167 | * | ||
168 | */ | ||
169 | public static TimeMetric.Match newEmptyMatch() { | ||
170 | return new Mutable(null); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns a mutable (partial) match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
178 | * @return the new, mutable (partial) match object. | ||
179 | * | ||
180 | */ | ||
181 | public static TimeMetric.Match newMutableMatch(final Double pTime) { | ||
182 | return new Mutable(pTime); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * Returns a new (partial) match. | ||
187 | * This can be used e.g. to call the matcher with a partial match. | ||
188 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
189 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
190 | * @return the (partial) match object. | ||
191 | * | ||
192 | */ | ||
193 | public static TimeMetric.Match newMatch(final Double pTime) { | ||
194 | return new Immutable(pTime); | ||
195 | } | ||
196 | |||
197 | private static final class Mutable extends TimeMetric.Match { | ||
198 | Mutable(final Double pTime) { | ||
199 | super(pTime); | ||
200 | } | ||
201 | |||
202 | @Override | ||
203 | public boolean isMutable() { | ||
204 | return true; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | private static final class Immutable extends TimeMetric.Match { | ||
209 | Immutable(final Double pTime) { | ||
210 | super(pTime); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return false; | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | |||
220 | /** | ||
221 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric pattern, | ||
222 | * providing pattern-specific query methods. | ||
223 | * | ||
224 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
225 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
226 | * | ||
227 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
228 | * | ||
229 | * <p>Original source: | ||
230 | * <code><pre> | ||
231 | * // Time | ||
232 | * | ||
233 | * pattern timeMetric(Time : java Double) { | ||
234 | * Time == sum find missionTime(_, #_); | ||
235 | * } | ||
236 | * </pre></code> | ||
237 | * | ||
238 | * @see Match | ||
239 | * @see TimeMetric | ||
240 | * | ||
241 | */ | ||
242 | public static class Matcher extends BaseMatcher<TimeMetric.Match> { | ||
243 | /** | ||
244 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
245 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
246 | * | ||
247 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
248 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
249 | * | ||
250 | */ | ||
251 | public static TimeMetric.Matcher on(final ViatraQueryEngine engine) { | ||
252 | // check if matcher already exists | ||
253 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
254 | if (matcher == null) { | ||
255 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
256 | } | ||
257 | return matcher; | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
262 | * @return an initialized matcher | ||
263 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
264 | * | ||
265 | */ | ||
266 | public static TimeMetric.Matcher create() { | ||
267 | return new Matcher(); | ||
268 | } | ||
269 | |||
270 | private static final int POSITION_TIME = 0; | ||
271 | |||
272 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TimeMetric.Matcher.class); | ||
273 | |||
274 | /** | ||
275 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
276 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
277 | * | ||
278 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
279 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
280 | * | ||
281 | */ | ||
282 | private Matcher() { | ||
283 | super(querySpecification()); | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
288 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
289 | * @return matches represented as a Match object. | ||
290 | * | ||
291 | */ | ||
292 | public Collection<TimeMetric.Match> getAllMatches(final Double pTime) { | ||
293 | return rawStreamAllMatches(new Object[]{pTime}).collect(Collectors.toSet()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * </p> | ||
299 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
300 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
301 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
302 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
303 | * @return a stream of matches represented as a Match object. | ||
304 | * | ||
305 | */ | ||
306 | public Stream<TimeMetric.Match> streamAllMatches(final Double pTime) { | ||
307 | return rawStreamAllMatches(new Object[]{pTime}); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
312 | * Neither determinism nor randomness of selection is guaranteed. | ||
313 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
314 | * @return a match represented as a Match object, or null if no match is found. | ||
315 | * | ||
316 | */ | ||
317 | public Optional<TimeMetric.Match> getOneArbitraryMatch(final Double pTime) { | ||
318 | return rawGetOneArbitraryMatch(new Object[]{pTime}); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
323 | * under any possible substitution of the unspecified parameters (if any). | ||
324 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
325 | * @return true if the input is a valid (partial) match of the pattern. | ||
326 | * | ||
327 | */ | ||
328 | public boolean hasMatch(final Double pTime) { | ||
329 | return rawHasMatch(new Object[]{pTime}); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
334 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
335 | * @return the number of pattern matches found. | ||
336 | * | ||
337 | */ | ||
338 | public int countMatches(final Double pTime) { | ||
339 | return rawCountMatches(new Object[]{pTime}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
344 | * Neither determinism nor randomness of selection is guaranteed. | ||
345 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
346 | * @param processor the action that will process the selected match. | ||
347 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
348 | * | ||
349 | */ | ||
350 | public boolean forOneArbitraryMatch(final Double pTime, final Consumer<? super TimeMetric.Match> processor) { | ||
351 | return rawForOneArbitraryMatch(new Object[]{pTime}, processor); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Returns a new (partial) match. | ||
356 | * This can be used e.g. to call the matcher with a partial match. | ||
357 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
358 | * @param pTime the fixed value of pattern parameter Time, or null if not bound. | ||
359 | * @return the (partial) match object. | ||
360 | * | ||
361 | */ | ||
362 | public TimeMetric.Match newMatch(final Double pTime) { | ||
363 | return TimeMetric.Match.newMatch(pTime); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Retrieve the set of values that occur in matches for Time. | ||
368 | * @return the Set of all values or empty set if there are no matches | ||
369 | * | ||
370 | */ | ||
371 | protected Stream<Double> rawStreamAllValuesOfTime(final Object[] parameters) { | ||
372 | return rawStreamAllValues(POSITION_TIME, parameters).map(Double.class::cast); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Retrieve the set of values that occur in matches for Time. | ||
377 | * @return the Set of all values or empty set if there are no matches | ||
378 | * | ||
379 | */ | ||
380 | public Set<Double> getAllValuesOfTime() { | ||
381 | return rawStreamAllValuesOfTime(emptyArray()).collect(Collectors.toSet()); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for Time. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | public Stream<Double> streamAllValuesOfTime() { | ||
390 | return rawStreamAllValuesOfTime(emptyArray()); | ||
391 | } | ||
392 | |||
393 | @Override | ||
394 | protected TimeMetric.Match tupleToMatch(final Tuple t) { | ||
395 | try { | ||
396 | return TimeMetric.Match.newMatch((Double) t.get(POSITION_TIME)); | ||
397 | } catch(ClassCastException e) { | ||
398 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
399 | return null; | ||
400 | } | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected TimeMetric.Match arrayToMatch(final Object[] match) { | ||
405 | try { | ||
406 | return TimeMetric.Match.newMatch((Double) match[POSITION_TIME]); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected TimeMetric.Match arrayToMatchMutable(final Object[] match) { | ||
415 | try { | ||
416 | return TimeMetric.Match.newMutableMatch((Double) match[POSITION_TIME]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * @return the singleton instance of the query specification of this pattern | ||
425 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
426 | * | ||
427 | */ | ||
428 | public static IQuerySpecification<TimeMetric.Matcher> querySpecification() { | ||
429 | return TimeMetric.instance(); | ||
430 | } | ||
431 | } | ||
432 | |||
433 | private TimeMetric() { | ||
434 | super(GeneratedPQuery.INSTANCE); | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * @return the singleton instance of the query specification | ||
439 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
440 | * | ||
441 | */ | ||
442 | public static TimeMetric instance() { | ||
443 | try{ | ||
444 | return LazyHolder.INSTANCE; | ||
445 | } catch (ExceptionInInitializerError err) { | ||
446 | throw processInitializerError(err); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | @Override | ||
451 | protected TimeMetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
452 | return TimeMetric.Matcher.on(engine); | ||
453 | } | ||
454 | |||
455 | @Override | ||
456 | public TimeMetric.Matcher instantiate() { | ||
457 | return TimeMetric.Matcher.create(); | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | public TimeMetric.Match newEmptyMatch() { | ||
462 | return TimeMetric.Match.newEmptyMatch(); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public TimeMetric.Match newMatch(final Object... parameters) { | ||
467 | return TimeMetric.Match.newMatch((java.lang.Double) parameters[0]); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric (visibility: PUBLIC, simpleName: TimeMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
472 | * <b>not</b> at the class load time of the outer class, | ||
473 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric (visibility: PUBLIC, simpleName: TimeMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
474 | * | ||
475 | * <p> This workaround is required e.g. to support recursion. | ||
476 | * | ||
477 | */ | ||
478 | private static class LazyHolder { | ||
479 | private static final TimeMetric INSTANCE = new TimeMetric(); | ||
480 | |||
481 | /** | ||
482 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
483 | * This initialization order is required to support indirect recursion. | ||
484 | * | ||
485 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
486 | * | ||
487 | */ | ||
488 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
489 | |||
490 | public static Object ensureInitialized() { | ||
491 | INSTANCE.ensureInitializedInternal(); | ||
492 | return null; | ||
493 | } | ||
494 | } | ||
495 | |||
496 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
497 | private static final TimeMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
498 | |||
499 | private final PParameter parameter_Time = new PParameter("Time", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
500 | |||
501 | private final List<PParameter> parameters = Arrays.asList(parameter_Time); | ||
502 | |||
503 | private GeneratedPQuery() { | ||
504 | super(PVisibility.PUBLIC); | ||
505 | } | ||
506 | |||
507 | @Override | ||
508 | public String getFullyQualifiedName() { | ||
509 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric"; | ||
510 | } | ||
511 | |||
512 | @Override | ||
513 | public List<String> getParameterNames() { | ||
514 | return Arrays.asList("Time"); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public List<PParameter> getParameters() { | ||
519 | return parameters; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public Set<PBody> doGetContainedBodies() { | ||
524 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
525 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
526 | { | ||
527 | PBody body = new PBody(this); | ||
528 | PVariable var_Time = body.getOrCreateVariableByName("Time"); | ||
529 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
530 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
531 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Time), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
532 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
533 | new ExportedParameter(body, var_Time, parameter_Time) | ||
534 | )); | ||
535 | // Time == sum find missionTime(_, #_) | ||
536 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
537 | new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), MissionTime.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); | ||
538 | new Equality(body, var_Time, var__virtual_0_); | ||
539 | bodies.add(body); | ||
540 | } | ||
541 | return bodies; | ||
542 | } | ||
543 | } | ||
544 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/UhfAntennaGainNotLow.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/UhfAntennaGainNotLow.java new file mode 100644 index 00000000..62222ded --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/UhfAntennaGainNotLow.java | |||
@@ -0,0 +1,576 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainLow; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EDataType; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
46 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
47 | |||
48 | /** | ||
49 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
50 | * | ||
51 | * <p>Original source: | ||
52 | * <code><pre> | ||
53 | * // UHF-band transmitters may only be combined with a low gain antenna | ||
54 | * | ||
55 | * {@literal @}Constraint(severity = "error", key = {Comm}, | ||
56 | * message = "UHF transceiver must be combined with a low gain antenna.") | ||
57 | * pattern uhfAntennaGainNotLow(Comm : CommSubsystem) { | ||
58 | * CommSubsystem.band(Comm, TransceiverBand::UHF); | ||
59 | * // VIATRA will fail to infer a type constraint for the virtual variable introduced | ||
60 | * // when an enum literal appears in a negative pattern call, so we use a helper pattern | ||
61 | * // instead of neg find commSubsystemGain(Comm, AntennaGain::LOW); | ||
62 | * neg find commSubsystemGainLow(Comm); | ||
63 | * } | ||
64 | * </pre></code> | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * @see Match | ||
68 | * | ||
69 | */ | ||
70 | @SuppressWarnings("all") | ||
71 | public final class UhfAntennaGainNotLow extends BaseGeneratedEMFQuerySpecification<UhfAntennaGainNotLow.Matcher> { | ||
72 | /** | ||
73 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.uhfAntennaGainNotLow pattern, | ||
74 | * to be used in conjunction with {@link Matcher}. | ||
75 | * | ||
76 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
77 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
78 | * usable to represent a match of the pattern in the result of a query, | ||
79 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
80 | * | ||
81 | * @see Matcher | ||
82 | * | ||
83 | */ | ||
84 | public static abstract class Match extends BasePatternMatch { | ||
85 | private CommSubsystem fComm; | ||
86 | |||
87 | private static List<String> parameterNames = makeImmutableList("Comm"); | ||
88 | |||
89 | private Match(final CommSubsystem pComm) { | ||
90 | this.fComm = pComm; | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final String parameterName) { | ||
95 | if ("Comm".equals(parameterName)) return this.fComm; | ||
96 | return null; | ||
97 | } | ||
98 | |||
99 | public CommSubsystem getComm() { | ||
100 | return this.fComm; | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public boolean set(final String parameterName, final Object newValue) { | ||
105 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
106 | if ("Comm".equals(parameterName) ) { | ||
107 | this.fComm = (CommSubsystem) newValue; | ||
108 | return true; | ||
109 | } | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | public void setComm(final CommSubsystem pComm) { | ||
114 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
115 | this.fComm = pComm; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public String patternName() { | ||
120 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.uhfAntennaGainNotLow"; | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public List<String> parameterNames() { | ||
125 | return UhfAntennaGainNotLow.Match.parameterNames; | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public Object[] toArray() { | ||
130 | return new Object[]{fComm}; | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public UhfAntennaGainNotLow.Match toImmutable() { | ||
135 | return isMutable() ? newMatch(fComm) : this; | ||
136 | } | ||
137 | |||
138 | @Override | ||
139 | public String prettyPrint() { | ||
140 | StringBuilder result = new StringBuilder(); | ||
141 | result.append("\"Comm\"=" + prettyPrintValue(fComm)); | ||
142 | return result.toString(); | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public int hashCode() { | ||
147 | return Objects.hash(fComm); | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public boolean equals(final Object obj) { | ||
152 | if (this == obj) | ||
153 | return true; | ||
154 | if (obj == null) { | ||
155 | return false; | ||
156 | } | ||
157 | if ((obj instanceof UhfAntennaGainNotLow.Match)) { | ||
158 | UhfAntennaGainNotLow.Match other = (UhfAntennaGainNotLow.Match) obj; | ||
159 | return Objects.equals(fComm, other.fComm); | ||
160 | } else { | ||
161 | // this should be infrequent | ||
162 | if (!(obj instanceof IPatternMatch)) { | ||
163 | return false; | ||
164 | } | ||
165 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
166 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public UhfAntennaGainNotLow specification() { | ||
172 | return UhfAntennaGainNotLow.instance(); | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * Returns an empty, mutable match. | ||
177 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
178 | * | ||
179 | * @return the empty match. | ||
180 | * | ||
181 | */ | ||
182 | public static UhfAntennaGainNotLow.Match newEmptyMatch() { | ||
183 | return new Mutable(null); | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * Returns a mutable (partial) match. | ||
188 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
189 | * | ||
190 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
191 | * @return the new, mutable (partial) match object. | ||
192 | * | ||
193 | */ | ||
194 | public static UhfAntennaGainNotLow.Match newMutableMatch(final CommSubsystem pComm) { | ||
195 | return new Mutable(pComm); | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * Returns a new (partial) match. | ||
200 | * This can be used e.g. to call the matcher with a partial match. | ||
201 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
202 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
203 | * @return the (partial) match object. | ||
204 | * | ||
205 | */ | ||
206 | public static UhfAntennaGainNotLow.Match newMatch(final CommSubsystem pComm) { | ||
207 | return new Immutable(pComm); | ||
208 | } | ||
209 | |||
210 | private static final class Mutable extends UhfAntennaGainNotLow.Match { | ||
211 | Mutable(final CommSubsystem pComm) { | ||
212 | super(pComm); | ||
213 | } | ||
214 | |||
215 | @Override | ||
216 | public boolean isMutable() { | ||
217 | return true; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | private static final class Immutable extends UhfAntennaGainNotLow.Match { | ||
222 | Immutable(final CommSubsystem pComm) { | ||
223 | super(pComm); | ||
224 | } | ||
225 | |||
226 | @Override | ||
227 | public boolean isMutable() { | ||
228 | return false; | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.uhfAntennaGainNotLow pattern, | ||
235 | * providing pattern-specific query methods. | ||
236 | * | ||
237 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
238 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
239 | * | ||
240 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
241 | * | ||
242 | * <p>Original source: | ||
243 | * <code><pre> | ||
244 | * // UHF-band transmitters may only be combined with a low gain antenna | ||
245 | * | ||
246 | * {@literal @}Constraint(severity = "error", key = {Comm}, | ||
247 | * message = "UHF transceiver must be combined with a low gain antenna.") | ||
248 | * pattern uhfAntennaGainNotLow(Comm : CommSubsystem) { | ||
249 | * CommSubsystem.band(Comm, TransceiverBand::UHF); | ||
250 | * // VIATRA will fail to infer a type constraint for the virtual variable introduced | ||
251 | * // when an enum literal appears in a negative pattern call, so we use a helper pattern | ||
252 | * // instead of neg find commSubsystemGain(Comm, AntennaGain::LOW); | ||
253 | * neg find commSubsystemGainLow(Comm); | ||
254 | * } | ||
255 | * </pre></code> | ||
256 | * | ||
257 | * @see Match | ||
258 | * @see UhfAntennaGainNotLow | ||
259 | * | ||
260 | */ | ||
261 | public static class Matcher extends BaseMatcher<UhfAntennaGainNotLow.Match> { | ||
262 | /** | ||
263 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
264 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
265 | * | ||
266 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
267 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
268 | * | ||
269 | */ | ||
270 | public static UhfAntennaGainNotLow.Matcher on(final ViatraQueryEngine engine) { | ||
271 | // check if matcher already exists | ||
272 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
273 | if (matcher == null) { | ||
274 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
275 | } | ||
276 | return matcher; | ||
277 | } | ||
278 | |||
279 | /** | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * @return an initialized matcher | ||
282 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
283 | * | ||
284 | */ | ||
285 | public static UhfAntennaGainNotLow.Matcher create() { | ||
286 | return new Matcher(); | ||
287 | } | ||
288 | |||
289 | private static final int POSITION_COMM = 0; | ||
290 | |||
291 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(UhfAntennaGainNotLow.Matcher.class); | ||
292 | |||
293 | /** | ||
294 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
295 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
296 | * | ||
297 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
298 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
299 | * | ||
300 | */ | ||
301 | private Matcher() { | ||
302 | super(querySpecification()); | ||
303 | } | ||
304 | |||
305 | /** | ||
306 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
307 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
308 | * @return matches represented as a Match object. | ||
309 | * | ||
310 | */ | ||
311 | public Collection<UhfAntennaGainNotLow.Match> getAllMatches(final CommSubsystem pComm) { | ||
312 | return rawStreamAllMatches(new Object[]{pComm}).collect(Collectors.toSet()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * </p> | ||
318 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
319 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
320 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
321 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
322 | * @return a stream of matches represented as a Match object. | ||
323 | * | ||
324 | */ | ||
325 | public Stream<UhfAntennaGainNotLow.Match> streamAllMatches(final CommSubsystem pComm) { | ||
326 | return rawStreamAllMatches(new Object[]{pComm}); | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
331 | * Neither determinism nor randomness of selection is guaranteed. | ||
332 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
333 | * @return a match represented as a Match object, or null if no match is found. | ||
334 | * | ||
335 | */ | ||
336 | public Optional<UhfAntennaGainNotLow.Match> getOneArbitraryMatch(final CommSubsystem pComm) { | ||
337 | return rawGetOneArbitraryMatch(new Object[]{pComm}); | ||
338 | } | ||
339 | |||
340 | /** | ||
341 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
342 | * under any possible substitution of the unspecified parameters (if any). | ||
343 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
344 | * @return true if the input is a valid (partial) match of the pattern. | ||
345 | * | ||
346 | */ | ||
347 | public boolean hasMatch(final CommSubsystem pComm) { | ||
348 | return rawHasMatch(new Object[]{pComm}); | ||
349 | } | ||
350 | |||
351 | /** | ||
352 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
353 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
354 | * @return the number of pattern matches found. | ||
355 | * | ||
356 | */ | ||
357 | public int countMatches(final CommSubsystem pComm) { | ||
358 | return rawCountMatches(new Object[]{pComm}); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
363 | * Neither determinism nor randomness of selection is guaranteed. | ||
364 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
365 | * @param processor the action that will process the selected match. | ||
366 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
367 | * | ||
368 | */ | ||
369 | public boolean forOneArbitraryMatch(final CommSubsystem pComm, final Consumer<? super UhfAntennaGainNotLow.Match> processor) { | ||
370 | return rawForOneArbitraryMatch(new Object[]{pComm}, processor); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * Returns a new (partial) match. | ||
375 | * This can be used e.g. to call the matcher with a partial match. | ||
376 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
377 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
378 | * @return the (partial) match object. | ||
379 | * | ||
380 | */ | ||
381 | public UhfAntennaGainNotLow.Match newMatch(final CommSubsystem pComm) { | ||
382 | return UhfAntennaGainNotLow.Match.newMatch(pComm); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for Comm. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | protected Stream<CommSubsystem> rawStreamAllValuesOfComm(final Object[] parameters) { | ||
391 | return rawStreamAllValues(POSITION_COMM, parameters).map(CommSubsystem.class::cast); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for Comm. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Set<CommSubsystem> getAllValuesOfComm() { | ||
400 | return rawStreamAllValuesOfComm(emptyArray()).collect(Collectors.toSet()); | ||
401 | } | ||
402 | |||
403 | /** | ||
404 | * Retrieve the set of values that occur in matches for Comm. | ||
405 | * @return the Set of all values or empty set if there are no matches | ||
406 | * | ||
407 | */ | ||
408 | public Stream<CommSubsystem> streamAllValuesOfComm() { | ||
409 | return rawStreamAllValuesOfComm(emptyArray()); | ||
410 | } | ||
411 | |||
412 | @Override | ||
413 | protected UhfAntennaGainNotLow.Match tupleToMatch(final Tuple t) { | ||
414 | try { | ||
415 | return UhfAntennaGainNotLow.Match.newMatch((CommSubsystem) t.get(POSITION_COMM)); | ||
416 | } catch(ClassCastException e) { | ||
417 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
418 | return null; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | @Override | ||
423 | protected UhfAntennaGainNotLow.Match arrayToMatch(final Object[] match) { | ||
424 | try { | ||
425 | return UhfAntennaGainNotLow.Match.newMatch((CommSubsystem) match[POSITION_COMM]); | ||
426 | } catch(ClassCastException e) { | ||
427 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
428 | return null; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | @Override | ||
433 | protected UhfAntennaGainNotLow.Match arrayToMatchMutable(final Object[] match) { | ||
434 | try { | ||
435 | return UhfAntennaGainNotLow.Match.newMutableMatch((CommSubsystem) match[POSITION_COMM]); | ||
436 | } catch(ClassCastException e) { | ||
437 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
438 | return null; | ||
439 | } | ||
440 | } | ||
441 | |||
442 | /** | ||
443 | * @return the singleton instance of the query specification of this pattern | ||
444 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
445 | * | ||
446 | */ | ||
447 | public static IQuerySpecification<UhfAntennaGainNotLow.Matcher> querySpecification() { | ||
448 | return UhfAntennaGainNotLow.instance(); | ||
449 | } | ||
450 | } | ||
451 | |||
452 | private UhfAntennaGainNotLow() { | ||
453 | super(GeneratedPQuery.INSTANCE); | ||
454 | } | ||
455 | |||
456 | /** | ||
457 | * @return the singleton instance of the query specification | ||
458 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
459 | * | ||
460 | */ | ||
461 | public static UhfAntennaGainNotLow instance() { | ||
462 | try{ | ||
463 | return LazyHolder.INSTANCE; | ||
464 | } catch (ExceptionInInitializerError err) { | ||
465 | throw processInitializerError(err); | ||
466 | } | ||
467 | } | ||
468 | |||
469 | @Override | ||
470 | protected UhfAntennaGainNotLow.Matcher instantiate(final ViatraQueryEngine engine) { | ||
471 | return UhfAntennaGainNotLow.Matcher.on(engine); | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | public UhfAntennaGainNotLow.Matcher instantiate() { | ||
476 | return UhfAntennaGainNotLow.Matcher.create(); | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | public UhfAntennaGainNotLow.Match newEmptyMatch() { | ||
481 | return UhfAntennaGainNotLow.Match.newEmptyMatch(); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public UhfAntennaGainNotLow.Match newMatch(final Object... parameters) { | ||
486 | return UhfAntennaGainNotLow.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem) parameters[0]); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow (visibility: PUBLIC, simpleName: UhfAntennaGainNotLow, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
491 | * <b>not</b> at the class load time of the outer class, | ||
492 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow (visibility: PUBLIC, simpleName: UhfAntennaGainNotLow, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
493 | * | ||
494 | * <p> This workaround is required e.g. to support recursion. | ||
495 | * | ||
496 | */ | ||
497 | private static class LazyHolder { | ||
498 | private static final UhfAntennaGainNotLow INSTANCE = new UhfAntennaGainNotLow(); | ||
499 | |||
500 | /** | ||
501 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
502 | * This initialization order is required to support indirect recursion. | ||
503 | * | ||
504 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
505 | * | ||
506 | */ | ||
507 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
508 | |||
509 | public static Object ensureInitialized() { | ||
510 | INSTANCE.ensureInitializedInternal(); | ||
511 | return null; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
516 | private static final UhfAntennaGainNotLow.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
517 | |||
518 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
519 | |||
520 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm); | ||
521 | |||
522 | private GeneratedPQuery() { | ||
523 | super(PVisibility.PUBLIC); | ||
524 | } | ||
525 | |||
526 | @Override | ||
527 | public String getFullyQualifiedName() { | ||
528 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.uhfAntennaGainNotLow"; | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public List<String> getParameterNames() { | ||
533 | return Arrays.asList("Comm"); | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public List<PParameter> getParameters() { | ||
538 | return parameters; | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public Set<PBody> doGetContainedBodies() { | ||
543 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
544 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
545 | { | ||
546 | PBody body = new PBody(this); | ||
547 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
548 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
549 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
550 | new ExportedParameter(body, var_Comm, parameter_Comm) | ||
551 | )); | ||
552 | // CommSubsystem.band(Comm, TransceiverBand::UHF) | ||
553 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
554 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "UHF").getInstance()); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
556 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
557 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
559 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
560 | // // VIATRA will fail to infer a type constraint for the virtual variable introduced // when an enum literal appears in a negative pattern call, so we use a helper pattern // instead of neg find commSubsystemGain(Comm, AntennaGain::LOW); neg find commSubsystemGainLow(Comm) | ||
561 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Comm), CommSubsystemGainLow.instance().getInternalQueryRepresentation()); | ||
562 | bodies.add(body); | ||
563 | } | ||
564 | { | ||
565 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
566 | annotation.addAttribute("severity", "error"); | ||
567 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
568 | new ParameterReference("Comm") | ||
569 | })); | ||
570 | annotation.addAttribute("message", "UHF transceiver must be combined with a low gain antenna."); | ||
571 | addAnnotation(annotation); | ||
572 | } | ||
573 | return bodies; | ||
574 | } | ||
575 | } | ||
576 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/XAntennaGainNotMedium.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/XAntennaGainNotMedium.java new file mode 100644 index 00000000..dbe6d26e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/XAntennaGainNotMedium.java | |||
@@ -0,0 +1,570 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Objects; | ||
13 | import java.util.Optional; | ||
14 | import java.util.Set; | ||
15 | import java.util.function.Consumer; | ||
16 | import java.util.stream.Collectors; | ||
17 | import java.util.stream.Stream; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.emf.ecore.EDataType; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
30 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
45 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
46 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
47 | |||
48 | /** | ||
49 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
50 | * | ||
51 | * <p>Original source: | ||
52 | * <code><pre> | ||
53 | * // X-band transmitters may only be combined with a medium gain antenna | ||
54 | * | ||
55 | * {@literal @}Constraint(severity = "error", key = {Comm}, | ||
56 | * message = "X-band transceiver must be combined with a medium gain antenna.") | ||
57 | * pattern xAntennaGainNotMedium(Comm : CommSubsystem) { | ||
58 | * CommSubsystem.band(Comm, TransceiverBand::X); | ||
59 | * neg find commSubsystemGainMedium(Comm); | ||
60 | * } | ||
61 | * </pre></code> | ||
62 | * | ||
63 | * @see Matcher | ||
64 | * @see Match | ||
65 | * | ||
66 | */ | ||
67 | @SuppressWarnings("all") | ||
68 | public final class XAntennaGainNotMedium extends BaseGeneratedEMFQuerySpecification<XAntennaGainNotMedium.Matcher> { | ||
69 | /** | ||
70 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.xAntennaGainNotMedium pattern, | ||
71 | * to be used in conjunction with {@link Matcher}. | ||
72 | * | ||
73 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
74 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
75 | * usable to represent a match of the pattern in the result of a query, | ||
76 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
77 | * | ||
78 | * @see Matcher | ||
79 | * | ||
80 | */ | ||
81 | public static abstract class Match extends BasePatternMatch { | ||
82 | private CommSubsystem fComm; | ||
83 | |||
84 | private static List<String> parameterNames = makeImmutableList("Comm"); | ||
85 | |||
86 | private Match(final CommSubsystem pComm) { | ||
87 | this.fComm = pComm; | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final String parameterName) { | ||
92 | if ("Comm".equals(parameterName)) return this.fComm; | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | public CommSubsystem getComm() { | ||
97 | return this.fComm; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public boolean set(final String parameterName, final Object newValue) { | ||
102 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
103 | if ("Comm".equals(parameterName) ) { | ||
104 | this.fComm = (CommSubsystem) newValue; | ||
105 | return true; | ||
106 | } | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public void setComm(final CommSubsystem pComm) { | ||
111 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
112 | this.fComm = pComm; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public String patternName() { | ||
117 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.xAntennaGainNotMedium"; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<String> parameterNames() { | ||
122 | return XAntennaGainNotMedium.Match.parameterNames; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Object[] toArray() { | ||
127 | return new Object[]{fComm}; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public XAntennaGainNotMedium.Match toImmutable() { | ||
132 | return isMutable() ? newMatch(fComm) : this; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String prettyPrint() { | ||
137 | StringBuilder result = new StringBuilder(); | ||
138 | result.append("\"Comm\"=" + prettyPrintValue(fComm)); | ||
139 | return result.toString(); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public int hashCode() { | ||
144 | return Objects.hash(fComm); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public boolean equals(final Object obj) { | ||
149 | if (this == obj) | ||
150 | return true; | ||
151 | if (obj == null) { | ||
152 | return false; | ||
153 | } | ||
154 | if ((obj instanceof XAntennaGainNotMedium.Match)) { | ||
155 | XAntennaGainNotMedium.Match other = (XAntennaGainNotMedium.Match) obj; | ||
156 | return Objects.equals(fComm, other.fComm); | ||
157 | } else { | ||
158 | // this should be infrequent | ||
159 | if (!(obj instanceof IPatternMatch)) { | ||
160 | return false; | ||
161 | } | ||
162 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
163 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public XAntennaGainNotMedium specification() { | ||
169 | return XAntennaGainNotMedium.instance(); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Returns an empty, mutable match. | ||
174 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
175 | * | ||
176 | * @return the empty match. | ||
177 | * | ||
178 | */ | ||
179 | public static XAntennaGainNotMedium.Match newEmptyMatch() { | ||
180 | return new Mutable(null); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns a mutable (partial) match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
188 | * @return the new, mutable (partial) match object. | ||
189 | * | ||
190 | */ | ||
191 | public static XAntennaGainNotMedium.Match newMutableMatch(final CommSubsystem pComm) { | ||
192 | return new Mutable(pComm); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns a new (partial) match. | ||
197 | * This can be used e.g. to call the matcher with a partial match. | ||
198 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
199 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
200 | * @return the (partial) match object. | ||
201 | * | ||
202 | */ | ||
203 | public static XAntennaGainNotMedium.Match newMatch(final CommSubsystem pComm) { | ||
204 | return new Immutable(pComm); | ||
205 | } | ||
206 | |||
207 | private static final class Mutable extends XAntennaGainNotMedium.Match { | ||
208 | Mutable(final CommSubsystem pComm) { | ||
209 | super(pComm); | ||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public boolean isMutable() { | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | private static final class Immutable extends XAntennaGainNotMedium.Match { | ||
219 | Immutable(final CommSubsystem pComm) { | ||
220 | super(pComm); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.xAntennaGainNotMedium pattern, | ||
232 | * providing pattern-specific query methods. | ||
233 | * | ||
234 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
235 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
236 | * | ||
237 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
238 | * | ||
239 | * <p>Original source: | ||
240 | * <code><pre> | ||
241 | * // X-band transmitters may only be combined with a medium gain antenna | ||
242 | * | ||
243 | * {@literal @}Constraint(severity = "error", key = {Comm}, | ||
244 | * message = "X-band transceiver must be combined with a medium gain antenna.") | ||
245 | * pattern xAntennaGainNotMedium(Comm : CommSubsystem) { | ||
246 | * CommSubsystem.band(Comm, TransceiverBand::X); | ||
247 | * neg find commSubsystemGainMedium(Comm); | ||
248 | * } | ||
249 | * </pre></code> | ||
250 | * | ||
251 | * @see Match | ||
252 | * @see XAntennaGainNotMedium | ||
253 | * | ||
254 | */ | ||
255 | public static class Matcher extends BaseMatcher<XAntennaGainNotMedium.Match> { | ||
256 | /** | ||
257 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
258 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
259 | * | ||
260 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
261 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
262 | * | ||
263 | */ | ||
264 | public static XAntennaGainNotMedium.Matcher on(final ViatraQueryEngine engine) { | ||
265 | // check if matcher already exists | ||
266 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
267 | if (matcher == null) { | ||
268 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
269 | } | ||
270 | return matcher; | ||
271 | } | ||
272 | |||
273 | /** | ||
274 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
275 | * @return an initialized matcher | ||
276 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
277 | * | ||
278 | */ | ||
279 | public static XAntennaGainNotMedium.Matcher create() { | ||
280 | return new Matcher(); | ||
281 | } | ||
282 | |||
283 | private static final int POSITION_COMM = 0; | ||
284 | |||
285 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(XAntennaGainNotMedium.Matcher.class); | ||
286 | |||
287 | /** | ||
288 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
289 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
290 | * | ||
291 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
293 | * | ||
294 | */ | ||
295 | private Matcher() { | ||
296 | super(querySpecification()); | ||
297 | } | ||
298 | |||
299 | /** | ||
300 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
301 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
302 | * @return matches represented as a Match object. | ||
303 | * | ||
304 | */ | ||
305 | public Collection<XAntennaGainNotMedium.Match> getAllMatches(final CommSubsystem pComm) { | ||
306 | return rawStreamAllMatches(new Object[]{pComm}).collect(Collectors.toSet()); | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
311 | * </p> | ||
312 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
313 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
314 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
315 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
316 | * @return a stream of matches represented as a Match object. | ||
317 | * | ||
318 | */ | ||
319 | public Stream<XAntennaGainNotMedium.Match> streamAllMatches(final CommSubsystem pComm) { | ||
320 | return rawStreamAllMatches(new Object[]{pComm}); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
325 | * Neither determinism nor randomness of selection is guaranteed. | ||
326 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
327 | * @return a match represented as a Match object, or null if no match is found. | ||
328 | * | ||
329 | */ | ||
330 | public Optional<XAntennaGainNotMedium.Match> getOneArbitraryMatch(final CommSubsystem pComm) { | ||
331 | return rawGetOneArbitraryMatch(new Object[]{pComm}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
336 | * under any possible substitution of the unspecified parameters (if any). | ||
337 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
338 | * @return true if the input is a valid (partial) match of the pattern. | ||
339 | * | ||
340 | */ | ||
341 | public boolean hasMatch(final CommSubsystem pComm) { | ||
342 | return rawHasMatch(new Object[]{pComm}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
347 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
348 | * @return the number of pattern matches found. | ||
349 | * | ||
350 | */ | ||
351 | public int countMatches(final CommSubsystem pComm) { | ||
352 | return rawCountMatches(new Object[]{pComm}); | ||
353 | } | ||
354 | |||
355 | /** | ||
356 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
357 | * Neither determinism nor randomness of selection is guaranteed. | ||
358 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
359 | * @param processor the action that will process the selected match. | ||
360 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
361 | * | ||
362 | */ | ||
363 | public boolean forOneArbitraryMatch(final CommSubsystem pComm, final Consumer<? super XAntennaGainNotMedium.Match> processor) { | ||
364 | return rawForOneArbitraryMatch(new Object[]{pComm}, processor); | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * Returns a new (partial) match. | ||
369 | * This can be used e.g. to call the matcher with a partial match. | ||
370 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
371 | * @param pComm the fixed value of pattern parameter Comm, or null if not bound. | ||
372 | * @return the (partial) match object. | ||
373 | * | ||
374 | */ | ||
375 | public XAntennaGainNotMedium.Match newMatch(final CommSubsystem pComm) { | ||
376 | return XAntennaGainNotMedium.Match.newMatch(pComm); | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * Retrieve the set of values that occur in matches for Comm. | ||
381 | * @return the Set of all values or empty set if there are no matches | ||
382 | * | ||
383 | */ | ||
384 | protected Stream<CommSubsystem> rawStreamAllValuesOfComm(final Object[] parameters) { | ||
385 | return rawStreamAllValues(POSITION_COMM, parameters).map(CommSubsystem.class::cast); | ||
386 | } | ||
387 | |||
388 | /** | ||
389 | * Retrieve the set of values that occur in matches for Comm. | ||
390 | * @return the Set of all values or empty set if there are no matches | ||
391 | * | ||
392 | */ | ||
393 | public Set<CommSubsystem> getAllValuesOfComm() { | ||
394 | return rawStreamAllValuesOfComm(emptyArray()).collect(Collectors.toSet()); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Retrieve the set of values that occur in matches for Comm. | ||
399 | * @return the Set of all values or empty set if there are no matches | ||
400 | * | ||
401 | */ | ||
402 | public Stream<CommSubsystem> streamAllValuesOfComm() { | ||
403 | return rawStreamAllValuesOfComm(emptyArray()); | ||
404 | } | ||
405 | |||
406 | @Override | ||
407 | protected XAntennaGainNotMedium.Match tupleToMatch(final Tuple t) { | ||
408 | try { | ||
409 | return XAntennaGainNotMedium.Match.newMatch((CommSubsystem) t.get(POSITION_COMM)); | ||
410 | } catch(ClassCastException e) { | ||
411 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
412 | return null; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | @Override | ||
417 | protected XAntennaGainNotMedium.Match arrayToMatch(final Object[] match) { | ||
418 | try { | ||
419 | return XAntennaGainNotMedium.Match.newMatch((CommSubsystem) match[POSITION_COMM]); | ||
420 | } catch(ClassCastException e) { | ||
421 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
422 | return null; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | @Override | ||
427 | protected XAntennaGainNotMedium.Match arrayToMatchMutable(final Object[] match) { | ||
428 | try { | ||
429 | return XAntennaGainNotMedium.Match.newMutableMatch((CommSubsystem) match[POSITION_COMM]); | ||
430 | } catch(ClassCastException e) { | ||
431 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
432 | return null; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * @return the singleton instance of the query specification of this pattern | ||
438 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
439 | * | ||
440 | */ | ||
441 | public static IQuerySpecification<XAntennaGainNotMedium.Matcher> querySpecification() { | ||
442 | return XAntennaGainNotMedium.instance(); | ||
443 | } | ||
444 | } | ||
445 | |||
446 | private XAntennaGainNotMedium() { | ||
447 | super(GeneratedPQuery.INSTANCE); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * @return the singleton instance of the query specification | ||
452 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
453 | * | ||
454 | */ | ||
455 | public static XAntennaGainNotMedium instance() { | ||
456 | try{ | ||
457 | return LazyHolder.INSTANCE; | ||
458 | } catch (ExceptionInInitializerError err) { | ||
459 | throw processInitializerError(err); | ||
460 | } | ||
461 | } | ||
462 | |||
463 | @Override | ||
464 | protected XAntennaGainNotMedium.Matcher instantiate(final ViatraQueryEngine engine) { | ||
465 | return XAntennaGainNotMedium.Matcher.on(engine); | ||
466 | } | ||
467 | |||
468 | @Override | ||
469 | public XAntennaGainNotMedium.Matcher instantiate() { | ||
470 | return XAntennaGainNotMedium.Matcher.create(); | ||
471 | } | ||
472 | |||
473 | @Override | ||
474 | public XAntennaGainNotMedium.Match newEmptyMatch() { | ||
475 | return XAntennaGainNotMedium.Match.newEmptyMatch(); | ||
476 | } | ||
477 | |||
478 | @Override | ||
479 | public XAntennaGainNotMedium.Match newMatch(final Object... parameters) { | ||
480 | return XAntennaGainNotMedium.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem) parameters[0]); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium (visibility: PUBLIC, simpleName: XAntennaGainNotMedium, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
485 | * <b>not</b> at the class load time of the outer class, | ||
486 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium (visibility: PUBLIC, simpleName: XAntennaGainNotMedium, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
487 | * | ||
488 | * <p> This workaround is required e.g. to support recursion. | ||
489 | * | ||
490 | */ | ||
491 | private static class LazyHolder { | ||
492 | private static final XAntennaGainNotMedium INSTANCE = new XAntennaGainNotMedium(); | ||
493 | |||
494 | /** | ||
495 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
496 | * This initialization order is required to support indirect recursion. | ||
497 | * | ||
498 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
499 | * | ||
500 | */ | ||
501 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
502 | |||
503 | public static Object ensureInitialized() { | ||
504 | INSTANCE.ensureInitializedInternal(); | ||
505 | return null; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
510 | private static final XAntennaGainNotMedium.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
511 | |||
512 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
513 | |||
514 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm); | ||
515 | |||
516 | private GeneratedPQuery() { | ||
517 | super(PVisibility.PUBLIC); | ||
518 | } | ||
519 | |||
520 | @Override | ||
521 | public String getFullyQualifiedName() { | ||
522 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.xAntennaGainNotMedium"; | ||
523 | } | ||
524 | |||
525 | @Override | ||
526 | public List<String> getParameterNames() { | ||
527 | return Arrays.asList("Comm"); | ||
528 | } | ||
529 | |||
530 | @Override | ||
531 | public List<PParameter> getParameters() { | ||
532 | return parameters; | ||
533 | } | ||
534 | |||
535 | @Override | ||
536 | public Set<PBody> doGetContainedBodies() { | ||
537 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
538 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
539 | { | ||
540 | PBody body = new PBody(this); | ||
541 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
543 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
544 | new ExportedParameter(body, var_Comm, parameter_Comm) | ||
545 | )); | ||
546 | // CommSubsystem.band(Comm, TransceiverBand::X) | ||
547 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
548 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "X").getInstance()); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
550 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
551 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
553 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
554 | // neg find commSubsystemGainMedium(Comm) | ||
555 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Comm), CommSubsystemGainMedium.instance().getInternalQueryRepresentation()); | ||
556 | bodies.add(body); | ||
557 | } | ||
558 | { | ||
559 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
560 | annotation.addAttribute("severity", "error"); | ||
561 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
562 | new ParameterReference("Comm") | ||
563 | })); | ||
564 | annotation.addAttribute("message", "X-band transceiver must be combined with a medium gain antenna."); | ||
565 | addAnnotation(annotation); | ||
566 | } | ||
567 | return bodies; | ||
568 | } | ||
569 | } | ||
570 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore new file mode 100644 index 00000000..f72ce8f1 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore | |||
@@ -0,0 +1,33 @@ | |||
1 | /.CommunicationLink.java._trace | ||
2 | /.SatelliteQueriesAll.java._trace | ||
3 | /.IndirectCommunicationLink.java._trace | ||
4 | /.DirectCommunicationLink.java._trace | ||
5 | /.SpacecraftWithInterferometryPayload.java._trace | ||
6 | /.SingleInterferometryPayload.java._trace | ||
7 | /.AtLeastTwoInterferometryPayloads.java._trace | ||
8 | /.DirectCommunicationLink2.java._trace | ||
9 | /.CommSubsystemBand.java._trace | ||
10 | /.CommSubsystemGain.java._trace | ||
11 | /.GroundStationNetwork.java._trace | ||
12 | /.SmallSat.java._trace | ||
13 | /.CommSubsystemGainLow.java._trace | ||
14 | /.CommSubsystemGainMedium.java._trace | ||
15 | /.CommSubsystemBandUhf.java._trace | ||
16 | /.MissionCoverage.java._trace | ||
17 | /.SatelliteMetricsAll.java._trace | ||
18 | /.MissionTime.java._trace | ||
19 | /.TimeMetric.java._trace | ||
20 | /.TransmitTime.java._trace | ||
21 | /.TransmitRate.java._trace | ||
22 | /.SpacecraftUplink.java._trace | ||
23 | /.MissionScienceData.java._trace | ||
24 | /.IndirectScienceData.java._trace | ||
25 | /.ScienceData.java._trace | ||
26 | /.IncomingData.java._trace | ||
27 | /.MissionCost.java._trace | ||
28 | /.BasePrice.java._trace | ||
29 | /.SpacecraftOfKind.java._trace | ||
30 | /.InterferometryPayloadCost.java._trace | ||
31 | /.AdditionalCommSubsystemCost.java._trace | ||
32 | /.SpacecraftWithTwoCommSubsystems.java._trace | ||
33 | /.SpacecraftCost.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java new file mode 100644 index 00000000..61b1da52 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java | |||
@@ -0,0 +1,173 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
30 | |||
31 | /** | ||
32 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
33 | * | ||
34 | * <p>Original source: | ||
35 | * <code><pre> | ||
36 | * private pattern additionalCommSubsystemCost(Spacecraft : Spacecraft, Cost : java Double) { | ||
37 | * find spacecraftWithTwoCommSubsystems(Spacecraft); | ||
38 | * Cost == 100000.0; | ||
39 | * } or { | ||
40 | * neg find spacecraftWithTwoCommSubsystems(Spacecraft); | ||
41 | * Cost == 0.0; | ||
42 | * } | ||
43 | * </pre></code> | ||
44 | * | ||
45 | * @see GenericPatternMatcher | ||
46 | * @see GenericPatternMatch | ||
47 | * | ||
48 | */ | ||
49 | @SuppressWarnings("all") | ||
50 | public final class AdditionalCommSubsystemCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
51 | private AdditionalCommSubsystemCost() { | ||
52 | super(GeneratedPQuery.INSTANCE); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return the singleton instance of the query specification | ||
57 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
58 | * | ||
59 | */ | ||
60 | public static AdditionalCommSubsystemCost instance() { | ||
61 | try{ | ||
62 | return LazyHolder.INSTANCE; | ||
63 | } catch (ExceptionInInitializerError err) { | ||
64 | throw processInitializerError(err); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost (visibility: PUBLIC, simpleName: AdditionalCommSubsystemCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
70 | * <b>not</b> at the class load time of the outer class, | ||
71 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost (visibility: PUBLIC, simpleName: AdditionalCommSubsystemCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
72 | * | ||
73 | * <p> This workaround is required e.g. to support recursion. | ||
74 | * | ||
75 | */ | ||
76 | private static class LazyHolder { | ||
77 | private static final AdditionalCommSubsystemCost INSTANCE = new AdditionalCommSubsystemCost(); | ||
78 | |||
79 | /** | ||
80 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
81 | * This initialization order is required to support indirect recursion. | ||
82 | * | ||
83 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
84 | * | ||
85 | */ | ||
86 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
87 | |||
88 | public static Object ensureInitialized() { | ||
89 | INSTANCE.ensureInitializedInternal(); | ||
90 | return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
95 | private static final AdditionalCommSubsystemCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
96 | |||
97 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
100 | |||
101 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_Cost); | ||
102 | |||
103 | private GeneratedPQuery() { | ||
104 | super(PVisibility.PRIVATE); | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public String getFullyQualifiedName() { | ||
109 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.additionalCommSubsystemCost"; | ||
110 | } | ||
111 | |||
112 | @Override | ||
113 | public List<String> getParameterNames() { | ||
114 | return Arrays.asList("Spacecraft","Cost"); | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public List<PParameter> getParameters() { | ||
119 | return parameters; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public Set<PBody> doGetContainedBodies() { | ||
124 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
125 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
126 | { | ||
127 | PBody body = new PBody(this); | ||
128 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
129 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
131 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
132 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
133 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
134 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
135 | )); | ||
136 | // find spacecraftWithTwoCommSubsystems(Spacecraft) | ||
137 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft), SpacecraftWithTwoCommSubsystems.instance().getInternalQueryRepresentation()); | ||
138 | // Cost == 100000.0 | ||
139 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
140 | new ConstantValue(body, var__virtual_0_, 100000.0); | ||
141 | new Equality(body, var_Cost, var__virtual_0_); | ||
142 | bodies.add(body); | ||
143 | } | ||
144 | { | ||
145 | PBody body = new PBody(this); | ||
146 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
147 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
148 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
149 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
150 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
151 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
152 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
153 | )); | ||
154 | // neg find spacecraftWithTwoCommSubsystems(Spacecraft) | ||
155 | new NegativePatternCall(body, Tuples.flatTupleOf(var_Spacecraft), SpacecraftWithTwoCommSubsystems.instance().getInternalQueryRepresentation()); | ||
156 | // Cost == 0.0 | ||
157 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
158 | new ConstantValue(body, var__virtual_0_, 0.0); | ||
159 | new Equality(body, var_Cost, var__virtual_0_); | ||
160 | bodies.add(body); | ||
161 | } | ||
162 | return bodies; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | private static double evaluateExpression_1_1() { | ||
167 | return 100000.0; | ||
168 | } | ||
169 | |||
170 | private static double evaluateExpression_2_1() { | ||
171 | return 0.0; | ||
172 | } | ||
173 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AtLeastTwoInterferometryPayloads.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AtLeastTwoInterferometryPayloads.java new file mode 100644 index 00000000..d560ac93 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AtLeastTwoInterferometryPayloads.java | |||
@@ -0,0 +1,138 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
26 | |||
27 | /** | ||
28 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
29 | * | ||
30 | * <p>Original source: | ||
31 | * <code><pre> | ||
32 | * private pattern atLeastTwoInterferometryPayloads(Mission : InterferometryMission) { | ||
33 | * find spacecraftWithInterferometryPayload(Mission, Spacecraft1); | ||
34 | * find spacecraftWithInterferometryPayload(Mission, Spacecraft2); | ||
35 | * Spacecraft1 != Spacecraft2; | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class AtLeastTwoInterferometryPayloads extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private AtLeastTwoInterferometryPayloads() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static AtLeastTwoInterferometryPayloads instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads (visibility: PUBLIC, simpleName: AtLeastTwoInterferometryPayloads, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads (visibility: PUBLIC, simpleName: AtLeastTwoInterferometryPayloads, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final AtLeastTwoInterferometryPayloads INSTANCE = new AtLeastTwoInterferometryPayloads(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final AtLeastTwoInterferometryPayloads.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.atLeastTwoInterferometryPayloads"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("Mission"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
121 | PVariable var_Spacecraft1 = body.getOrCreateVariableByName("Spacecraft1"); | ||
122 | PVariable var_Spacecraft2 = body.getOrCreateVariableByName("Spacecraft2"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
124 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
125 | new ExportedParameter(body, var_Mission, parameter_Mission) | ||
126 | )); | ||
127 | // find spacecraftWithInterferometryPayload(Mission, Spacecraft1) | ||
128 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Mission, var_Spacecraft1), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation()); | ||
129 | // find spacecraftWithInterferometryPayload(Mission, Spacecraft2) | ||
130 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Mission, var_Spacecraft2), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation()); | ||
131 | // Spacecraft1 != Spacecraft2 | ||
132 | new Inequality(body, var_Spacecraft1, var_Spacecraft2); | ||
133 | bodies.add(body); | ||
134 | } | ||
135 | return bodies; | ||
136 | } | ||
137 | } | ||
138 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java new file mode 100644 index 00000000..c70f4c8b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java | |||
@@ -0,0 +1,216 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
30 | |||
31 | /** | ||
32 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
33 | * | ||
34 | * <p>Original source: | ||
35 | * <code><pre> | ||
36 | * private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) { | ||
37 | * Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U); | ||
38 | * BasePrice == 250000.0; | ||
39 | * } or { | ||
40 | * Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U); | ||
41 | * BasePrice == 750000.0; | ||
42 | * } or { | ||
43 | * Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat); | ||
44 | * BasePrice == 3000000.0; | ||
45 | * } | ||
46 | * </pre></code> | ||
47 | * | ||
48 | * @see GenericPatternMatcher | ||
49 | * @see GenericPatternMatch | ||
50 | * | ||
51 | */ | ||
52 | @SuppressWarnings("all") | ||
53 | public final class BasePrice extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
54 | private BasePrice() { | ||
55 | super(GeneratedPQuery.INSTANCE); | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * @return the singleton instance of the query specification | ||
60 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
61 | * | ||
62 | */ | ||
63 | public static BasePrice instance() { | ||
64 | try{ | ||
65 | return LazyHolder.INSTANCE; | ||
66 | } catch (ExceptionInInitializerError err) { | ||
67 | throw processInitializerError(err); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice (visibility: PUBLIC, simpleName: BasePrice, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
73 | * <b>not</b> at the class load time of the outer class, | ||
74 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice (visibility: PUBLIC, simpleName: BasePrice, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
75 | * | ||
76 | * <p> This workaround is required e.g. to support recursion. | ||
77 | * | ||
78 | */ | ||
79 | private static class LazyHolder { | ||
80 | private static final BasePrice INSTANCE = new BasePrice(); | ||
81 | |||
82 | /** | ||
83 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
84 | * This initialization order is required to support indirect recursion. | ||
85 | * | ||
86 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
87 | * | ||
88 | */ | ||
89 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
90 | |||
91 | public static Object ensureInitialized() { | ||
92 | INSTANCE.ensureInitializedInternal(); | ||
93 | return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
98 | private static final BasePrice.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
99 | |||
100 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
101 | |||
102 | private final PParameter parameter_BasePrice = new PParameter("BasePrice", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
103 | |||
104 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_BasePrice); | ||
105 | |||
106 | private GeneratedPQuery() { | ||
107 | super(PVisibility.PRIVATE); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public String getFullyQualifiedName() { | ||
112 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.basePrice"; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<String> getParameterNames() { | ||
117 | return Arrays.asList("Spacecraft","BasePrice"); | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<PParameter> getParameters() { | ||
122 | return parameters; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Set<PBody> doGetContainedBodies() { | ||
127 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
128 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
129 | { | ||
130 | PBody body = new PBody(this); | ||
131 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
132 | PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
134 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
135 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
136 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
137 | new ExportedParameter(body, var_BasePrice, parameter_BasePrice) | ||
138 | )); | ||
139 | // Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U) | ||
140 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
141 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat3U").getInstance()); | ||
142 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
143 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
145 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
146 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
147 | // BasePrice == 250000.0 | ||
148 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
149 | new ConstantValue(body, var__virtual_2_, 250000.0); | ||
150 | new Equality(body, var_BasePrice, var__virtual_2_); | ||
151 | bodies.add(body); | ||
152 | } | ||
153 | { | ||
154 | PBody body = new PBody(this); | ||
155 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
156 | PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); | ||
157 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
158 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
159 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
160 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
161 | new ExportedParameter(body, var_BasePrice, parameter_BasePrice) | ||
162 | )); | ||
163 | // Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U) | ||
164 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
165 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat6U").getInstance()); | ||
166 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
167 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
168 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
169 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
170 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
171 | // BasePrice == 750000.0 | ||
172 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
173 | new ConstantValue(body, var__virtual_2_, 750000.0); | ||
174 | new Equality(body, var_BasePrice, var__virtual_2_); | ||
175 | bodies.add(body); | ||
176 | } | ||
177 | { | ||
178 | PBody body = new PBody(this); | ||
179 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
180 | PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); | ||
181 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
182 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
183 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
184 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
185 | new ExportedParameter(body, var_BasePrice, parameter_BasePrice) | ||
186 | )); | ||
187 | // Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat) | ||
188 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
189 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "SmallSat").getInstance()); | ||
190 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
191 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
192 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
193 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
194 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
195 | // BasePrice == 3000000.0 | ||
196 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
197 | new ConstantValue(body, var__virtual_2_, 3000000.0); | ||
198 | new Equality(body, var_BasePrice, var__virtual_2_); | ||
199 | bodies.add(body); | ||
200 | } | ||
201 | return bodies; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | private static double evaluateExpression_1_1() { | ||
206 | return 250000.0; | ||
207 | } | ||
208 | |||
209 | private static double evaluateExpression_2_1() { | ||
210 | return 750000.0; | ||
211 | } | ||
212 | |||
213 | private static double evaluateExpression_3_1() { | ||
214 | return 3000000.0; | ||
215 | } | ||
216 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemBand.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemBand.java new file mode 100644 index 00000000..a0009587 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemBand.java | |||
@@ -0,0 +1,140 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern commSubsystemBand(Comm : CommSubsystem, Band : TransceiverBand) { | ||
34 | * CommSubsystem.band(Comm, Band); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class CommSubsystemBand extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private CommSubsystemBand() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static CommSubsystemBand instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand (visibility: PUBLIC, simpleName: CommSubsystemBand, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand (visibility: PUBLIC, simpleName: CommSubsystemBand, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final CommSubsystemBand INSTANCE = new CommSubsystemBand(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final CommSubsystemBand.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_Band = new PParameter("Band", "hu.bme.mit.inf.dslreasoner.domains.satellite.TransceiverBand", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "TransceiverBand")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm, parameter_Band); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.commSubsystemBand"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Comm","Band"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
122 | PVariable var_Band = body.getOrCreateVariableByName("Band"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Band), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
125 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
126 | new ExportedParameter(body, var_Comm, parameter_Comm), | ||
127 | new ExportedParameter(body, var_Band, parameter_Band) | ||
128 | )); | ||
129 | // CommSubsystem.band(Comm, Band) | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
131 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
134 | new Equality(body, var__virtual_0_, var_Band); | ||
135 | bodies.add(body); | ||
136 | } | ||
137 | return bodies; | ||
138 | } | ||
139 | } | ||
140 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemBandUhf.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemBandUhf.java new file mode 100644 index 00000000..51175ce3 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemBandUhf.java | |||
@@ -0,0 +1,138 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
28 | |||
29 | /** | ||
30 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
31 | * | ||
32 | * <p>Original source: | ||
33 | * <code><pre> | ||
34 | * private pattern commSubsystemBandUhf(Comm : CommSubsystem) { | ||
35 | * CommSubsystem.band(Comm, TransceiverBand::UHF); | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class CommSubsystemBandUhf extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private CommSubsystemBandUhf() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static CommSubsystemBandUhf instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf (visibility: PUBLIC, simpleName: CommSubsystemBandUhf, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf (visibility: PUBLIC, simpleName: CommSubsystemBandUhf, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final CommSubsystemBandUhf INSTANCE = new CommSubsystemBandUhf(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final CommSubsystemBandUhf.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.commSubsystemBandUhf"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("Comm"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
122 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
123 | new ExportedParameter(body, var_Comm, parameter_Comm) | ||
124 | )); | ||
125 | // CommSubsystem.band(Comm, TransceiverBand::UHF) | ||
126 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
127 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "UHF").getInstance()); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
129 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
132 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
133 | bodies.add(body); | ||
134 | } | ||
135 | return bodies; | ||
136 | } | ||
137 | } | ||
138 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGain.java new file mode 100644 index 00000000..e2e0e2a1 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGain.java | |||
@@ -0,0 +1,140 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern commSubsystemGain(Comm : CommSubsystem, Gain : AntennaGain) { | ||
34 | * CommSubsystem.gain(Comm, Gain); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class CommSubsystemGain extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private CommSubsystemGain() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static CommSubsystemGain instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain (visibility: PUBLIC, simpleName: CommSubsystemGain, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain (visibility: PUBLIC, simpleName: CommSubsystemGain, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final CommSubsystemGain INSTANCE = new CommSubsystemGain(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final CommSubsystemGain.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_Gain = new PParameter("Gain", "hu.bme.mit.inf.dslreasoner.domains.satellite.AntennaGain", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "AntennaGain")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm, parameter_Gain); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.commSubsystemGain"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Comm","Gain"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
122 | PVariable var_Gain = body.getOrCreateVariableByName("Gain"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Gain), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "AntennaGain"))); | ||
125 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
126 | new ExportedParameter(body, var_Comm, parameter_Comm), | ||
127 | new ExportedParameter(body, var_Gain, parameter_Gain) | ||
128 | )); | ||
129 | // CommSubsystem.gain(Comm, Gain) | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
131 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "gain"))); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "AntennaGain"))); | ||
134 | new Equality(body, var__virtual_0_, var_Gain); | ||
135 | bodies.add(body); | ||
136 | } | ||
137 | return bodies; | ||
138 | } | ||
139 | } | ||
140 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGainLow.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGainLow.java new file mode 100644 index 00000000..04ee67da --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGainLow.java | |||
@@ -0,0 +1,138 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
28 | |||
29 | /** | ||
30 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
31 | * | ||
32 | * <p>Original source: | ||
33 | * <code><pre> | ||
34 | * private pattern commSubsystemGainLow(Comm : CommSubsystem) { | ||
35 | * CommSubsystem.gain(Comm, AntennaGain::LOW); | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class CommSubsystemGainLow extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private CommSubsystemGainLow() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static CommSubsystemGainLow instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainLow (visibility: PUBLIC, simpleName: CommSubsystemGainLow, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainLow, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainLow (visibility: PUBLIC, simpleName: CommSubsystemGainLow, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainLow, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final CommSubsystemGainLow INSTANCE = new CommSubsystemGainLow(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final CommSubsystemGainLow.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.commSubsystemGainLow"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("Comm"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
122 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
123 | new ExportedParameter(body, var_Comm, parameter_Comm) | ||
124 | )); | ||
125 | // CommSubsystem.gain(Comm, AntennaGain::LOW) | ||
126 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
127 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "AntennaGain", "LOW").getInstance()); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
129 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "gain"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "AntennaGain"))); | ||
132 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
133 | bodies.add(body); | ||
134 | } | ||
135 | return bodies; | ||
136 | } | ||
137 | } | ||
138 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGainMedium.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGainMedium.java new file mode 100644 index 00000000..4b3bc03b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/CommSubsystemGainMedium.java | |||
@@ -0,0 +1,138 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
28 | |||
29 | /** | ||
30 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
31 | * | ||
32 | * <p>Original source: | ||
33 | * <code><pre> | ||
34 | * private pattern commSubsystemGainMedium(Comm : CommSubsystem) { | ||
35 | * CommSubsystem.gain(Comm, AntennaGain::MEDIUM); | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class CommSubsystemGainMedium extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private CommSubsystemGainMedium() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static CommSubsystemGainMedium instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium (visibility: PUBLIC, simpleName: CommSubsystemGainMedium, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium (visibility: PUBLIC, simpleName: CommSubsystemGainMedium, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final CommSubsystemGainMedium INSTANCE = new CommSubsystemGainMedium(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final CommSubsystemGainMedium.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Comm = new PParameter("Comm", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommSubsystem")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_Comm); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.commSubsystemGainMedium"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("Comm"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_Comm = body.getOrCreateVariableByName("Comm"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
122 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
123 | new ExportedParameter(body, var_Comm, parameter_Comm) | ||
124 | )); | ||
125 | // CommSubsystem.gain(Comm, AntennaGain::MEDIUM) | ||
126 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
127 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "AntennaGain", "MEDIUM").getInstance()); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
129 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Comm, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "gain"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "AntennaGain"))); | ||
132 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
133 | bodies.add(body); | ||
134 | } | ||
135 | return bodies; | ||
136 | } | ||
137 | } | ||
138 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/DirectCommunicationLink.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/DirectCommunicationLink.java new file mode 100644 index 00000000..d6f5c53b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/DirectCommunicationLink.java | |||
@@ -0,0 +1,162 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
25 | |||
26 | /** | ||
27 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
28 | * | ||
29 | * <p>Original source: | ||
30 | * <code><pre> | ||
31 | * private pattern directCommunicationLink(Source : CommunicatingElement, Target : CommunicatingElement) { | ||
32 | * DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
33 | * DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
34 | * CommunicatingElement.commSubsystem(Source, SourceSubsystem); | ||
35 | * CommunicatingElement.commSubsystem(Target, TargetSubsystem); | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class DirectCommunicationLink extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private DirectCommunicationLink() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static DirectCommunicationLink instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink (visibility: PUBLIC, simpleName: DirectCommunicationLink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink (visibility: PUBLIC, simpleName: DirectCommunicationLink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final DirectCommunicationLink INSTANCE = new DirectCommunicationLink(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final DirectCommunicationLink.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Source = new PParameter("Source", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final PParameter parameter_Target = new PParameter("Target", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); | ||
94 | |||
95 | private final List<PParameter> parameters = Arrays.asList(parameter_Source, parameter_Target); | ||
96 | |||
97 | private GeneratedPQuery() { | ||
98 | super(PVisibility.PRIVATE); | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public String getFullyQualifiedName() { | ||
103 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.directCommunicationLink"; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public List<String> getParameterNames() { | ||
108 | return Arrays.asList("Source","Target"); | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public List<PParameter> getParameters() { | ||
113 | return parameters; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public Set<PBody> doGetContainedBodies() { | ||
118 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
119 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
120 | { | ||
121 | PBody body = new PBody(this); | ||
122 | PVariable var_Source = body.getOrCreateVariableByName("Source"); | ||
123 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
124 | PVariable var_Link = body.getOrCreateVariableByName("Link"); | ||
125 | PVariable var_SourceSubsystem = body.getOrCreateVariableByName("SourceSubsystem"); | ||
126 | PVariable var_TargetSubsystem = body.getOrCreateVariableByName("TargetSubsystem"); | ||
127 | new TypeConstraint(body, Tuples.flatTupleOf(var_Source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
129 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
130 | new ExportedParameter(body, var_Source, parameter_Source), | ||
131 | new ExportedParameter(body, var_Target, parameter_Target) | ||
132 | )); | ||
133 | // DirectedCommunicationLink.source(Link, SourceSubsystem) | ||
134 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
135 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
136 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); | ||
137 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
138 | new Equality(body, var__virtual_0_, var_SourceSubsystem); | ||
139 | // DirectedCommunicationLink.target(Link, TargetSubsystem) | ||
140 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
141 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
142 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
144 | new Equality(body, var__virtual_1_, var_TargetSubsystem); | ||
145 | // CommunicatingElement.commSubsystem(Source, SourceSubsystem) | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var_Source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
147 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
148 | new TypeConstraint(body, Tuples.flatTupleOf(var_Source, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
149 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
150 | new Equality(body, var__virtual_2_, var_SourceSubsystem); | ||
151 | // CommunicatingElement.commSubsystem(Target, TargetSubsystem) | ||
152 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
153 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
154 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
155 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
156 | new Equality(body, var__virtual_3_, var_TargetSubsystem); | ||
157 | bodies.add(body); | ||
158 | } | ||
159 | return bodies; | ||
160 | } | ||
161 | } | ||
162 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/GroundStationNetwork.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/GroundStationNetwork.java new file mode 100644 index 00000000..93b1a01b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/GroundStationNetwork.java | |||
@@ -0,0 +1,127 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
23 | |||
24 | /** | ||
25 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
26 | * | ||
27 | * <p>Original source: | ||
28 | * <code><pre> | ||
29 | * private pattern groundStationNetwork(Network : GroundStationNetwork) { | ||
30 | * GroundStationNetwork(Network); | ||
31 | * } | ||
32 | * </pre></code> | ||
33 | * | ||
34 | * @see GenericPatternMatcher | ||
35 | * @see GenericPatternMatch | ||
36 | * | ||
37 | */ | ||
38 | @SuppressWarnings("all") | ||
39 | public final class GroundStationNetwork extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
40 | private GroundStationNetwork() { | ||
41 | super(GeneratedPQuery.INSTANCE); | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * @return the singleton instance of the query specification | ||
46 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
47 | * | ||
48 | */ | ||
49 | public static GroundStationNetwork instance() { | ||
50 | try{ | ||
51 | return LazyHolder.INSTANCE; | ||
52 | } catch (ExceptionInInitializerError err) { | ||
53 | throw processInitializerError(err); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork (visibility: PUBLIC, simpleName: GroundStationNetwork, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
59 | * <b>not</b> at the class load time of the outer class, | ||
60 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork (visibility: PUBLIC, simpleName: GroundStationNetwork, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
61 | * | ||
62 | * <p> This workaround is required e.g. to support recursion. | ||
63 | * | ||
64 | */ | ||
65 | private static class LazyHolder { | ||
66 | private static final GroundStationNetwork INSTANCE = new GroundStationNetwork(); | ||
67 | |||
68 | /** | ||
69 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
70 | * This initialization order is required to support indirect recursion. | ||
71 | * | ||
72 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
73 | * | ||
74 | */ | ||
75 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
76 | |||
77 | public static Object ensureInitialized() { | ||
78 | INSTANCE.ensureInitializedInternal(); | ||
79 | return null; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
84 | private static final GroundStationNetwork.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
85 | |||
86 | private final PParameter parameter_Network = new PParameter("Network", "hu.bme.mit.inf.dslreasoner.domains.satellite.GroundStationNetwork", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "GroundStationNetwork")), PParameterDirection.INOUT); | ||
87 | |||
88 | private final List<PParameter> parameters = Arrays.asList(parameter_Network); | ||
89 | |||
90 | private GeneratedPQuery() { | ||
91 | super(PVisibility.PRIVATE); | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public String getFullyQualifiedName() { | ||
96 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.groundStationNetwork"; | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public List<String> getParameterNames() { | ||
101 | return Arrays.asList("Network"); | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<PParameter> getParameters() { | ||
106 | return parameters; | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public Set<PBody> doGetContainedBodies() { | ||
111 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
112 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
113 | { | ||
114 | PBody body = new PBody(this); | ||
115 | PVariable var_Network = body.getOrCreateVariableByName("Network"); | ||
116 | new TypeConstraint(body, Tuples.flatTupleOf(var_Network), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); | ||
117 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
118 | new ExportedParameter(body, var_Network, parameter_Network) | ||
119 | )); | ||
120 | // GroundStationNetwork(Network) | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Network), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); | ||
122 | bodies.add(body); | ||
123 | } | ||
124 | return bodies; | ||
125 | } | ||
126 | } | ||
127 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java new file mode 100644 index 00000000..114bbf33 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java | |||
@@ -0,0 +1,145 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Set; | ||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
28 | |||
29 | /** | ||
30 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
31 | * | ||
32 | * <p>Original source: | ||
33 | * <code><pre> | ||
34 | * private pattern incomingData(Spacecraft : Spacecraft, Source : Spacecraft, Data : java Double) { | ||
35 | * find indirectCommunicationLink(Source, Spacecraft); | ||
36 | * find scienceData(Source, Data); | ||
37 | * } | ||
38 | * </pre></code> | ||
39 | * | ||
40 | * @see GenericPatternMatcher | ||
41 | * @see GenericPatternMatch | ||
42 | * | ||
43 | */ | ||
44 | @SuppressWarnings("all") | ||
45 | public final class IncomingData extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
46 | private IncomingData() { | ||
47 | super(GeneratedPQuery.INSTANCE); | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * @return the singleton instance of the query specification | ||
52 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
53 | * | ||
54 | */ | ||
55 | public static IncomingData instance() { | ||
56 | try{ | ||
57 | return LazyHolder.INSTANCE; | ||
58 | } catch (ExceptionInInitializerError err) { | ||
59 | throw processInitializerError(err); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData (visibility: PUBLIC, simpleName: IncomingData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
65 | * <b>not</b> at the class load time of the outer class, | ||
66 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData (visibility: PUBLIC, simpleName: IncomingData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
67 | * | ||
68 | * <p> This workaround is required e.g. to support recursion. | ||
69 | * | ||
70 | */ | ||
71 | private static class LazyHolder { | ||
72 | private static final IncomingData INSTANCE = new IncomingData(); | ||
73 | |||
74 | /** | ||
75 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
76 | * This initialization order is required to support indirect recursion. | ||
77 | * | ||
78 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
79 | * | ||
80 | */ | ||
81 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
82 | |||
83 | public static Object ensureInitialized() { | ||
84 | INSTANCE.ensureInitializedInternal(); | ||
85 | return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
90 | private static final IncomingData.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
91 | |||
92 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final PParameter parameter_Source = new PParameter("Source", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
95 | |||
96 | private final PParameter parameter_Data = new PParameter("Data", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
97 | |||
98 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_Source, parameter_Data); | ||
99 | |||
100 | private GeneratedPQuery() { | ||
101 | super(PVisibility.PRIVATE); | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public String getFullyQualifiedName() { | ||
106 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incomingData"; | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<String> getParameterNames() { | ||
111 | return Arrays.asList("Spacecraft","Source","Data"); | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public List<PParameter> getParameters() { | ||
116 | return parameters; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public Set<PBody> doGetContainedBodies() { | ||
121 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
122 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
123 | { | ||
124 | PBody body = new PBody(this); | ||
125 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
126 | PVariable var_Source = body.getOrCreateVariableByName("Source"); | ||
127 | PVariable var_Data = body.getOrCreateVariableByName("Data"); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
129 | new TypeConstraint(body, Tuples.flatTupleOf(var_Source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
130 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Data), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
131 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
132 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
133 | new ExportedParameter(body, var_Source, parameter_Source), | ||
134 | new ExportedParameter(body, var_Data, parameter_Data) | ||
135 | )); | ||
136 | // find indirectCommunicationLink(Source, Spacecraft) | ||
137 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Source, var_Spacecraft), IndirectCommunicationLink.instance().getInternalQueryRepresentation()); | ||
138 | // find scienceData(Source, Data) | ||
139 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Source, var_Data), ScienceData.instance().getInternalQueryRepresentation()); | ||
140 | bodies.add(body); | ||
141 | } | ||
142 | return bodies; | ||
143 | } | ||
144 | } | ||
145 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IndirectCommunicationLink.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IndirectCommunicationLink.java new file mode 100644 index 00000000..6d5e475c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IndirectCommunicationLink.java | |||
@@ -0,0 +1,134 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
25 | |||
26 | /** | ||
27 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
28 | * | ||
29 | * <p>Original source: | ||
30 | * <code><pre> | ||
31 | * private pattern indirectCommunicationLink(Source : CommunicatingElement, Target : CommunicatingElement) { | ||
32 | * find directCommunicationLink+(Source, Target); | ||
33 | * } | ||
34 | * </pre></code> | ||
35 | * | ||
36 | * @see GenericPatternMatcher | ||
37 | * @see GenericPatternMatch | ||
38 | * | ||
39 | */ | ||
40 | @SuppressWarnings("all") | ||
41 | public final class IndirectCommunicationLink extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
42 | private IndirectCommunicationLink() { | ||
43 | super(GeneratedPQuery.INSTANCE); | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * @return the singleton instance of the query specification | ||
48 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
49 | * | ||
50 | */ | ||
51 | public static IndirectCommunicationLink instance() { | ||
52 | try{ | ||
53 | return LazyHolder.INSTANCE; | ||
54 | } catch (ExceptionInInitializerError err) { | ||
55 | throw processInitializerError(err); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink (visibility: PUBLIC, simpleName: IndirectCommunicationLink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
61 | * <b>not</b> at the class load time of the outer class, | ||
62 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink (visibility: PUBLIC, simpleName: IndirectCommunicationLink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
63 | * | ||
64 | * <p> This workaround is required e.g. to support recursion. | ||
65 | * | ||
66 | */ | ||
67 | private static class LazyHolder { | ||
68 | private static final IndirectCommunicationLink INSTANCE = new IndirectCommunicationLink(); | ||
69 | |||
70 | /** | ||
71 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
72 | * This initialization order is required to support indirect recursion. | ||
73 | * | ||
74 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
75 | * | ||
76 | */ | ||
77 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
78 | |||
79 | public static Object ensureInitialized() { | ||
80 | INSTANCE.ensureInitializedInternal(); | ||
81 | return null; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
86 | private static final IndirectCommunicationLink.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
87 | |||
88 | private final PParameter parameter_Source = new PParameter("Source", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); | ||
89 | |||
90 | private final PParameter parameter_Target = new PParameter("Target", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final List<PParameter> parameters = Arrays.asList(parameter_Source, parameter_Target); | ||
93 | |||
94 | private GeneratedPQuery() { | ||
95 | super(PVisibility.PRIVATE); | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public String getFullyQualifiedName() { | ||
100 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.indirectCommunicationLink"; | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public List<String> getParameterNames() { | ||
105 | return Arrays.asList("Source","Target"); | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public List<PParameter> getParameters() { | ||
110 | return parameters; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public Set<PBody> doGetContainedBodies() { | ||
115 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
116 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
117 | { | ||
118 | PBody body = new PBody(this); | ||
119 | PVariable var_Source = body.getOrCreateVariableByName("Source"); | ||
120 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
122 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
123 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
124 | new ExportedParameter(body, var_Source, parameter_Source), | ||
125 | new ExportedParameter(body, var_Target, parameter_Target) | ||
126 | )); | ||
127 | // find directCommunicationLink+(Source, Target) | ||
128 | new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_Source, var_Target), DirectCommunicationLink.instance().getInternalQueryRepresentation()); | ||
129 | bodies.add(body); | ||
130 | } | ||
131 | return bodies; | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java new file mode 100644 index 00000000..205d896a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java | |||
@@ -0,0 +1,175 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
30 | |||
31 | /** | ||
32 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
33 | * | ||
34 | * <p>Original source: | ||
35 | * <code><pre> | ||
36 | * private pattern interferometryPayloadCost(Spacecraft : Spacecraft, Cost : java Double) { | ||
37 | * find spacecraftWithInterferometryPayload(_, Spacecraft); | ||
38 | * Cost == 50000.0; | ||
39 | * } or { | ||
40 | * neg find spacecraftWithInterferometryPayload(_, Spacecraft); | ||
41 | * Cost == 0.0; | ||
42 | * } | ||
43 | * </pre></code> | ||
44 | * | ||
45 | * @see GenericPatternMatcher | ||
46 | * @see GenericPatternMatch | ||
47 | * | ||
48 | */ | ||
49 | @SuppressWarnings("all") | ||
50 | public final class InterferometryPayloadCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
51 | private InterferometryPayloadCost() { | ||
52 | super(GeneratedPQuery.INSTANCE); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return the singleton instance of the query specification | ||
57 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
58 | * | ||
59 | */ | ||
60 | public static InterferometryPayloadCost instance() { | ||
61 | try{ | ||
62 | return LazyHolder.INSTANCE; | ||
63 | } catch (ExceptionInInitializerError err) { | ||
64 | throw processInitializerError(err); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost (visibility: PUBLIC, simpleName: InterferometryPayloadCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
70 | * <b>not</b> at the class load time of the outer class, | ||
71 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost (visibility: PUBLIC, simpleName: InterferometryPayloadCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
72 | * | ||
73 | * <p> This workaround is required e.g. to support recursion. | ||
74 | * | ||
75 | */ | ||
76 | private static class LazyHolder { | ||
77 | private static final InterferometryPayloadCost INSTANCE = new InterferometryPayloadCost(); | ||
78 | |||
79 | /** | ||
80 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
81 | * This initialization order is required to support indirect recursion. | ||
82 | * | ||
83 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
84 | * | ||
85 | */ | ||
86 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
87 | |||
88 | public static Object ensureInitialized() { | ||
89 | INSTANCE.ensureInitializedInternal(); | ||
90 | return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
95 | private static final InterferometryPayloadCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
96 | |||
97 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
100 | |||
101 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_Cost); | ||
102 | |||
103 | private GeneratedPQuery() { | ||
104 | super(PVisibility.PRIVATE); | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public String getFullyQualifiedName() { | ||
109 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.interferometryPayloadCost"; | ||
110 | } | ||
111 | |||
112 | @Override | ||
113 | public List<String> getParameterNames() { | ||
114 | return Arrays.asList("Spacecraft","Cost"); | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public List<PParameter> getParameters() { | ||
119 | return parameters; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public Set<PBody> doGetContainedBodies() { | ||
124 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
125 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
126 | { | ||
127 | PBody body = new PBody(this); | ||
128 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
129 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
130 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
132 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
133 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
134 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
135 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
136 | )); | ||
137 | // find spacecraftWithInterferometryPayload(_, Spacecraft) | ||
138 | new PositivePatternCall(body, Tuples.flatTupleOf(var___0_, var_Spacecraft), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation()); | ||
139 | // Cost == 50000.0 | ||
140 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
141 | new ConstantValue(body, var__virtual_0_, 50000.0); | ||
142 | new Equality(body, var_Cost, var__virtual_0_); | ||
143 | bodies.add(body); | ||
144 | } | ||
145 | { | ||
146 | PBody body = new PBody(this); | ||
147 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
148 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
149 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
150 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
151 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
152 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
153 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
154 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
155 | )); | ||
156 | // neg find spacecraftWithInterferometryPayload(_, Spacecraft) | ||
157 | new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_Spacecraft), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation()); | ||
158 | // Cost == 0.0 | ||
159 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
160 | new ConstantValue(body, var__virtual_0_, 0.0); | ||
161 | new Equality(body, var_Cost, var__virtual_0_); | ||
162 | bodies.add(body); | ||
163 | } | ||
164 | return bodies; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | private static double evaluateExpression_1_1() { | ||
169 | return 50000.0; | ||
170 | } | ||
171 | |||
172 | private static double evaluateExpression_2_1() { | ||
173 | return 0.0; | ||
174 | } | ||
175 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java new file mode 100644 index 00000000..0374195f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java | |||
@@ -0,0 +1,183 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
35 | |||
36 | /** | ||
37 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
38 | * | ||
39 | * <p>Original source: | ||
40 | * <code><pre> | ||
41 | * private pattern missionCost(Mission : InterferometryMission, Cost : java Double) { | ||
42 | * InterferometryMission.observationTime(Mission, ObservationTime); | ||
43 | * SpacecraftCost == sum find spacecraftCost(Mission, _, #_); | ||
44 | * Cost == eval(SpacecraftCost + 100000.0 ObservationTime); | ||
45 | * } | ||
46 | * </pre></code> | ||
47 | * | ||
48 | * @see GenericPatternMatcher | ||
49 | * @see GenericPatternMatch | ||
50 | * | ||
51 | */ | ||
52 | @SuppressWarnings("all") | ||
53 | public final class MissionCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
54 | private MissionCost() { | ||
55 | super(GeneratedPQuery.INSTANCE); | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * @return the singleton instance of the query specification | ||
60 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
61 | * | ||
62 | */ | ||
63 | public static MissionCost instance() { | ||
64 | try{ | ||
65 | return LazyHolder.INSTANCE; | ||
66 | } catch (ExceptionInInitializerError err) { | ||
67 | throw processInitializerError(err); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost (visibility: PUBLIC, simpleName: MissionCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
73 | * <b>not</b> at the class load time of the outer class, | ||
74 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost (visibility: PUBLIC, simpleName: MissionCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
75 | * | ||
76 | * <p> This workaround is required e.g. to support recursion. | ||
77 | * | ||
78 | */ | ||
79 | private static class LazyHolder { | ||
80 | private static final MissionCost INSTANCE = new MissionCost(); | ||
81 | |||
82 | /** | ||
83 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
84 | * This initialization order is required to support indirect recursion. | ||
85 | * | ||
86 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
87 | * | ||
88 | */ | ||
89 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
90 | |||
91 | public static Object ensureInitialized() { | ||
92 | INSTANCE.ensureInitializedInternal(); | ||
93 | return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
98 | private static final MissionCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
99 | |||
100 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
101 | |||
102 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
103 | |||
104 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Cost); | ||
105 | |||
106 | private GeneratedPQuery() { | ||
107 | super(PVisibility.PRIVATE); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public String getFullyQualifiedName() { | ||
112 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.missionCost"; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<String> getParameterNames() { | ||
117 | return Arrays.asList("Mission","Cost"); | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<PParameter> getParameters() { | ||
122 | return parameters; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Set<PBody> doGetContainedBodies() { | ||
127 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
128 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
129 | { | ||
130 | PBody body = new PBody(this); | ||
131 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
132 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
133 | PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); | ||
134 | PVariable var_SpacecraftCost = body.getOrCreateVariableByName("SpacecraftCost"); | ||
135 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
136 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
137 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
138 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
139 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
140 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
141 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
142 | )); | ||
143 | // InterferometryMission.observationTime(Mission, ObservationTime) | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
145 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); | ||
147 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); | ||
148 | new Equality(body, var__virtual_0_, var_ObservationTime); | ||
149 | // SpacecraftCost == sum find spacecraftCost(Mission, _, #_) | ||
150 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
151 | new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Mission, var___0_, var___1_), SpacecraftCost.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); | ||
152 | new Equality(body, var_SpacecraftCost, var__virtual_1_); | ||
153 | // Cost == eval(SpacecraftCost + 100000.0 * ObservationTime) | ||
154 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
155 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
156 | |||
157 | @Override | ||
158 | public String getShortDescription() { | ||
159 | return "Expression evaluation from pattern missionCost"; | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public Iterable<String> getInputParameterNames() { | ||
164 | return Arrays.asList("ObservationTime", "SpacecraftCost");} | ||
165 | |||
166 | @Override | ||
167 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
168 | Float ObservationTime = (Float) provider.getValue("ObservationTime"); | ||
169 | Double SpacecraftCost = (Double) provider.getValue("SpacecraftCost"); | ||
170 | return evaluateExpression_1_1(ObservationTime, SpacecraftCost); | ||
171 | } | ||
172 | }, var__virtual_2_ ); | ||
173 | new Equality(body, var_Cost, var__virtual_2_); | ||
174 | bodies.add(body); | ||
175 | } | ||
176 | return bodies; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | private static double evaluateExpression_1_1(final Float ObservationTime, final Double SpacecraftCost) { | ||
181 | return ((SpacecraftCost).doubleValue() + (100000.0 * (ObservationTime).floatValue())); | ||
182 | } | ||
183 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java new file mode 100644 index 00000000..583c2175 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java | |||
@@ -0,0 +1,183 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
34 | |||
35 | /** | ||
36 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
37 | * | ||
38 | * <p>Original source: | ||
39 | * <code><pre> | ||
40 | * private pattern missionCoverage(Mission : InterferometryMission, Coverage : java Double) { | ||
41 | * InterferometryMission.observationTime(Mission, ObservationTime); | ||
42 | * ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _); | ||
43 | * Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9 (1.0 / ObservationTime)) + 0.05 ObservationTime / 3); | ||
44 | * } | ||
45 | * </pre></code> | ||
46 | * | ||
47 | * @see GenericPatternMatcher | ||
48 | * @see GenericPatternMatch | ||
49 | * | ||
50 | */ | ||
51 | @SuppressWarnings("all") | ||
52 | public final class MissionCoverage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
53 | private MissionCoverage() { | ||
54 | super(GeneratedPQuery.INSTANCE); | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * @return the singleton instance of the query specification | ||
59 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
60 | * | ||
61 | */ | ||
62 | public static MissionCoverage instance() { | ||
63 | try{ | ||
64 | return LazyHolder.INSTANCE; | ||
65 | } catch (ExceptionInInitializerError err) { | ||
66 | throw processInitializerError(err); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage (visibility: PUBLIC, simpleName: MissionCoverage, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
72 | * <b>not</b> at the class load time of the outer class, | ||
73 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage (visibility: PUBLIC, simpleName: MissionCoverage, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
74 | * | ||
75 | * <p> This workaround is required e.g. to support recursion. | ||
76 | * | ||
77 | */ | ||
78 | private static class LazyHolder { | ||
79 | private static final MissionCoverage INSTANCE = new MissionCoverage(); | ||
80 | |||
81 | /** | ||
82 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
83 | * This initialization order is required to support indirect recursion. | ||
84 | * | ||
85 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
86 | * | ||
87 | */ | ||
88 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
89 | |||
90 | public static Object ensureInitialized() { | ||
91 | INSTANCE.ensureInitializedInternal(); | ||
92 | return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
97 | private static final MissionCoverage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
98 | |||
99 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
100 | |||
101 | private final PParameter parameter_Coverage = new PParameter("Coverage", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
102 | |||
103 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Coverage); | ||
104 | |||
105 | private GeneratedPQuery() { | ||
106 | super(PVisibility.PRIVATE); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public String getFullyQualifiedName() { | ||
111 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.missionCoverage"; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public List<String> getParameterNames() { | ||
116 | return Arrays.asList("Mission","Coverage"); | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public List<PParameter> getParameters() { | ||
121 | return parameters; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public Set<PBody> doGetContainedBodies() { | ||
126 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
127 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
128 | { | ||
129 | PBody body = new PBody(this); | ||
130 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
131 | PVariable var_Coverage = body.getOrCreateVariableByName("Coverage"); | ||
132 | PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); | ||
133 | PVariable var_ObserverCount = body.getOrCreateVariableByName("ObserverCount"); | ||
134 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
135 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
136 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Coverage), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
137 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
138 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
139 | new ExportedParameter(body, var_Coverage, parameter_Coverage) | ||
140 | )); | ||
141 | // InterferometryMission.observationTime(Mission, ObservationTime) | ||
142 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
143 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); | ||
145 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); | ||
146 | new Equality(body, var__virtual_0_, var_ObservationTime); | ||
147 | // ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _) | ||
148 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
149 | new PatternMatchCounter(body, Tuples.flatTupleOf(var_Mission, var___0_), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation(), var__virtual_1_); | ||
150 | new Equality(body, var_ObserverCount, var__virtual_1_); | ||
151 | // Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9 * (1.0 / ObservationTime)) + 0.05 * ObservationTime / 3) | ||
152 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
153 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
154 | |||
155 | @Override | ||
156 | public String getShortDescription() { | ||
157 | return "Expression evaluation from pattern missionCoverage"; | ||
158 | } | ||
159 | |||
160 | @Override | ||
161 | public Iterable<String> getInputParameterNames() { | ||
162 | return Arrays.asList("ObservationTime", "ObserverCount");} | ||
163 | |||
164 | @Override | ||
165 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
166 | Float ObservationTime = (Float) provider.getValue("ObservationTime"); | ||
167 | Integer ObserverCount = (Integer) provider.getValue("ObserverCount"); | ||
168 | return evaluateExpression_1_1(ObservationTime, ObserverCount); | ||
169 | } | ||
170 | }, var__virtual_2_ ); | ||
171 | new Equality(body, var_Coverage, var__virtual_2_); | ||
172 | bodies.add(body); | ||
173 | } | ||
174 | return bodies; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | private static double evaluateExpression_1_1(final Float ObservationTime, final Integer ObserverCount) { | ||
179 | double _pow = Math.pow((1 - (2.0 / (ObserverCount).intValue())), (1 + (9 * (1.0 / (ObservationTime).floatValue())))); | ||
180 | double _plus = (_pow + ((0.05 * (ObservationTime).floatValue()) / 3)); | ||
181 | return _plus; | ||
182 | } | ||
183 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java new file mode 100644 index 00000000..3ad42bf5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java | |||
@@ -0,0 +1,183 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.EDataType; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
35 | |||
36 | /** | ||
37 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
38 | * | ||
39 | * <p>Original source: | ||
40 | * <code><pre> | ||
41 | * private pattern missionTime(Mission : InterferometryMission, Time : java Double) { | ||
42 | * InterferometryMission.observationTime(Mission, ObservationTime); | ||
43 | * TrasmitTime == sum find transmitTime(Mission, _, #_); | ||
44 | * Time == eval(TrasmitTime + 60.0 ObservationTime); | ||
45 | * } | ||
46 | * </pre></code> | ||
47 | * | ||
48 | * @see GenericPatternMatcher | ||
49 | * @see GenericPatternMatch | ||
50 | * | ||
51 | */ | ||
52 | @SuppressWarnings("all") | ||
53 | public final class MissionTime extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
54 | private MissionTime() { | ||
55 | super(GeneratedPQuery.INSTANCE); | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * @return the singleton instance of the query specification | ||
60 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
61 | * | ||
62 | */ | ||
63 | public static MissionTime instance() { | ||
64 | try{ | ||
65 | return LazyHolder.INSTANCE; | ||
66 | } catch (ExceptionInInitializerError err) { | ||
67 | throw processInitializerError(err); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime (visibility: PUBLIC, simpleName: MissionTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
73 | * <b>not</b> at the class load time of the outer class, | ||
74 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime (visibility: PUBLIC, simpleName: MissionTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
75 | * | ||
76 | * <p> This workaround is required e.g. to support recursion. | ||
77 | * | ||
78 | */ | ||
79 | private static class LazyHolder { | ||
80 | private static final MissionTime INSTANCE = new MissionTime(); | ||
81 | |||
82 | /** | ||
83 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
84 | * This initialization order is required to support indirect recursion. | ||
85 | * | ||
86 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
87 | * | ||
88 | */ | ||
89 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
90 | |||
91 | public static Object ensureInitialized() { | ||
92 | INSTANCE.ensureInitializedInternal(); | ||
93 | return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
98 | private static final MissionTime.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
99 | |||
100 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
101 | |||
102 | private final PParameter parameter_Time = new PParameter("Time", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
103 | |||
104 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Time); | ||
105 | |||
106 | private GeneratedPQuery() { | ||
107 | super(PVisibility.PRIVATE); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public String getFullyQualifiedName() { | ||
112 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.missionTime"; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<String> getParameterNames() { | ||
117 | return Arrays.asList("Mission","Time"); | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<PParameter> getParameters() { | ||
122 | return parameters; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Set<PBody> doGetContainedBodies() { | ||
127 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
128 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
129 | { | ||
130 | PBody body = new PBody(this); | ||
131 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
132 | PVariable var_Time = body.getOrCreateVariableByName("Time"); | ||
133 | PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); | ||
134 | PVariable var_TrasmitTime = body.getOrCreateVariableByName("TrasmitTime"); | ||
135 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
136 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
137 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
138 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Time), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
139 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
140 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
141 | new ExportedParameter(body, var_Time, parameter_Time) | ||
142 | )); | ||
143 | // InterferometryMission.observationTime(Mission, ObservationTime) | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
145 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); | ||
147 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); | ||
148 | new Equality(body, var__virtual_0_, var_ObservationTime); | ||
149 | // TrasmitTime == sum find transmitTime(Mission, _, #_) | ||
150 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
151 | new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Mission, var___0_, var___1_), TransmitTime.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); | ||
152 | new Equality(body, var_TrasmitTime, var__virtual_1_); | ||
153 | // Time == eval(TrasmitTime + 60.0 * ObservationTime) | ||
154 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
155 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
156 | |||
157 | @Override | ||
158 | public String getShortDescription() { | ||
159 | return "Expression evaluation from pattern missionTime"; | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public Iterable<String> getInputParameterNames() { | ||
164 | return Arrays.asList("ObservationTime", "TrasmitTime");} | ||
165 | |||
166 | @Override | ||
167 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
168 | Float ObservationTime = (Float) provider.getValue("ObservationTime"); | ||
169 | Double TrasmitTime = (Double) provider.getValue("TrasmitTime"); | ||
170 | return evaluateExpression_1_1(ObservationTime, TrasmitTime); | ||
171 | } | ||
172 | }, var__virtual_2_ ); | ||
173 | new Equality(body, var_Time, var__virtual_2_); | ||
174 | bodies.add(body); | ||
175 | } | ||
176 | return bodies; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | private static double evaluateExpression_1_1(final Float ObservationTime, final Double TrasmitTime) { | ||
181 | return ((TrasmitTime).doubleValue() + (60.0 * (ObservationTime).floatValue())); | ||
182 | } | ||
183 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java new file mode 100644 index 00000000..2f310711 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java | |||
@@ -0,0 +1,156 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric; | ||
10 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna; | ||
11 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand; | ||
12 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain; | ||
13 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow; | ||
14 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation; | ||
15 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads; | ||
16 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink; | ||
17 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric; | ||
18 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow; | ||
19 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium; | ||
20 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost; | ||
21 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads; | ||
22 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice; | ||
23 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand; | ||
24 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf; | ||
25 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain; | ||
26 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainLow; | ||
27 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium; | ||
28 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink; | ||
29 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork; | ||
30 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData; | ||
31 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink; | ||
32 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost; | ||
33 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost; | ||
34 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage; | ||
35 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime; | ||
36 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData; | ||
37 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat; | ||
38 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost; | ||
39 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind; | ||
40 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink; | ||
41 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; | ||
42 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems; | ||
43 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate; | ||
44 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime; | ||
45 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
46 | |||
47 | /** | ||
48 | * A pattern group formed of all patterns defined in SatelliteQueries.vql. | ||
49 | * | ||
50 | * <p>A private group that includes private patterns as well. Only intended use case is for pattern testing. | ||
51 | * | ||
52 | * <p> From package hu.bme.mit.inf.dslreasoner.domains.satellite.queries, the group contains the definition of the following patterns: <ul> | ||
53 | * <li>communicationLinkDoesNotStartAtContainingElement</li> | ||
54 | * <li>notEnoughInterferometryPayloads</li> | ||
55 | * <li>atLeastTwoInterferometryPayloads</li> | ||
56 | * <li>spacecraftWithInterferometryPayload</li> | ||
57 | * <li>noLinkToGroundStation</li> | ||
58 | * <li>communicationLoop</li> | ||
59 | * <li>indirectCommunicationLink</li> | ||
60 | * <li>directCommunicationLink</li> | ||
61 | * <li>incompatibleSourceAndTargetBand</li> | ||
62 | * <li>commSubsystemBand</li> | ||
63 | * <li>incompatibleSourceAndTargetGain</li> | ||
64 | * <li>commSubsystemGain</li> | ||
65 | * <li>uhfAntennaGainNotLow</li> | ||
66 | * <li>commSubsystemGainLow</li> | ||
67 | * <li>xAntennaGainNotMedium</li> | ||
68 | * <li>commSubsystemGainMedium</li> | ||
69 | * <li>kaAntennaGainLow</li> | ||
70 | * <li>threeUCubeSatWithNonUhfCrossLink</li> | ||
71 | * <li>commSubsystemBandUhf</li> | ||
72 | * <li>groundStationNetwork</li> | ||
73 | * <li>cubeSatWithKaAntenna</li> | ||
74 | * <li>smallSat</li> | ||
75 | * <li>coverageMetric</li> | ||
76 | * <li>missionCoverage</li> | ||
77 | * <li>timeMetric</li> | ||
78 | * <li>missionTime</li> | ||
79 | * <li>transmitTime</li> | ||
80 | * <li>incomingData</li> | ||
81 | * <li>scienceData</li> | ||
82 | * <li>transmitRate</li> | ||
83 | * <li>spacecraftUplink</li> | ||
84 | * <li>costMetric</li> | ||
85 | * <li>missionCost</li> | ||
86 | * <li>spacecraftCost</li> | ||
87 | * <li>spacecraftOfKind</li> | ||
88 | * <li>basePrice</li> | ||
89 | * <li>interferometryPayloadCost</li> | ||
90 | * <li>additionalCommSubsystemCost</li> | ||
91 | * <li>spacecraftWithTwoCommSubsystems</li> | ||
92 | * </ul> | ||
93 | * | ||
94 | * @see IQueryGroup | ||
95 | * | ||
96 | */ | ||
97 | @SuppressWarnings("all") | ||
98 | public final class SatelliteQueriesAll extends BaseGeneratedPatternGroup { | ||
99 | /** | ||
100 | * Access the pattern group. | ||
101 | * | ||
102 | * @return the singleton instance of the group | ||
103 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
104 | * | ||
105 | */ | ||
106 | public static SatelliteQueriesAll instance() { | ||
107 | if (INSTANCE == null) { | ||
108 | INSTANCE = new SatelliteQueriesAll(); | ||
109 | } | ||
110 | return INSTANCE; | ||
111 | } | ||
112 | |||
113 | private static SatelliteQueriesAll INSTANCE; | ||
114 | |||
115 | private SatelliteQueriesAll() { | ||
116 | querySpecifications.add(CommunicationLinkDoesNotStartAtContainingElement.instance()); | ||
117 | querySpecifications.add(NotEnoughInterferometryPayloads.instance()); | ||
118 | querySpecifications.add(AtLeastTwoInterferometryPayloads.instance()); | ||
119 | querySpecifications.add(SpacecraftWithInterferometryPayload.instance()); | ||
120 | querySpecifications.add(NoLinkToGroundStation.instance()); | ||
121 | querySpecifications.add(CommunicationLoop.instance()); | ||
122 | querySpecifications.add(IndirectCommunicationLink.instance()); | ||
123 | querySpecifications.add(DirectCommunicationLink.instance()); | ||
124 | querySpecifications.add(IncompatibleSourceAndTargetBand.instance()); | ||
125 | querySpecifications.add(CommSubsystemBand.instance()); | ||
126 | querySpecifications.add(IncompatibleSourceAndTargetGain.instance()); | ||
127 | querySpecifications.add(CommSubsystemGain.instance()); | ||
128 | querySpecifications.add(UhfAntennaGainNotLow.instance()); | ||
129 | querySpecifications.add(CommSubsystemGainLow.instance()); | ||
130 | querySpecifications.add(XAntennaGainNotMedium.instance()); | ||
131 | querySpecifications.add(CommSubsystemGainMedium.instance()); | ||
132 | querySpecifications.add(KaAntennaGainLow.instance()); | ||
133 | querySpecifications.add(ThreeUCubeSatWithNonUhfCrossLink.instance()); | ||
134 | querySpecifications.add(CommSubsystemBandUhf.instance()); | ||
135 | querySpecifications.add(GroundStationNetwork.instance()); | ||
136 | querySpecifications.add(CubeSatWithKaAntenna.instance()); | ||
137 | querySpecifications.add(SmallSat.instance()); | ||
138 | querySpecifications.add(CoverageMetric.instance()); | ||
139 | querySpecifications.add(MissionCoverage.instance()); | ||
140 | querySpecifications.add(TimeMetric.instance()); | ||
141 | querySpecifications.add(MissionTime.instance()); | ||
142 | querySpecifications.add(TransmitTime.instance()); | ||
143 | querySpecifications.add(IncomingData.instance()); | ||
144 | querySpecifications.add(ScienceData.instance()); | ||
145 | querySpecifications.add(TransmitRate.instance()); | ||
146 | querySpecifications.add(SpacecraftUplink.instance()); | ||
147 | querySpecifications.add(CostMetric.instance()); | ||
148 | querySpecifications.add(MissionCost.instance()); | ||
149 | querySpecifications.add(SpacecraftCost.instance()); | ||
150 | querySpecifications.add(SpacecraftOfKind.instance()); | ||
151 | querySpecifications.add(BasePrice.instance()); | ||
152 | querySpecifications.add(InterferometryPayloadCost.instance()); | ||
153 | querySpecifications.add(AdditionalCommSubsystemCost.instance()); | ||
154 | querySpecifications.add(SpacecraftWithTwoCommSubsystems.instance()); | ||
155 | } | ||
156 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java new file mode 100644 index 00000000..b558e51e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java | |||
@@ -0,0 +1,179 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
32 | |||
33 | /** | ||
34 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
35 | * | ||
36 | * <p>Original source: | ||
37 | * <code><pre> | ||
38 | * private pattern scienceData(Spacecraft : Spacecraft, Data : java Double) { | ||
39 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
40 | * InterferometryMission.observationTime(Mission, ObservationTime); | ||
41 | * Data == eval(12.0 ObservationTime); | ||
42 | * } | ||
43 | * </pre></code> | ||
44 | * | ||
45 | * @see GenericPatternMatcher | ||
46 | * @see GenericPatternMatch | ||
47 | * | ||
48 | */ | ||
49 | @SuppressWarnings("all") | ||
50 | public final class ScienceData extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
51 | private ScienceData() { | ||
52 | super(GeneratedPQuery.INSTANCE); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return the singleton instance of the query specification | ||
57 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
58 | * | ||
59 | */ | ||
60 | public static ScienceData instance() { | ||
61 | try{ | ||
62 | return LazyHolder.INSTANCE; | ||
63 | } catch (ExceptionInInitializerError err) { | ||
64 | throw processInitializerError(err); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData (visibility: PUBLIC, simpleName: ScienceData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
70 | * <b>not</b> at the class load time of the outer class, | ||
71 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData (visibility: PUBLIC, simpleName: ScienceData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
72 | * | ||
73 | * <p> This workaround is required e.g. to support recursion. | ||
74 | * | ||
75 | */ | ||
76 | private static class LazyHolder { | ||
77 | private static final ScienceData INSTANCE = new ScienceData(); | ||
78 | |||
79 | /** | ||
80 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
81 | * This initialization order is required to support indirect recursion. | ||
82 | * | ||
83 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
84 | * | ||
85 | */ | ||
86 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
87 | |||
88 | public static Object ensureInitialized() { | ||
89 | INSTANCE.ensureInitializedInternal(); | ||
90 | return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
95 | private static final ScienceData.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
96 | |||
97 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final PParameter parameter_Data = new PParameter("Data", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
100 | |||
101 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_Data); | ||
102 | |||
103 | private GeneratedPQuery() { | ||
104 | super(PVisibility.PRIVATE); | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public String getFullyQualifiedName() { | ||
109 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.scienceData"; | ||
110 | } | ||
111 | |||
112 | @Override | ||
113 | public List<String> getParameterNames() { | ||
114 | return Arrays.asList("Spacecraft","Data"); | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public List<PParameter> getParameters() { | ||
119 | return parameters; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public Set<PBody> doGetContainedBodies() { | ||
124 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
125 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
126 | { | ||
127 | PBody body = new PBody(this); | ||
128 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
129 | PVariable var_Data = body.getOrCreateVariableByName("Data"); | ||
130 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
131 | PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
133 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Data), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
134 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
135 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
136 | new ExportedParameter(body, var_Data, parameter_Data) | ||
137 | )); | ||
138 | // ConstellationMission.spacecraft(Mission, Spacecraft) | ||
139 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
140 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
141 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); | ||
142 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
143 | new Equality(body, var__virtual_0_, var_Spacecraft); | ||
144 | // InterferometryMission.observationTime(Mission, ObservationTime) | ||
145 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
146 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
147 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); | ||
148 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); | ||
149 | new Equality(body, var__virtual_1_, var_ObservationTime); | ||
150 | // Data == eval(12.0 * ObservationTime) | ||
151 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
152 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
153 | |||
154 | @Override | ||
155 | public String getShortDescription() { | ||
156 | return "Expression evaluation from pattern scienceData"; | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public Iterable<String> getInputParameterNames() { | ||
161 | return Arrays.asList("ObservationTime");} | ||
162 | |||
163 | @Override | ||
164 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
165 | Float ObservationTime = (Float) provider.getValue("ObservationTime"); | ||
166 | return evaluateExpression_1_1(ObservationTime); | ||
167 | } | ||
168 | }, var__virtual_2_ ); | ||
169 | new Equality(body, var_Data, var__virtual_2_); | ||
170 | bodies.add(body); | ||
171 | } | ||
172 | return bodies; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | private static double evaluateExpression_1_1(final Float ObservationTime) { | ||
177 | return (12.0 * (ObservationTime).floatValue()); | ||
178 | } | ||
179 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java new file mode 100644 index 00000000..d74ed28a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java | |||
@@ -0,0 +1,138 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
28 | |||
29 | /** | ||
30 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
31 | * | ||
32 | * <p>Original source: | ||
33 | * <code><pre> | ||
34 | * private pattern smallSat(Sat : Spacecraft) { | ||
35 | * Spacecraft.kind(Sat, SpacecraftKind::SmallSat); | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class SmallSat extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private SmallSat() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static SmallSat instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat (visibility: PUBLIC, simpleName: SmallSat, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat (visibility: PUBLIC, simpleName: SmallSat, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final SmallSat INSTANCE = new SmallSat(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final SmallSat.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Sat = new PParameter("Sat", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_Sat); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.smallSat"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("Sat"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_Sat = body.getOrCreateVariableByName("Sat"); | ||
121 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
122 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
123 | new ExportedParameter(body, var_Sat, parameter_Sat) | ||
124 | )); | ||
125 | // Spacecraft.kind(Sat, SpacecraftKind::SmallSat) | ||
126 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
127 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "SmallSat").getInstance()); | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
129 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
132 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
133 | bodies.add(body); | ||
134 | } | ||
135 | return bodies; | ||
136 | } | ||
137 | } | ||
138 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java new file mode 100644 index 00000000..65fed74a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java | |||
@@ -0,0 +1,215 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind; | ||
10 | import java.util.Arrays; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Set; | ||
14 | import org.eclipse.emf.ecore.EClass; | ||
15 | import org.eclipse.emf.ecore.EDataType; | ||
16 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
17 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
18 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
19 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
20 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
38 | |||
39 | /** | ||
40 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
41 | * | ||
42 | * <p>Original source: | ||
43 | * <code><pre> | ||
44 | * private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spacecraft, Cost : java Double) { | ||
45 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
46 | * Spacecraft.kind(Spacecraft, Kind); | ||
47 | * KindCount == count find spacecraftOfKind(_, Kind); | ||
48 | * find basePrice(Spacecraft, BasePrice); | ||
49 | * find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost); | ||
50 | * find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost); | ||
51 | * Cost == eval(BasePrice Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see GenericPatternMatcher | ||
56 | * @see GenericPatternMatch | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class SpacecraftCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
61 | private SpacecraftCost() { | ||
62 | super(GeneratedPQuery.INSTANCE); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * @return the singleton instance of the query specification | ||
67 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
68 | * | ||
69 | */ | ||
70 | public static SpacecraftCost instance() { | ||
71 | try{ | ||
72 | return LazyHolder.INSTANCE; | ||
73 | } catch (ExceptionInInitializerError err) { | ||
74 | throw processInitializerError(err); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost (visibility: PUBLIC, simpleName: SpacecraftCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
80 | * <b>not</b> at the class load time of the outer class, | ||
81 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost (visibility: PUBLIC, simpleName: SpacecraftCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
82 | * | ||
83 | * <p> This workaround is required e.g. to support recursion. | ||
84 | * | ||
85 | */ | ||
86 | private static class LazyHolder { | ||
87 | private static final SpacecraftCost INSTANCE = new SpacecraftCost(); | ||
88 | |||
89 | /** | ||
90 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
91 | * This initialization order is required to support indirect recursion. | ||
92 | * | ||
93 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
94 | * | ||
95 | */ | ||
96 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
97 | |||
98 | public static Object ensureInitialized() { | ||
99 | INSTANCE.ensureInitializedInternal(); | ||
100 | return null; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
105 | private static final SpacecraftCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
106 | |||
107 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
108 | |||
109 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
110 | |||
111 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
112 | |||
113 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft, parameter_Cost); | ||
114 | |||
115 | private GeneratedPQuery() { | ||
116 | super(PVisibility.PRIVATE); | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String getFullyQualifiedName() { | ||
121 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftCost"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> getParameterNames() { | ||
126 | return Arrays.asList("Mission","Spacecraft","Cost"); | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public List<PParameter> getParameters() { | ||
131 | return parameters; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public Set<PBody> doGetContainedBodies() { | ||
136 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
137 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
138 | { | ||
139 | PBody body = new PBody(this); | ||
140 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
141 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
142 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
143 | PVariable var_Kind = body.getOrCreateVariableByName("Kind"); | ||
144 | PVariable var_KindCount = body.getOrCreateVariableByName("KindCount"); | ||
145 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
146 | PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); | ||
147 | PVariable var_InterferometryPayloadCost = body.getOrCreateVariableByName("InterferometryPayloadCost"); | ||
148 | PVariable var_AdditionalCommSubsystemCost = body.getOrCreateVariableByName("AdditionalCommSubsystemCost"); | ||
149 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
150 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
151 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
152 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
153 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
154 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
155 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
156 | )); | ||
157 | // ConstellationMission.spacecraft(Mission, Spacecraft) | ||
158 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
159 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
160 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); | ||
161 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
162 | new Equality(body, var__virtual_0_, var_Spacecraft); | ||
163 | // Spacecraft.kind(Spacecraft, Kind) | ||
164 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
165 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
166 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
167 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
168 | new Equality(body, var__virtual_1_, var_Kind); | ||
169 | // KindCount == count find spacecraftOfKind(_, Kind) | ||
170 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
171 | new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_, var_Kind), SpacecraftOfKind.instance().getInternalQueryRepresentation(), var__virtual_2_); | ||
172 | new Equality(body, var_KindCount, var__virtual_2_); | ||
173 | // find basePrice(Spacecraft, BasePrice) | ||
174 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_BasePrice), BasePrice.instance().getInternalQueryRepresentation()); | ||
175 | // find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost) | ||
176 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_InterferometryPayloadCost), InterferometryPayloadCost.instance().getInternalQueryRepresentation()); | ||
177 | // find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost) | ||
178 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_AdditionalCommSubsystemCost), AdditionalCommSubsystemCost.instance().getInternalQueryRepresentation()); | ||
179 | // Cost == eval(BasePrice * Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost) | ||
180 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
181 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
182 | |||
183 | @Override | ||
184 | public String getShortDescription() { | ||
185 | return "Expression evaluation from pattern spacecraftCost"; | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | public Iterable<String> getInputParameterNames() { | ||
190 | return Arrays.asList("AdditionalCommSubsystemCost", "BasePrice", "InterferometryPayloadCost", "KindCount");} | ||
191 | |||
192 | @Override | ||
193 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
194 | Double AdditionalCommSubsystemCost = (Double) provider.getValue("AdditionalCommSubsystemCost"); | ||
195 | Double BasePrice = (Double) provider.getValue("BasePrice"); | ||
196 | Double InterferometryPayloadCost = (Double) provider.getValue("InterferometryPayloadCost"); | ||
197 | Integer KindCount = (Integer) provider.getValue("KindCount"); | ||
198 | return evaluateExpression_1_1(AdditionalCommSubsystemCost, BasePrice, InterferometryPayloadCost, KindCount); | ||
199 | } | ||
200 | }, var__virtual_3_ ); | ||
201 | new Equality(body, var_Cost, var__virtual_3_); | ||
202 | bodies.add(body); | ||
203 | } | ||
204 | return bodies; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | private static double evaluateExpression_1_1(final Double AdditionalCommSubsystemCost, final Double BasePrice, final Double InterferometryPayloadCost, final Integer KindCount) { | ||
209 | double _pow = Math.pow((KindCount).intValue(), (-0.25)); | ||
210 | double _multiply = ((BasePrice).doubleValue() * _pow); | ||
211 | double _plus = (_multiply + (InterferometryPayloadCost).doubleValue()); | ||
212 | double _plus_1 = (_plus + (AdditionalCommSubsystemCost).doubleValue()); | ||
213 | return _plus_1; | ||
214 | } | ||
215 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java new file mode 100644 index 00000000..5e49aa58 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java | |||
@@ -0,0 +1,140 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern spacecraftOfKind(Spacecraft : Spacecraft, Kind : SpacecraftKind) { | ||
34 | * Spacecraft.kind(Spacecraft, Kind); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class SpacecraftOfKind extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private SpacecraftOfKind() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static SpacecraftOfKind instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind (visibility: PUBLIC, simpleName: SpacecraftOfKind, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind (visibility: PUBLIC, simpleName: SpacecraftOfKind, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final SpacecraftOfKind INSTANCE = new SpacecraftOfKind(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final SpacecraftOfKind.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_Kind = new PParameter("Kind", "hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "SpacecraftKind")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_Kind); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftOfKind"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Spacecraft","Kind"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
122 | PVariable var_Kind = body.getOrCreateVariableByName("Kind"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Kind), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
125 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
126 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
127 | new ExportedParameter(body, var_Kind, parameter_Kind) | ||
128 | )); | ||
129 | // Spacecraft.kind(Spacecraft, Kind) | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
131 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
134 | new Equality(body, var__virtual_0_, var_Kind); | ||
135 | bodies.add(body); | ||
136 | } | ||
137 | return bodies; | ||
138 | } | ||
139 | } | ||
140 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java new file mode 100644 index 00000000..966ff6f8 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java | |||
@@ -0,0 +1,171 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.emf.ecore.EDataType; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
27 | |||
28 | /** | ||
29 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
30 | * | ||
31 | * <p>Original source: | ||
32 | * <code><pre> | ||
33 | * private pattern spacecraftUplink(Spacecraft : Spacecraft, Band : TransceiverBand, Target : CommunicatingElement) { | ||
34 | * CommunicatingElement.communicationLink(Spacecraft, Link); | ||
35 | * DirectedCommunicationLink.source.band(Link, Band); | ||
36 | * DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
37 | * CommunicatingElement.commSubsystem(Target, TargetSubsystem); | ||
38 | * } | ||
39 | * </pre></code> | ||
40 | * | ||
41 | * @see GenericPatternMatcher | ||
42 | * @see GenericPatternMatch | ||
43 | * | ||
44 | */ | ||
45 | @SuppressWarnings("all") | ||
46 | public final class SpacecraftUplink extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
47 | private SpacecraftUplink() { | ||
48 | super(GeneratedPQuery.INSTANCE); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @return the singleton instance of the query specification | ||
53 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
54 | * | ||
55 | */ | ||
56 | public static SpacecraftUplink instance() { | ||
57 | try{ | ||
58 | return LazyHolder.INSTANCE; | ||
59 | } catch (ExceptionInInitializerError err) { | ||
60 | throw processInitializerError(err); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink (visibility: PUBLIC, simpleName: SpacecraftUplink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
66 | * <b>not</b> at the class load time of the outer class, | ||
67 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink (visibility: PUBLIC, simpleName: SpacecraftUplink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
68 | * | ||
69 | * <p> This workaround is required e.g. to support recursion. | ||
70 | * | ||
71 | */ | ||
72 | private static class LazyHolder { | ||
73 | private static final SpacecraftUplink INSTANCE = new SpacecraftUplink(); | ||
74 | |||
75 | /** | ||
76 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
77 | * This initialization order is required to support indirect recursion. | ||
78 | * | ||
79 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
80 | * | ||
81 | */ | ||
82 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
83 | |||
84 | public static Object ensureInitialized() { | ||
85 | INSTANCE.ensureInitializedInternal(); | ||
86 | return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
91 | private static final SpacecraftUplink.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
92 | |||
93 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
94 | |||
95 | private final PParameter parameter_Band = new PParameter("Band", "hu.bme.mit.inf.dslreasoner.domains.satellite.TransceiverBand", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "TransceiverBand")), PParameterDirection.INOUT); | ||
96 | |||
97 | private final PParameter parameter_Target = new PParameter("Target", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); | ||
98 | |||
99 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_Band, parameter_Target); | ||
100 | |||
101 | private GeneratedPQuery() { | ||
102 | super(PVisibility.PRIVATE); | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public String getFullyQualifiedName() { | ||
107 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftUplink"; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<String> getParameterNames() { | ||
112 | return Arrays.asList("Spacecraft","Band","Target"); | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public List<PParameter> getParameters() { | ||
117 | return parameters; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public Set<PBody> doGetContainedBodies() { | ||
122 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
123 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
124 | { | ||
125 | PBody body = new PBody(this); | ||
126 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
127 | PVariable var_Band = body.getOrCreateVariableByName("Band"); | ||
128 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
129 | PVariable var_Link = body.getOrCreateVariableByName("Link"); | ||
130 | PVariable var_TargetSubsystem = body.getOrCreateVariableByName("TargetSubsystem"); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
132 | new TypeConstraint(body, Tuples.flatTupleOf(var_Band), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
134 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
135 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
136 | new ExportedParameter(body, var_Band, parameter_Band), | ||
137 | new ExportedParameter(body, var_Target, parameter_Target) | ||
138 | )); | ||
139 | // CommunicatingElement.communicationLink(Spacecraft, Link) | ||
140 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
141 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
142 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "communicationLink"))); | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
144 | new Equality(body, var__virtual_0_, var_Link); | ||
145 | // DirectedCommunicationLink.source.band(Link, Band) | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
147 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
148 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); | ||
149 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
150 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
151 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); | ||
152 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); | ||
153 | new Equality(body, var__virtual_2_, var_Band); | ||
154 | // DirectedCommunicationLink.target(Link, TargetSubsystem) | ||
155 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); | ||
156 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
157 | new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); | ||
158 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
159 | new Equality(body, var__virtual_3_, var_TargetSubsystem); | ||
160 | // CommunicatingElement.commSubsystem(Target, TargetSubsystem) | ||
161 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); | ||
162 | PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); | ||
163 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
164 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
165 | new Equality(body, var__virtual_4_, var_TargetSubsystem); | ||
166 | bodies.add(body); | ||
167 | } | ||
168 | return bodies; | ||
169 | } | ||
170 | } | ||
171 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithInterferometryPayload.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithInterferometryPayload.java new file mode 100644 index 00000000..f8e6ca4f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithInterferometryPayload.java | |||
@@ -0,0 +1,149 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
25 | |||
26 | /** | ||
27 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
28 | * | ||
29 | * <p>Original source: | ||
30 | * <code><pre> | ||
31 | * private pattern spacecraftWithInterferometryPayload(Mission : ConstellationMission, Spacecraft : Spacecraft) { | ||
32 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
33 | * Spacecraft.payload(Spacecraft, Payload); | ||
34 | * InterferometryPayload(Payload); | ||
35 | * } | ||
36 | * </pre></code> | ||
37 | * | ||
38 | * @see GenericPatternMatcher | ||
39 | * @see GenericPatternMatch | ||
40 | * | ||
41 | */ | ||
42 | @SuppressWarnings("all") | ||
43 | public final class SpacecraftWithInterferometryPayload extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
44 | private SpacecraftWithInterferometryPayload() { | ||
45 | super(GeneratedPQuery.INSTANCE); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @return the singleton instance of the query specification | ||
50 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
51 | * | ||
52 | */ | ||
53 | public static SpacecraftWithInterferometryPayload instance() { | ||
54 | try{ | ||
55 | return LazyHolder.INSTANCE; | ||
56 | } catch (ExceptionInInitializerError err) { | ||
57 | throw processInitializerError(err); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload (visibility: PUBLIC, simpleName: SpacecraftWithInterferometryPayload, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
63 | * <b>not</b> at the class load time of the outer class, | ||
64 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload (visibility: PUBLIC, simpleName: SpacecraftWithInterferometryPayload, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
65 | * | ||
66 | * <p> This workaround is required e.g. to support recursion. | ||
67 | * | ||
68 | */ | ||
69 | private static class LazyHolder { | ||
70 | private static final SpacecraftWithInterferometryPayload INSTANCE = new SpacecraftWithInterferometryPayload(); | ||
71 | |||
72 | /** | ||
73 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
74 | * This initialization order is required to support indirect recursion. | ||
75 | * | ||
76 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
77 | * | ||
78 | */ | ||
79 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
80 | |||
81 | public static Object ensureInitialized() { | ||
82 | INSTANCE.ensureInitializedInternal(); | ||
83 | return null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
88 | private static final SpacecraftWithInterferometryPayload.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
89 | |||
90 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.ConstellationMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "ConstellationMission")), PParameterDirection.INOUT); | ||
91 | |||
92 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
93 | |||
94 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft); | ||
95 | |||
96 | private GeneratedPQuery() { | ||
97 | super(PVisibility.PRIVATE); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public String getFullyQualifiedName() { | ||
102 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftWithInterferometryPayload"; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public List<String> getParameterNames() { | ||
107 | return Arrays.asList("Mission","Spacecraft"); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public List<PParameter> getParameters() { | ||
112 | return parameters; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public Set<PBody> doGetContainedBodies() { | ||
117 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
118 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
119 | { | ||
120 | PBody body = new PBody(this); | ||
121 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
122 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
123 | PVariable var_Payload = body.getOrCreateVariableByName("Payload"); | ||
124 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
125 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
126 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
127 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
128 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft) | ||
129 | )); | ||
130 | // ConstellationMission.spacecraft(Mission, Spacecraft) | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
132 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
133 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); | ||
134 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
135 | new Equality(body, var__virtual_0_, var_Spacecraft); | ||
136 | // Spacecraft.payload(Spacecraft, Payload) | ||
137 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
138 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
139 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "payload"))); | ||
140 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Payload"))); | ||
141 | new Equality(body, var__virtual_1_, var_Payload); | ||
142 | // InterferometryPayload(Payload) | ||
143 | new TypeConstraint(body, Tuples.flatTupleOf(var_Payload), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryPayload"))); | ||
144 | bodies.add(body); | ||
145 | } | ||
146 | return bodies; | ||
147 | } | ||
148 | } | ||
149 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java new file mode 100644 index 00000000..98f1be7b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java | |||
@@ -0,0 +1,146 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.LinkedHashSet; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.ecore.EClass; | ||
11 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
13 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
26 | |||
27 | /** | ||
28 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
29 | * | ||
30 | * <p>Original source: | ||
31 | * <code><pre> | ||
32 | * private pattern spacecraftWithTwoCommSubsystems(Spacecraft : Spacecraft) { | ||
33 | * Spacecraft.commSubsystem(Spacecraft, Subsystem1); | ||
34 | * Spacecraft.commSubsystem(Spacecraft, Subsystem2); | ||
35 | * Subsystem1 != Subsystem2; | ||
36 | * } | ||
37 | * </pre></code> | ||
38 | * | ||
39 | * @see GenericPatternMatcher | ||
40 | * @see GenericPatternMatch | ||
41 | * | ||
42 | */ | ||
43 | @SuppressWarnings("all") | ||
44 | public final class SpacecraftWithTwoCommSubsystems extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
45 | private SpacecraftWithTwoCommSubsystems() { | ||
46 | super(GeneratedPQuery.INSTANCE); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @return the singleton instance of the query specification | ||
51 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
52 | * | ||
53 | */ | ||
54 | public static SpacecraftWithTwoCommSubsystems instance() { | ||
55 | try{ | ||
56 | return LazyHolder.INSTANCE; | ||
57 | } catch (ExceptionInInitializerError err) { | ||
58 | throw processInitializerError(err); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems (visibility: PUBLIC, simpleName: SpacecraftWithTwoCommSubsystems, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
64 | * <b>not</b> at the class load time of the outer class, | ||
65 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems (visibility: PUBLIC, simpleName: SpacecraftWithTwoCommSubsystems, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
66 | * | ||
67 | * <p> This workaround is required e.g. to support recursion. | ||
68 | * | ||
69 | */ | ||
70 | private static class LazyHolder { | ||
71 | private static final SpacecraftWithTwoCommSubsystems INSTANCE = new SpacecraftWithTwoCommSubsystems(); | ||
72 | |||
73 | /** | ||
74 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
75 | * This initialization order is required to support indirect recursion. | ||
76 | * | ||
77 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
78 | * | ||
79 | */ | ||
80 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
81 | |||
82 | public static Object ensureInitialized() { | ||
83 | INSTANCE.ensureInitializedInternal(); | ||
84 | return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
89 | private static final SpacecraftWithTwoCommSubsystems.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
90 | |||
91 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
92 | |||
93 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft); | ||
94 | |||
95 | private GeneratedPQuery() { | ||
96 | super(PVisibility.PRIVATE); | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public String getFullyQualifiedName() { | ||
101 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftWithTwoCommSubsystems"; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public List<String> getParameterNames() { | ||
106 | return Arrays.asList("Spacecraft"); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public List<PParameter> getParameters() { | ||
111 | return parameters; | ||
112 | } | ||
113 | |||
114 | @Override | ||
115 | public Set<PBody> doGetContainedBodies() { | ||
116 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
117 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
118 | { | ||
119 | PBody body = new PBody(this); | ||
120 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
121 | PVariable var_Subsystem1 = body.getOrCreateVariableByName("Subsystem1"); | ||
122 | PVariable var_Subsystem2 = body.getOrCreateVariableByName("Subsystem2"); | ||
123 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
124 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
125 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft) | ||
126 | )); | ||
127 | // Spacecraft.commSubsystem(Spacecraft, Subsystem1) | ||
128 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
129 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
130 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
131 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
132 | new Equality(body, var__virtual_0_, var_Subsystem1); | ||
133 | // Spacecraft.commSubsystem(Spacecraft, Subsystem2) | ||
134 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
135 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
136 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); | ||
137 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); | ||
138 | new Equality(body, var__virtual_1_, var_Subsystem2); | ||
139 | // Subsystem1 != Subsystem2 | ||
140 | new Inequality(body, var_Subsystem1, var_Subsystem2); | ||
141 | bodies.add(body); | ||
142 | } | ||
143 | return bodies; | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java new file mode 100644 index 00000000..2faa7733 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java | |||
@@ -0,0 +1,277 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
13 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
14 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
29 | |||
30 | /** | ||
31 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
32 | * | ||
33 | * <p>Original source: | ||
34 | * <code><pre> | ||
35 | * private pattern transmitRate(Spacecraft : Spacecraft, TransmitRate : java Double) { | ||
36 | * find spacecraftUplink(Spacecraft, TransceiverBand::UHF, Target); | ||
37 | * Spacecraft(Target); | ||
38 | * TransmitRate == 5.0; | ||
39 | * } or { | ||
40 | * find spacecraftUplink(Spacecraft, TransceiverBand::X, Target); | ||
41 | * Spacecraft(Target); | ||
42 | * TransmitRate == 1.6; | ||
43 | * } or { | ||
44 | * find spacecraftUplink(Spacecraft, TransceiverBand::X, Target); | ||
45 | * GroundStationNetwork(Target); | ||
46 | * TransmitRate == 0.7; | ||
47 | * } or { | ||
48 | * find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target); | ||
49 | * Spacecraft(Target); | ||
50 | * TransmitRate == 220.0; | ||
51 | * } or { | ||
52 | * find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target); | ||
53 | * GroundStationNetwork(Target); | ||
54 | * TransmitRate == 80.0; | ||
55 | * } | ||
56 | * </pre></code> | ||
57 | * | ||
58 | * @see GenericPatternMatcher | ||
59 | * @see GenericPatternMatch | ||
60 | * | ||
61 | */ | ||
62 | @SuppressWarnings("all") | ||
63 | public final class TransmitRate extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
64 | private TransmitRate() { | ||
65 | super(GeneratedPQuery.INSTANCE); | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * @return the singleton instance of the query specification | ||
70 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
71 | * | ||
72 | */ | ||
73 | public static TransmitRate instance() { | ||
74 | try{ | ||
75 | return LazyHolder.INSTANCE; | ||
76 | } catch (ExceptionInInitializerError err) { | ||
77 | throw processInitializerError(err); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate (visibility: PUBLIC, simpleName: TransmitRate, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
83 | * <b>not</b> at the class load time of the outer class, | ||
84 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate (visibility: PUBLIC, simpleName: TransmitRate, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
85 | * | ||
86 | * <p> This workaround is required e.g. to support recursion. | ||
87 | * | ||
88 | */ | ||
89 | private static class LazyHolder { | ||
90 | private static final TransmitRate INSTANCE = new TransmitRate(); | ||
91 | |||
92 | /** | ||
93 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
94 | * This initialization order is required to support indirect recursion. | ||
95 | * | ||
96 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
97 | * | ||
98 | */ | ||
99 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
100 | |||
101 | public static Object ensureInitialized() { | ||
102 | INSTANCE.ensureInitializedInternal(); | ||
103 | return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
108 | private static final TransmitRate.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
109 | |||
110 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
111 | |||
112 | private final PParameter parameter_TransmitRate = new PParameter("TransmitRate", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
113 | |||
114 | private final List<PParameter> parameters = Arrays.asList(parameter_Spacecraft, parameter_TransmitRate); | ||
115 | |||
116 | private GeneratedPQuery() { | ||
117 | super(PVisibility.PRIVATE); | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public String getFullyQualifiedName() { | ||
122 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.transmitRate"; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public List<String> getParameterNames() { | ||
127 | return Arrays.asList("Spacecraft","TransmitRate"); | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public List<PParameter> getParameters() { | ||
132 | return parameters; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public Set<PBody> doGetContainedBodies() { | ||
137 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
138 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
139 | { | ||
140 | PBody body = new PBody(this); | ||
141 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
142 | PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); | ||
143 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
144 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
145 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
146 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
147 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
148 | new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) | ||
149 | )); | ||
150 | // find spacecraftUplink(Spacecraft, TransceiverBand::UHF, Target) | ||
151 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
152 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "UHF").getInstance()); | ||
153 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); | ||
154 | // Spacecraft(Target) | ||
155 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
156 | // TransmitRate == 5.0 | ||
157 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
158 | new ConstantValue(body, var__virtual_1_, 5.0); | ||
159 | new Equality(body, var_TransmitRate, var__virtual_1_); | ||
160 | bodies.add(body); | ||
161 | } | ||
162 | { | ||
163 | PBody body = new PBody(this); | ||
164 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
165 | PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); | ||
166 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
167 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
168 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
169 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
170 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
171 | new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) | ||
172 | )); | ||
173 | // find spacecraftUplink(Spacecraft, TransceiverBand::X, Target) | ||
174 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
175 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "X").getInstance()); | ||
176 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); | ||
177 | // Spacecraft(Target) | ||
178 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
179 | // TransmitRate == 1.6 | ||
180 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
181 | new ConstantValue(body, var__virtual_1_, 1.6); | ||
182 | new Equality(body, var_TransmitRate, var__virtual_1_); | ||
183 | bodies.add(body); | ||
184 | } | ||
185 | { | ||
186 | PBody body = new PBody(this); | ||
187 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
188 | PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); | ||
189 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
190 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
191 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
192 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
193 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
194 | new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) | ||
195 | )); | ||
196 | // find spacecraftUplink(Spacecraft, TransceiverBand::X, Target) | ||
197 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
198 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "X").getInstance()); | ||
199 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); | ||
200 | // GroundStationNetwork(Target) | ||
201 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); | ||
202 | // TransmitRate == 0.7 | ||
203 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
204 | new ConstantValue(body, var__virtual_1_, 0.7); | ||
205 | new Equality(body, var_TransmitRate, var__virtual_1_); | ||
206 | bodies.add(body); | ||
207 | } | ||
208 | { | ||
209 | PBody body = new PBody(this); | ||
210 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
211 | PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); | ||
212 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
213 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
214 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
215 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
216 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
217 | new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) | ||
218 | )); | ||
219 | // find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target) | ||
220 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
221 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "Ka").getInstance()); | ||
222 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); | ||
223 | // Spacecraft(Target) | ||
224 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
225 | // TransmitRate == 220.0 | ||
226 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
227 | new ConstantValue(body, var__virtual_1_, 220.0); | ||
228 | new Equality(body, var_TransmitRate, var__virtual_1_); | ||
229 | bodies.add(body); | ||
230 | } | ||
231 | { | ||
232 | PBody body = new PBody(this); | ||
233 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
234 | PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); | ||
235 | PVariable var_Target = body.getOrCreateVariableByName("Target"); | ||
236 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
237 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
238 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
239 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
240 | new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) | ||
241 | )); | ||
242 | // find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target) | ||
243 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
244 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "Ka").getInstance()); | ||
245 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); | ||
246 | // GroundStationNetwork(Target) | ||
247 | new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); | ||
248 | // TransmitRate == 80.0 | ||
249 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
250 | new ConstantValue(body, var__virtual_1_, 80.0); | ||
251 | new Equality(body, var_TransmitRate, var__virtual_1_); | ||
252 | bodies.add(body); | ||
253 | } | ||
254 | return bodies; | ||
255 | } | ||
256 | } | ||
257 | |||
258 | private static double evaluateExpression_1_1() { | ||
259 | return 5.0; | ||
260 | } | ||
261 | |||
262 | private static double evaluateExpression_2_1() { | ||
263 | return 1.6; | ||
264 | } | ||
265 | |||
266 | private static double evaluateExpression_3_1() { | ||
267 | return 0.7; | ||
268 | } | ||
269 | |||
270 | private static double evaluateExpression_4_1() { | ||
271 | return 220.0; | ||
272 | } | ||
273 | |||
274 | private static double evaluateExpression_5_1() { | ||
275 | return 80.0; | ||
276 | } | ||
277 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java new file mode 100644 index 00000000..eb338bec --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java | |||
@@ -0,0 +1,200 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
12 | import java.util.Set; | ||
13 | import org.eclipse.emf.ecore.EClass; | ||
14 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
15 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
16 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
17 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
36 | import org.eclipse.xtext.xbase.lib.DoubleExtensions; | ||
37 | |||
38 | /** | ||
39 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
40 | * | ||
41 | * <p>Original source: | ||
42 | * <code><pre> | ||
43 | * private pattern transmitTime(Mission : InterferometryMission, Spacecraft : Spacecraft, TransmitTime : java Double) { | ||
44 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
45 | * find scienceData(Spacecraft, ScienceData); | ||
46 | * IncomingData == sum find incomingData(Spacecraft, _, #_); | ||
47 | * find transmitRate(Spacecraft, TransmitRate); | ||
48 | * TransmitTime == eval((ScienceData + IncomingData) / (7.5 TransmitRate)); | ||
49 | * } | ||
50 | * </pre></code> | ||
51 | * | ||
52 | * @see GenericPatternMatcher | ||
53 | * @see GenericPatternMatch | ||
54 | * | ||
55 | */ | ||
56 | @SuppressWarnings("all") | ||
57 | public final class TransmitTime extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
58 | private TransmitTime() { | ||
59 | super(GeneratedPQuery.INSTANCE); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * @return the singleton instance of the query specification | ||
64 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
65 | * | ||
66 | */ | ||
67 | public static TransmitTime instance() { | ||
68 | try{ | ||
69 | return LazyHolder.INSTANCE; | ||
70 | } catch (ExceptionInInitializerError err) { | ||
71 | throw processInitializerError(err); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime (visibility: PUBLIC, simpleName: TransmitTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
77 | * <b>not</b> at the class load time of the outer class, | ||
78 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime (visibility: PUBLIC, simpleName: TransmitTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
79 | * | ||
80 | * <p> This workaround is required e.g. to support recursion. | ||
81 | * | ||
82 | */ | ||
83 | private static class LazyHolder { | ||
84 | private static final TransmitTime INSTANCE = new TransmitTime(); | ||
85 | |||
86 | /** | ||
87 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
88 | * This initialization order is required to support indirect recursion. | ||
89 | * | ||
90 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
91 | * | ||
92 | */ | ||
93 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
94 | |||
95 | public static Object ensureInitialized() { | ||
96 | INSTANCE.ensureInitializedInternal(); | ||
97 | return null; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
102 | private static final TransmitTime.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
103 | |||
104 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
105 | |||
106 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
107 | |||
108 | private final PParameter parameter_TransmitTime = new PParameter("TransmitTime", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
109 | |||
110 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft, parameter_TransmitTime); | ||
111 | |||
112 | private GeneratedPQuery() { | ||
113 | super(PVisibility.PRIVATE); | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String getFullyQualifiedName() { | ||
118 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.transmitTime"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> getParameterNames() { | ||
123 | return Arrays.asList("Mission","Spacecraft","TransmitTime"); | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<PParameter> getParameters() { | ||
128 | return parameters; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Set<PBody> doGetContainedBodies() { | ||
133 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
134 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
135 | { | ||
136 | PBody body = new PBody(this); | ||
137 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
138 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
139 | PVariable var_TransmitTime = body.getOrCreateVariableByName("TransmitTime"); | ||
140 | PVariable var_ScienceData = body.getOrCreateVariableByName("ScienceData"); | ||
141 | PVariable var_IncomingData = body.getOrCreateVariableByName("IncomingData"); | ||
142 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
143 | PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); | ||
144 | PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); | ||
145 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
146 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
147 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitTime), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
148 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
149 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
150 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
151 | new ExportedParameter(body, var_TransmitTime, parameter_TransmitTime) | ||
152 | )); | ||
153 | // ConstellationMission.spacecraft(Mission, Spacecraft) | ||
154 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
155 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
156 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); | ||
157 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
158 | new Equality(body, var__virtual_0_, var_Spacecraft); | ||
159 | // find scienceData(Spacecraft, ScienceData) | ||
160 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_ScienceData), ScienceData.instance().getInternalQueryRepresentation()); | ||
161 | // IncomingData == sum find incomingData(Spacecraft, _, #_) | ||
162 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
163 | new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Spacecraft, var___0_, var___1_), IncomingData.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); | ||
164 | new Equality(body, var_IncomingData, var__virtual_1_); | ||
165 | // find transmitRate(Spacecraft, TransmitRate) | ||
166 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_TransmitRate), TransmitRate.instance().getInternalQueryRepresentation()); | ||
167 | // TransmitTime == eval((ScienceData + IncomingData) / (7.5 * TransmitRate)) | ||
168 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
169 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
170 | |||
171 | @Override | ||
172 | public String getShortDescription() { | ||
173 | return "Expression evaluation from pattern transmitTime"; | ||
174 | } | ||
175 | |||
176 | @Override | ||
177 | public Iterable<String> getInputParameterNames() { | ||
178 | return Arrays.asList("IncomingData", "ScienceData", "TransmitRate");} | ||
179 | |||
180 | @Override | ||
181 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
182 | Double IncomingData = (Double) provider.getValue("IncomingData"); | ||
183 | Double ScienceData = (Double) provider.getValue("ScienceData"); | ||
184 | Double TransmitRate = (Double) provider.getValue("TransmitRate"); | ||
185 | return evaluateExpression_1_1(IncomingData, ScienceData, TransmitRate); | ||
186 | } | ||
187 | }, var__virtual_2_ ); | ||
188 | new Equality(body, var_TransmitTime, var__virtual_2_); | ||
189 | bodies.add(body); | ||
190 | } | ||
191 | return bodies; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | private static double evaluateExpression_1_1(final Double IncomingData, final Double ScienceData, final Double TransmitRate) { | ||
196 | double _plus = DoubleExtensions.operator_plus(ScienceData, IncomingData); | ||
197 | double _divide = (_plus / (7.5 * (TransmitRate).doubleValue())); | ||
198 | return _divide; | ||
199 | } | ||
200 | } | ||