diff options
author | 2019-02-07 18:24:45 +0100 | |
---|---|---|
committer | 2019-02-19 19:18:25 +0100 | |
commit | 6f88c4bd4e91728cea62505e893b0ce300baf7fc (patch) | |
tree | fef4d5cf7d28b0e4fd59a3b7181e60a2f236d235 /Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation | |
parent | Extract component fault tree model (diff) | |
download | VIATRA-Generator-6f88c4bd4e91728cea62505e893b0ce300baf7fc.tar.gz VIATRA-Generator-6f88c4bd4e91728cea62505e893b0ce300baf7fc.tar.zst VIATRA-Generator-6f88c4bd4e91728cea62505e893b0ce300baf7fc.zip |
Ecore2Cft transformation
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation')
21 files changed, 549 insertions, 0 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore new file mode 100644 index 00000000..49df59a2 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore | |||
@@ -0,0 +1,8 @@ | |||
1 | /.CftTransformation.java._trace | ||
2 | /.ComponentFaultTreeTrace.java._trace | ||
3 | /.ComponentInstanceTrace.java._trace | ||
4 | /.InputTrace.java._trace | ||
5 | /.MappingHandler.java._trace | ||
6 | /.ComponentInstantiationHandler.java._trace | ||
7 | /.MappingQueries.java._trace | ||
8 | /.LookupHandler.java._trace | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin new file mode 100644 index 00000000..3e751774 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore new file mode 100644 index 00000000..70156b02 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore | |||
@@ -0,0 +1 @@ | |||
/.Cft2FtTransformation.java._trace | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java new file mode 100644 index 00000000..ae750806 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
4 | |||
5 | @SuppressWarnings("all") | ||
6 | public class Cft2FtTransformation { | ||
7 | public void createFaultTree(final ComponentFaultTree componentFaultTree) { | ||
8 | throw new UnsupportedOperationException(); | ||
9 | } | ||
10 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbin new file mode 100644 index 00000000..d26ae359 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbin new file mode 100644 index 00000000..03d6064f --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbin new file mode 100644 index 00000000..1f6758ac --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbin new file mode 100644 index 00000000..3569c02f --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbin new file mode 100644 index 00000000..378550ba --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbin new file mode 100644 index 00000000..0b0e534a --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbin new file mode 100644 index 00000000..5e26d4e4 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbin new file mode 100644 index 00000000..8fb7f13f --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbin | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore new file mode 100644 index 00000000..33bb70d4 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore | |||
@@ -0,0 +1,9 @@ | |||
1 | /.ComponentFaultTreeTrace.java._trace | ||
2 | /.ComponentInstanceTrace.java._trace | ||
3 | /.InputTrace.java._trace | ||
4 | /.LookupHandler.java._trace | ||
5 | /.MappingHandler.java._trace | ||
6 | /.MappingQueries.java._trace | ||
7 | /.CftTransformation.java._trace | ||
8 | /.Ecore2CftTransformation.java._trace | ||
9 | /.ComponentNameGenerator.java._trace | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java new file mode 100644 index 00000000..46e711d9 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java | |||
@@ -0,0 +1,67 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentNameGenerator; | ||
9 | import java.util.Map; | ||
10 | import org.eclipse.emf.common.util.EList; | ||
11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
12 | import org.eclipse.xtend.lib.annotations.Accessors; | ||
13 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
14 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
15 | import org.eclipse.xtext.xbase.lib.Pure; | ||
16 | |||
17 | @SuppressWarnings("all") | ||
18 | public class ComponentFaultTreeTrace { | ||
19 | @Accessors | ||
20 | private final ComponentFaultTree componentFaultTree = CftFactory.eINSTANCE.createComponentFaultTree(); | ||
21 | |||
22 | private final ComponentNameGenerator nameGenerator = new ComponentNameGenerator(); | ||
23 | |||
24 | private final Map<IPatternMatch, ComponentInstanceTrace> componentInstancesMap = CollectionLiterals.<IPatternMatch, ComponentInstanceTrace>newHashMap(); | ||
25 | |||
26 | public ComponentInstanceTrace instantiateComponent(final IPatternMatch patternMatch, final ComponentDefinition componenDefinition) { | ||
27 | ComponentInstanceTrace _xblockexpression = null; | ||
28 | { | ||
29 | boolean _containsKey = this.componentInstancesMap.containsKey(patternMatch); | ||
30 | if (_containsKey) { | ||
31 | throw new IllegalArgumentException(("Already instantiated component for match: " + patternMatch)); | ||
32 | } | ||
33 | final ComponentInstanceTrace componentTrace = new ComponentInstanceTrace(this.componentFaultTree, componenDefinition, this.nameGenerator); | ||
34 | this.componentInstancesMap.put(patternMatch, componentTrace); | ||
35 | _xblockexpression = componentTrace; | ||
36 | } | ||
37 | return _xblockexpression; | ||
38 | } | ||
39 | |||
40 | public void setTopLevel(final ComponentInstanceTrace trace) { | ||
41 | Output _topEvent = this.componentFaultTree.getTopEvent(); | ||
42 | boolean _tripleNotEquals = (_topEvent != null); | ||
43 | if (_tripleNotEquals) { | ||
44 | throw new IllegalArgumentException("Top level component already set"); | ||
45 | } | ||
46 | final EList<Output> outputs = trace.getOutputs(); | ||
47 | int _size = outputs.size(); | ||
48 | boolean _tripleNotEquals_1 = (_size != 1); | ||
49 | if (_tripleNotEquals_1) { | ||
50 | int _size_1 = outputs.size(); | ||
51 | String _plus = ("Top level component must have 1 output, got " + Integer.valueOf(_size_1)); | ||
52 | String _plus_1 = (_plus + | ||
53 | " instead"); | ||
54 | throw new IllegalArgumentException(_plus_1); | ||
55 | } | ||
56 | this.componentFaultTree.setTopEvent(IterableExtensions.<Output>head(outputs)); | ||
57 | } | ||
58 | |||
59 | public ComponentInstanceTrace lookup(final IPatternMatch patternMatch) { | ||
60 | return this.componentInstancesMap.get(patternMatch); | ||
61 | } | ||
62 | |||
63 | @Pure | ||
64 | public ComponentFaultTree getComponentFaultTree() { | ||
65 | return this.componentFaultTree; | ||
66 | } | ||
67 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java new file mode 100644 index 00000000..840f501d --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java | |||
@@ -0,0 +1,65 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.Maps; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentNameGenerator; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.InputTrace; | ||
13 | import java.util.Map; | ||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | |||
16 | @SuppressWarnings("all") | ||
17 | public class ComponentInstanceTrace { | ||
18 | private final Component componentInstance = CftFactory.eINSTANCE.createComponent(); | ||
19 | |||
20 | private final Map<InputEvent, InputTrace> inputEventsMap; | ||
21 | |||
22 | private final Map<EventDeclaration, Output> outputEventsMap; | ||
23 | |||
24 | protected ComponentInstanceTrace(final ComponentFaultTree faultTree, final ComponentDefinition componentDefinition, final ComponentNameGenerator nameGenerator) { | ||
25 | this.componentInstance.setComponentDefinition(componentDefinition); | ||
26 | this.componentInstance.setName(nameGenerator.nextName(componentDefinition)); | ||
27 | this.inputEventsMap = Maps.<InputEvent, InputTrace>newHashMapWithExpectedSize(componentDefinition.getInputEvents().size()); | ||
28 | EList<InputEvent> _inputEvents = componentDefinition.getInputEvents(); | ||
29 | for (final InputEvent inputEvent : _inputEvents) { | ||
30 | { | ||
31 | final InputTrace inputTrace = new InputTrace(this.componentInstance, inputEvent); | ||
32 | this.inputEventsMap.put(inputEvent, inputTrace); | ||
33 | } | ||
34 | } | ||
35 | this.outputEventsMap = Maps.<EventDeclaration, Output>newHashMapWithExpectedSize(componentDefinition.getOutputEvents().size()); | ||
36 | EList<EventDeclaration> _outputEvents = componentDefinition.getOutputEvents(); | ||
37 | for (final EventDeclaration outputEvent : _outputEvents) { | ||
38 | { | ||
39 | final Output output = CftFactory.eINSTANCE.createOutput(); | ||
40 | output.setEventDeclaration(outputEvent); | ||
41 | EList<Output> _outputs = this.componentInstance.getOutputs(); | ||
42 | _outputs.add(output); | ||
43 | this.outputEventsMap.put(outputEvent, output); | ||
44 | } | ||
45 | } | ||
46 | EList<Component> _components = faultTree.getComponents(); | ||
47 | _components.add(this.componentInstance); | ||
48 | } | ||
49 | |||
50 | public void assign(final EventDeclaration inputEvent, final ComponentInstanceTrace sourceComponent, final EventDeclaration outputEvent) { | ||
51 | final InputTrace inputTrace = this.inputEventsMap.get(inputEvent); | ||
52 | if ((inputTrace == null)) { | ||
53 | throw new IllegalArgumentException(("Unknown input: " + inputEvent)); | ||
54 | } | ||
55 | final Output output = sourceComponent.outputEventsMap.get(outputEvent); | ||
56 | if ((output == null)) { | ||
57 | throw new IllegalArgumentException(("Unknown output: " + outputEvent)); | ||
58 | } | ||
59 | inputTrace.assign(output); | ||
60 | } | ||
61 | |||
62 | protected EList<Output> getOutputs() { | ||
63 | return this.componentInstance.getOutputs(); | ||
64 | } | ||
65 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java new file mode 100644 index 00000000..e7dca003 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java | |||
@@ -0,0 +1,29 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
4 | import java.util.Map; | ||
5 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
6 | |||
7 | @SuppressWarnings("all") | ||
8 | public class ComponentNameGenerator { | ||
9 | private static final String DEFAULT_NAME = "__unnamed"; | ||
10 | |||
11 | private final Map<ComponentDefinition, Integer> instanceCounts = CollectionLiterals.<ComponentDefinition, Integer>newHashMap(); | ||
12 | |||
13 | public String nextName(final ComponentDefinition componentDefinition) { | ||
14 | String _xblockexpression = null; | ||
15 | { | ||
16 | final Integer instanceCount = this.instanceCounts.getOrDefault(componentDefinition, Integer.valueOf(0)); | ||
17 | this.instanceCounts.put(componentDefinition, Integer.valueOf(((instanceCount).intValue() + 1))); | ||
18 | String _elvis = null; | ||
19 | String _name = componentDefinition.getName(); | ||
20 | if (_name != null) { | ||
21 | _elvis = _name; | ||
22 | } else { | ||
23 | _elvis = ComponentNameGenerator.DEFAULT_NAME; | ||
24 | } | ||
25 | _xblockexpression = (_elvis + instanceCount); | ||
26 | } | ||
27 | return _xblockexpression; | ||
28 | } | ||
29 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java new file mode 100644 index 00000000..8b2d9d97 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java | |||
@@ -0,0 +1,35 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingHandler; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries; | ||
9 | import java.util.List; | ||
10 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
11 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
12 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
13 | |||
14 | @SuppressWarnings("all") | ||
15 | public class Ecore2CftTransformation { | ||
16 | private final List<MappingHandler> mappingHandlers; | ||
17 | |||
18 | public Ecore2CftTransformation(final TransformationDefinition transformationDefinition, final ViatraQueryEngine viatraQueryEngine) { | ||
19 | final MappingQueries mappingQueries = new MappingQueries(transformationDefinition, viatraQueryEngine); | ||
20 | final Function1<MappingDefinition, MappingHandler> _function = (MappingDefinition mappingDefinition) -> { | ||
21 | return new MappingHandler(mappingDefinition, mappingQueries); | ||
22 | }; | ||
23 | this.mappingHandlers = ImmutableList.<MappingHandler>copyOf(ListExtensions.<MappingDefinition, MappingHandler>map(transformationDefinition.getMappingDefinitions(), _function)); | ||
24 | } | ||
25 | |||
26 | public void createComponentFaultTree() { | ||
27 | final ComponentFaultTreeTrace trace = new ComponentFaultTreeTrace(); | ||
28 | for (final MappingHandler handler : this.mappingHandlers) { | ||
29 | handler.instantiateComponents(trace); | ||
30 | } | ||
31 | for (final MappingHandler handler_1 : this.mappingHandlers) { | ||
32 | handler_1.instantiateConnections(trace); | ||
33 | } | ||
34 | } | ||
35 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java new file mode 100644 index 00000000..c12f2bae --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java | |||
@@ -0,0 +1,35 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
9 | import java.util.Map; | ||
10 | import org.eclipse.emf.common.util.EList; | ||
11 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
12 | |||
13 | @SuppressWarnings("all") | ||
14 | public class InputTrace { | ||
15 | private final Input input = CftFactory.eINSTANCE.createInput(); | ||
16 | |||
17 | private final Map<Output, Connection> connectionsMap = CollectionLiterals.<Output, Connection>newHashMap(); | ||
18 | |||
19 | protected InputTrace(final Component component, final InputEvent inputEvent) { | ||
20 | this.input.setInputEvent(inputEvent); | ||
21 | EList<Input> _inputs = component.getInputs(); | ||
22 | _inputs.add(this.input); | ||
23 | } | ||
24 | |||
25 | public void assign(final Output output) { | ||
26 | final Connection connection = this.connectionsMap.get(output); | ||
27 | if ((connection == null)) { | ||
28 | final Connection newConnection = CftFactory.eINSTANCE.createConnection(); | ||
29 | newConnection.setOutput(output); | ||
30 | EList<Connection> _incomingConnections = this.input.getIncomingConnections(); | ||
31 | _incomingConnections.add(newConnection); | ||
32 | this.connectionsMap.put(output, newConnection); | ||
33 | } | ||
34 | } | ||
35 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java new file mode 100644 index 00000000..e155aac8 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java | |||
@@ -0,0 +1,84 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingParameter; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
9 | import org.eclipse.emf.ecore.EObject; | ||
10 | import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern; | ||
11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
12 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
13 | import org.eclipse.xtext.xbase.lib.Conversions; | ||
14 | |||
15 | @SuppressWarnings("all") | ||
16 | public class LookupHandler { | ||
17 | private final int[] argumentIndices; | ||
18 | |||
19 | private final ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher; | ||
20 | |||
21 | public LookupHandler(final MappingDefinition mappingDefinition, final LookupDefinition lookupDefinition, final ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher) { | ||
22 | EObject _eContainer = lookupDefinition.eContainer(); | ||
23 | boolean _notEquals = (!Objects.equal(_eContainer, mappingDefinition)); | ||
24 | if (_notEquals) { | ||
25 | throw new IllegalArgumentException("lookupDefinition must be contained in mappingDefinition"); | ||
26 | } | ||
27 | final int argumentCount = lookupDefinition.getArguments().size(); | ||
28 | int _length = ((Object[])Conversions.unwrapArray(lookedUpMatcher.getParameterNames(), Object.class)).length; | ||
29 | boolean _notEquals_1 = (argumentCount != _length); | ||
30 | if (_notEquals_1) { | ||
31 | MappingDefinition _mapping = lookupDefinition.getMapping(); | ||
32 | Pattern _pattern = null; | ||
33 | if (_mapping!=null) { | ||
34 | _pattern=_mapping.getPattern(); | ||
35 | } | ||
36 | String _name = null; | ||
37 | if (_pattern!=null) { | ||
38 | _name=_pattern.getName(); | ||
39 | } | ||
40 | String _plus = ("lookupDefinition (name: " + _name); | ||
41 | String _plus_1 = (_plus + | ||
42 | ") must have as many arguments as lookedUpMatcher (name: "); | ||
43 | String _patternName = lookedUpMatcher.getPatternName(); | ||
44 | String _plus_2 = (_plus_1 + _patternName); | ||
45 | String _plus_3 = (_plus_2 + ")"); | ||
46 | throw new IllegalArgumentException(_plus_3); | ||
47 | } | ||
48 | this.argumentIndices = new int[argumentCount]; | ||
49 | for (int i = 0; (i < argumentCount); i++) { | ||
50 | { | ||
51 | final MappingParameter argument = lookupDefinition.getArguments().get(i); | ||
52 | final int argumentIndex = mappingDefinition.getParameters().indexOf(argument); | ||
53 | this.argumentIndices[i] = argumentIndex; | ||
54 | } | ||
55 | } | ||
56 | this.lookedUpMatcher = lookedUpMatcher; | ||
57 | } | ||
58 | |||
59 | public ComponentInstanceTrace lookupForMatch(final ComponentFaultTreeTrace faultTreeTrace, final IPatternMatch match) { | ||
60 | ComponentInstanceTrace _xblockexpression = null; | ||
61 | { | ||
62 | final IPatternMatch lookedUpMatch = this.createLookedUpMatch(match); | ||
63 | _xblockexpression = faultTreeTrace.lookup(lookedUpMatch); | ||
64 | } | ||
65 | return _xblockexpression; | ||
66 | } | ||
67 | |||
68 | private IPatternMatch createLookedUpMatch(final IPatternMatch match) { | ||
69 | IPatternMatch _xblockexpression = null; | ||
70 | { | ||
71 | final IPatternMatch lookedUpMatch = this.lookedUpMatcher.newEmptyMatch(); | ||
72 | final int argumentCount = this.argumentIndices.length; | ||
73 | for (int i = 0; (i < argumentCount); i++) { | ||
74 | { | ||
75 | final int argumentIndex = this.argumentIndices[i]; | ||
76 | Object argumentValue = match.get(argumentIndex); | ||
77 | lookedUpMatch.set(i, argumentValue); | ||
78 | } | ||
79 | } | ||
80 | _xblockexpression = lookedUpMatch; | ||
81 | } | ||
82 | return _xblockexpression; | ||
83 | } | ||
84 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java new file mode 100644 index 00000000..41703289 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java | |||
@@ -0,0 +1,146 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap; | ||
4 | import com.google.common.collect.Iterables; | ||
5 | import com.google.common.collect.Maps; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Assignment; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventReference; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler; | ||
16 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries; | ||
17 | import java.util.HashMap; | ||
18 | import java.util.HashSet; | ||
19 | import java.util.Map; | ||
20 | import java.util.Set; | ||
21 | import java.util.function.Consumer; | ||
22 | import org.eclipse.emf.common.util.EList; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
25 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
26 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
27 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
28 | |||
29 | @SuppressWarnings("all") | ||
30 | public class MappingHandler { | ||
31 | private final ViatraQueryMatcher<? extends IPatternMatch> matcher; | ||
32 | |||
33 | private final MappingDefinition mappingDefinition; | ||
34 | |||
35 | private final Map<LookupDefinition, LookupHandler> lookupHandlers; | ||
36 | |||
37 | public MappingHandler(final MappingDefinition mappingDefinition, final MappingQueries mappingQueries) { | ||
38 | this.matcher = mappingQueries.getMatcher(mappingDefinition); | ||
39 | this.mappingDefinition = mappingDefinition; | ||
40 | final HashSet<Variable> variables = CollectionLiterals.<Variable>newHashSet(); | ||
41 | EList<Assignment> _assignments = mappingDefinition.getAssignments(); | ||
42 | for (final Assignment assignment : _assignments) { | ||
43 | { | ||
44 | Variable _component = assignment.getInput().getComponent(); | ||
45 | variables.add(_component); | ||
46 | Variable _component_1 = assignment.getOutput().getComponent(); | ||
47 | variables.add(_component_1); | ||
48 | } | ||
49 | } | ||
50 | final Function1<LookupDefinition, LookupDefinition> _function = (LookupDefinition it) -> { | ||
51 | return it; | ||
52 | }; | ||
53 | final Function1<LookupDefinition, LookupHandler> _function_1 = (LookupDefinition lookupDefinition) -> { | ||
54 | return mappingQueries.createLookupHandler(mappingDefinition, lookupDefinition); | ||
55 | }; | ||
56 | this.lookupHandlers = ImmutableMap.<LookupDefinition, LookupHandler>copyOf(IterableExtensions.<LookupDefinition, LookupDefinition, LookupHandler>toMap(Iterables.<LookupDefinition>filter(variables, LookupDefinition.class), _function, _function_1)); | ||
57 | } | ||
58 | |||
59 | public void instantiateComponents(final ComponentFaultTreeTrace faultTreeTrace) { | ||
60 | boolean _hasComponentInstace = this.hasComponentInstace(); | ||
61 | boolean _not = (!_hasComponentInstace); | ||
62 | if (_not) { | ||
63 | return; | ||
64 | } | ||
65 | final Consumer<IPatternMatch> _function = (IPatternMatch match) -> { | ||
66 | final ComponentInstanceTrace componentTrace = faultTreeTrace.instantiateComponent(match, this.getComponentDefinition()); | ||
67 | boolean _isTopLevel = this.isTopLevel(); | ||
68 | if (_isTopLevel) { | ||
69 | faultTreeTrace.setTopLevel(componentTrace); | ||
70 | } | ||
71 | }; | ||
72 | this.matcher.forEachMatch(_function); | ||
73 | } | ||
74 | |||
75 | public void instantiateConnections(final ComponentFaultTreeTrace faultTreeTrace) { | ||
76 | boolean _hasConnections = this.hasConnections(); | ||
77 | boolean _not = (!_hasConnections); | ||
78 | if (_not) { | ||
79 | return; | ||
80 | } | ||
81 | final Consumer<IPatternMatch> _function = (IPatternMatch match) -> { | ||
82 | final Map<Variable, ComponentInstanceTrace> lookedUpComponents = this.lookupComponents(faultTreeTrace, match); | ||
83 | EList<Assignment> _assignments = this.mappingDefinition.getAssignments(); | ||
84 | for (final Assignment assignment : _assignments) { | ||
85 | { | ||
86 | final EventReference input = assignment.getInput(); | ||
87 | final ComponentInstanceTrace inputComponent = lookedUpComponents.get(input.getComponent()); | ||
88 | final EventReference output = assignment.getOutput(); | ||
89 | final ComponentInstanceTrace outputComponent = lookedUpComponents.get(output.getComponent()); | ||
90 | if (((inputComponent != null) && (outputComponent != null))) { | ||
91 | inputComponent.assign(input.getEvent(), outputComponent, output.getEvent()); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | }; | ||
96 | this.matcher.forEachMatch(_function); | ||
97 | } | ||
98 | |||
99 | private Map<Variable, ComponentInstanceTrace> lookupComponents(final ComponentFaultTreeTrace faultTreeTrace, final IPatternMatch match) { | ||
100 | HashMap<Variable, ComponentInstanceTrace> _xblockexpression = null; | ||
101 | { | ||
102 | int _size = this.lookupHandlers.size(); | ||
103 | int _plus = (_size + 1); | ||
104 | final HashMap<Variable, ComponentInstanceTrace> lookedUpComponents = Maps.<Variable, ComponentInstanceTrace>newHashMapWithExpectedSize(_plus); | ||
105 | boolean _hasComponentInstace = this.hasComponentInstace(); | ||
106 | if (_hasComponentInstace) { | ||
107 | final ComponentInstanceTrace componentInstance = faultTreeTrace.lookup(match); | ||
108 | lookedUpComponents.put(this.mappingDefinition.getComponentInstance(), componentInstance); | ||
109 | } | ||
110 | Set<Map.Entry<LookupDefinition, LookupHandler>> _entrySet = this.lookupHandlers.entrySet(); | ||
111 | for (final Map.Entry<LookupDefinition, LookupHandler> pair : _entrySet) { | ||
112 | { | ||
113 | final ComponentInstanceTrace componentInstance_1 = pair.getValue().lookupForMatch(faultTreeTrace, match); | ||
114 | if ((componentInstance_1 != null)) { | ||
115 | lookedUpComponents.put(pair.getKey(), componentInstance_1); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | _xblockexpression = lookedUpComponents; | ||
120 | } | ||
121 | return _xblockexpression; | ||
122 | } | ||
123 | |||
124 | private ComponentDefinition getComponentDefinition() { | ||
125 | ComponentInstance _componentInstance = this.mappingDefinition.getComponentInstance(); | ||
126 | ComponentDefinition _componentType = null; | ||
127 | if (_componentInstance!=null) { | ||
128 | _componentType=_componentInstance.getComponentType(); | ||
129 | } | ||
130 | return _componentType; | ||
131 | } | ||
132 | |||
133 | private boolean hasComponentInstace() { | ||
134 | ComponentDefinition _componentDefinition = this.getComponentDefinition(); | ||
135 | return (_componentDefinition != null); | ||
136 | } | ||
137 | |||
138 | private boolean isTopLevel() { | ||
139 | return this.mappingDefinition.isTopLevel(); | ||
140 | } | ||
141 | |||
142 | private boolean hasConnections() { | ||
143 | boolean _isEmpty = this.mappingDefinition.getAssignments().isEmpty(); | ||
144 | return (!_isEmpty); | ||
145 | } | ||
146 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java new file mode 100644 index 00000000..6147807e --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java | |||
@@ -0,0 +1,60 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler; | ||
8 | import java.util.Map; | ||
9 | import org.eclipse.viatra.query.patternlanguage.emf.specification.SpecificationBuilder; | ||
10 | import org.eclipse.viatra.query.runtime.api.GenericQueryGroup; | ||
11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
12 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
13 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
14 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
15 | import org.eclipse.xtext.xbase.lib.Conversions; | ||
16 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
17 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
18 | import org.eclipse.xtext.xbase.lib.MapExtensions; | ||
19 | |||
20 | @SuppressWarnings("all") | ||
21 | public class MappingQueries { | ||
22 | private final Map<MappingDefinition, ViatraQueryMatcher<? extends IPatternMatch>> matchersMap; | ||
23 | |||
24 | public MappingQueries(final TransformationDefinition transformationDefinition, final ViatraQueryEngine viatraQueryEngine) { | ||
25 | final SpecificationBuilder specificationBuilder = new SpecificationBuilder(); | ||
26 | final Function1<MappingDefinition, MappingDefinition> _function = (MappingDefinition it) -> { | ||
27 | return it; | ||
28 | }; | ||
29 | final Function1<MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> _function_1 = (MappingDefinition it) -> { | ||
30 | return specificationBuilder.getOrCreateSpecification(it.getPattern()); | ||
31 | }; | ||
32 | final Map<MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> querySpecificationsMap = IterableExtensions.<MappingDefinition, MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>>toMap(transformationDefinition.getMappingDefinitions(), _function, _function_1); | ||
33 | GenericQueryGroup.of(((IQuerySpecification<?>[])Conversions.unwrapArray(querySpecificationsMap.values(), IQuerySpecification.class))).prepare(viatraQueryEngine); | ||
34 | final Function1<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>, ViatraQueryMatcher<? extends IPatternMatch>> _function_2 = (IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> it) -> { | ||
35 | return it.getMatcher(viatraQueryEngine); | ||
36 | }; | ||
37 | this.matchersMap = ImmutableMap.<MappingDefinition, ViatraQueryMatcher<? extends IPatternMatch>>copyOf(MapExtensions.<MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>, ViatraQueryMatcher<? extends IPatternMatch>>mapValues(querySpecificationsMap, _function_2)); | ||
38 | } | ||
39 | |||
40 | public ViatraQueryMatcher<? extends IPatternMatch> getMatcher(final MappingDefinition mappingDefinition) { | ||
41 | ViatraQueryMatcher<? extends IPatternMatch> _xblockexpression = null; | ||
42 | { | ||
43 | final ViatraQueryMatcher<? extends IPatternMatch> matcher = this.matchersMap.get(mappingDefinition); | ||
44 | if ((matcher == null)) { | ||
45 | throw new IllegalArgumentException(("Unknown mapping definition: " + mappingDefinition)); | ||
46 | } | ||
47 | _xblockexpression = matcher; | ||
48 | } | ||
49 | return _xblockexpression; | ||
50 | } | ||
51 | |||
52 | public LookupHandler createLookupHandler(final MappingDefinition mappingDefinition, final LookupDefinition lookupDefinition) { | ||
53 | LookupHandler _xblockexpression = null; | ||
54 | { | ||
55 | final ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher = this.getMatcher(lookupDefinition.getMapping()); | ||
56 | _xblockexpression = new LookupHandler(mappingDefinition, lookupDefinition, lookedUpMatcher); | ||
57 | } | ||
58 | return _xblockexpression; | ||
59 | } | ||
60 | } | ||