aboutsummaryrefslogtreecommitdiffstats
path: root/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation
diff options
context:
space:
mode:
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation')
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath1
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project6
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF9
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend10
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend39
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend51
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend16
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend27
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend29
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend47
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend91
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend38
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore8
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbinbin0 -> 2298 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore1
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java10
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbinbin0 -> 5009 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbinbin0 -> 5190 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbinbin0 -> 3472 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbinbin0 -> 3400 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbinbin0 -> 3849 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbinbin0 -> 5169 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbinbin0 -> 6876 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbinbin0 -> 4833 bytes
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore9
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java67
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java65
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java29
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java35
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java35
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java84
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java146
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java60
33 files changed, 913 insertions, 0 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath
index eca7bdba..428337e5 100644
--- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath
@@ -3,5 +3,6 @@
3 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> 3 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> 4 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5 <classpathentry kind="src" path="src"/> 5 <classpathentry kind="src" path="src"/>
6 <classpathentry kind="src" path="xtend-gen"/>
6 <classpathentry kind="output" path="bin"/> 7 <classpathentry kind="output" path="bin"/>
7</classpath> 8</classpath>
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project
index bd1da900..ba51fe06 100644
--- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project
@@ -6,6 +6,11 @@
6 </projects> 6 </projects>
7 <buildSpec> 7 <buildSpec>
8 <buildCommand> 8 <buildCommand>
9 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
9 <name>org.eclipse.jdt.core.javabuilder</name> 14 <name>org.eclipse.jdt.core.javabuilder</name>
10 <arguments> 15 <arguments>
11 </arguments> 16 </arguments>
@@ -24,5 +29,6 @@
24 <natures> 29 <natures>
25 <nature>org.eclipse.pde.PluginNature</nature> 30 <nature>org.eclipse.pde.PluginNature</nature>
26 <nature>org.eclipse.jdt.core.javanature</nature> 31 <nature>org.eclipse.jdt.core.javanature</nature>
32 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
27 </natures> 33 </natures>
28</projectDescription> 34</projectDescription>
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF
index ae23171b..91eeedc5 100644
--- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF
@@ -5,3 +5,12 @@ Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.faulttree.transformation
5Bundle-Version: 1.0.0.qualifier 5Bundle-Version: 1.0.0.qualifier
6Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.faulttree.transformation 6Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.faulttree.transformation
7Bundle-RequiredExecutionEnvironment: JavaSE-1.8 7Bundle-RequiredExecutionEnvironment: JavaSE-1.8
8Require-Bundle: com.google.guava,
9 org.eclipse.xtext.xbase.lib,
10 org.eclipse.xtend.lib,
11 org.eclipse.xtend.lib.macro,
12 org.eclipse.emf.ecore,
13 org.eclipse.viatra.query.runtime,
14 org.eclipse.viatra.query.runtime.rete,
15 org.eclipse.viatra.query.runtime.localsearch,
16 hu.bme.mit.inf.dslreasoner.faulttree.components
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend
new file mode 100644
index 00000000..caaffc3c
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend
@@ -0,0 +1,10 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree
4
5class Cft2FtTransformation {
6 def createFaultTree(ComponentFaultTree componentFaultTree) {
7 // TODO
8 throw new UnsupportedOperationException()
9 }
10} \ No newline at end of file
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend
new file mode 100644
index 00000000..7a3e377b
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend
@@ -0,0 +1,39 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory
4import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition
5import java.util.Map
6import org.eclipse.viatra.query.runtime.api.IPatternMatch
7import org.eclipse.xtend.lib.annotations.Accessors
8
9class ComponentFaultTreeTrace {
10 @Accessors val componentFaultTree = CftFactory.eINSTANCE.createComponentFaultTree
11
12 val nameGenerator = new ComponentNameGenerator
13 val Map<IPatternMatch, ComponentInstanceTrace> componentInstancesMap = newHashMap
14
15 def instantiateComponent(IPatternMatch patternMatch, ComponentDefinition componenDefinition) {
16 if (componentInstancesMap.containsKey(patternMatch)) {
17 throw new IllegalArgumentException("Already instantiated component for match: " + patternMatch)
18 }
19 val componentTrace = new ComponentInstanceTrace(componentFaultTree, componenDefinition, nameGenerator)
20 componentInstancesMap.put(patternMatch, componentTrace)
21 componentTrace
22 }
23
24 def setTopLevel(ComponentInstanceTrace trace) {
25 if (componentFaultTree.topEvent !== null) {
26 throw new IllegalArgumentException("Top level component already set")
27 }
28 val outputs = trace.outputs
29 if (outputs.size !== 1) {
30 throw new IllegalArgumentException("Top level component must have 1 output, got " + outputs.size +
31 " instead")
32 }
33 componentFaultTree.topEvent = outputs.head
34 }
35
36 def lookup(IPatternMatch patternMatch) {
37 componentInstancesMap.get(patternMatch)
38 }
39}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend
new file mode 100644
index 00000000..7353bfe5
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend
@@ -0,0 +1,51 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import com.google.common.collect.Maps
4import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory
5import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition
6import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree
7import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration
8import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent
9import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output
10import java.util.Map
11
12class ComponentInstanceTrace {
13 val componentInstance = CftFactory.eINSTANCE.createComponent
14 val Map<InputEvent, InputTrace> inputEventsMap
15 val Map<EventDeclaration, Output> outputEventsMap
16
17 protected new(ComponentFaultTree faultTree, ComponentDefinition componentDefinition,
18 ComponentNameGenerator nameGenerator) {
19 componentInstance.componentDefinition = componentDefinition
20 componentInstance.name = nameGenerator.nextName(componentDefinition)
21 inputEventsMap = Maps.newHashMapWithExpectedSize(componentDefinition.inputEvents.size)
22 for (inputEvent : componentDefinition.inputEvents) {
23 val inputTrace = new InputTrace(componentInstance, inputEvent)
24 inputEventsMap.put(inputEvent, inputTrace)
25 }
26 outputEventsMap = Maps.newHashMapWithExpectedSize(componentDefinition.outputEvents.size)
27 for (outputEvent : componentDefinition.outputEvents) {
28 val output = CftFactory.eINSTANCE.createOutput
29 output.eventDeclaration = outputEvent
30 componentInstance.outputs += output
31 outputEventsMap.put(outputEvent, output)
32 }
33 faultTree.components += componentInstance
34 }
35
36 def void assign(EventDeclaration inputEvent, ComponentInstanceTrace sourceComponent, EventDeclaration outputEvent) {
37 val inputTrace = inputEventsMap.get(inputEvent)
38 if (inputTrace === null) {
39 throw new IllegalArgumentException("Unknown input: " + inputEvent)
40 }
41 val output = sourceComponent.outputEventsMap.get(outputEvent)
42 if (output === null) {
43 throw new IllegalArgumentException("Unknown output: " + outputEvent)
44 }
45 inputTrace.assign(output)
46 }
47
48 protected def getOutputs() {
49 componentInstance.outputs
50 }
51}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend
new file mode 100644
index 00000000..71d40a9b
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend
@@ -0,0 +1,16 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition
4import java.util.Map
5
6class ComponentNameGenerator {
7 static val DEFAULT_NAME = "__unnamed"
8
9 val Map<ComponentDefinition, Integer> instanceCounts = newHashMap
10
11 def nextName(ComponentDefinition componentDefinition) {
12 val instanceCount = instanceCounts.getOrDefault(componentDefinition, 0)
13 instanceCounts.put(componentDefinition, instanceCount + 1)
14 (componentDefinition.name ?: DEFAULT_NAME) + instanceCount
15 }
16}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend
new file mode 100644
index 00000000..36aac5e1
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend
@@ -0,0 +1,27 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import com.google.common.collect.ImmutableList
4import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition
5import java.util.List
6import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
7
8class Ecore2CftTransformation {
9 val List<MappingHandler> mappingHandlers
10
11 new(TransformationDefinition transformationDefinition, ViatraQueryEngine viatraQueryEngine) {
12 val mappingQueries = new MappingQueries(transformationDefinition, viatraQueryEngine)
13 mappingHandlers = ImmutableList.copyOf(transformationDefinition.mappingDefinitions.map [ mappingDefinition |
14 new MappingHandler(mappingDefinition, mappingQueries)
15 ])
16 }
17
18 def createComponentFaultTree() {
19 val trace = new ComponentFaultTreeTrace
20 for (handler : mappingHandlers) {
21 handler.instantiateComponents(trace)
22 }
23 for (handler : mappingHandlers) {
24 handler.instantiateConnections(trace)
25 }
26 }
27}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend
new file mode 100644
index 00000000..c529a09b
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend
@@ -0,0 +1,29 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory
4import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component
5import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection
6import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input
7import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent
8import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output
9import java.util.Map
10
11class InputTrace {
12 val Input input = CftFactory.eINSTANCE.createInput
13 val Map<Output, Connection> connectionsMap = newHashMap
14
15 protected new(Component component, InputEvent inputEvent) {
16 input.inputEvent = inputEvent
17 component.inputs += input
18 }
19
20 def void assign(Output output) {
21 val connection = connectionsMap.get(output)
22 if (connection === null) {
23 val newConnection = CftFactory.eINSTANCE.createConnection
24 newConnection.output = output
25 input.incomingConnections += newConnection
26 connectionsMap.put(output, newConnection)
27 }
28 }
29}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend
new file mode 100644
index 00000000..3a06dcc3
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend
@@ -0,0 +1,47 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition
4import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition
5import org.eclipse.viatra.query.runtime.api.IPatternMatch
6import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
7
8class LookupHandler {
9 val int[] argumentIndices
10 val ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher
11
12 new(MappingDefinition mappingDefinition, LookupDefinition lookupDefinition,
13 ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher) {
14 if (lookupDefinition.eContainer != mappingDefinition) {
15 throw new IllegalArgumentException("lookupDefinition must be contained in mappingDefinition")
16 }
17 val argumentCount = lookupDefinition.arguments.size
18 if (argumentCount != lookedUpMatcher.parameterNames.length) {
19 throw new IllegalArgumentException(
20 "lookupDefinition (name: " + lookupDefinition.mapping?.pattern?.name +
21 ") must have as many arguments as lookedUpMatcher (name: " + lookedUpMatcher.patternName + ")")
22 }
23 argumentIndices = newIntArrayOfSize(argumentCount)
24 for (var int i = 0; i < argumentCount; i++) {
25 val argument = lookupDefinition.arguments.get(i)
26 val argumentIndex = mappingDefinition.parameters.indexOf(argument)
27 argumentIndices.set(i, argumentIndex)
28 }
29 this.lookedUpMatcher = lookedUpMatcher
30 }
31
32 def lookupForMatch(ComponentFaultTreeTrace faultTreeTrace, IPatternMatch match) {
33 val lookedUpMatch = createLookedUpMatch(match)
34 faultTreeTrace.lookup(lookedUpMatch)
35 }
36
37 private def createLookedUpMatch(IPatternMatch match) {
38 val lookedUpMatch = lookedUpMatcher.newEmptyMatch
39 val argumentCount = argumentIndices.length
40 for (var int i = 0; i < argumentCount; i++) {
41 val argumentIndex = argumentIndices.get(i)
42 var argumentValue = match.get(argumentIndex)
43 lookedUpMatch.set(i, argumentValue)
44 }
45 lookedUpMatch
46 }
47}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend
new file mode 100644
index 00000000..643af5c4
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend
@@ -0,0 +1,91 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import com.google.common.collect.ImmutableMap
4import com.google.common.collect.Maps
5import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition
6import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition
7import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable
8import java.util.Map
9import org.eclipse.viatra.query.runtime.api.IPatternMatch
10import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
11
12class MappingHandler {
13 val ViatraQueryMatcher<? extends IPatternMatch> matcher
14 val MappingDefinition mappingDefinition
15 val Map<LookupDefinition, LookupHandler> lookupHandlers
16
17 new(MappingDefinition mappingDefinition, MappingQueries mappingQueries) {
18 matcher = mappingQueries.getMatcher(mappingDefinition)
19 this.mappingDefinition = mappingDefinition
20 val variables = newHashSet
21 for (assignment : mappingDefinition.assignments) {
22 variables += assignment.input.component
23 variables += assignment.output.component
24 }
25 lookupHandlers = ImmutableMap.copyOf(variables.filter(LookupDefinition).toMap([it], [ lookupDefinition |
26 mappingQueries.createLookupHandler(mappingDefinition, lookupDefinition)
27 ]))
28 }
29
30 def instantiateComponents(ComponentFaultTreeTrace faultTreeTrace) {
31 if (!hasComponentInstace) {
32 return
33 }
34 matcher.forEachMatch [ match |
35 val componentTrace = faultTreeTrace.instantiateComponent(match, componentDefinition)
36 if (isTopLevel) {
37 faultTreeTrace.topLevel = componentTrace
38 }
39 ]
40 }
41
42 def instantiateConnections(ComponentFaultTreeTrace faultTreeTrace) {
43 if (!hasConnections) {
44 return
45 }
46 matcher.forEachMatch [ match |
47 val lookedUpComponents = lookupComponents(faultTreeTrace, match)
48 for (assignment : mappingDefinition.assignments) {
49 val input = assignment.input
50 val inputComponent = lookedUpComponents.get(input.component)
51 val output = assignment.output
52 val outputComponent = lookedUpComponents.get(output.component)
53 if (inputComponent !== null && outputComponent !== null) {
54 inputComponent.assign(input.event, outputComponent, output.event)
55 }
56 }
57 ]
58 }
59
60 private def Map<Variable, ComponentInstanceTrace> lookupComponents(ComponentFaultTreeTrace faultTreeTrace,
61 IPatternMatch match) {
62 val lookedUpComponents = Maps.newHashMapWithExpectedSize(lookupHandlers.size + 1)
63 if (hasComponentInstace) {
64 val componentInstance = faultTreeTrace.lookup(match)
65 lookedUpComponents.put(mappingDefinition.componentInstance, componentInstance)
66 }
67 for (pair : lookupHandlers.entrySet) {
68 val componentInstance = pair.value.lookupForMatch(faultTreeTrace, match)
69 if (componentInstance !== null) {
70 lookedUpComponents.put(pair.key, componentInstance)
71 }
72 }
73 lookedUpComponents
74 }
75
76 private def getComponentDefinition() {
77 mappingDefinition.componentInstance?.componentType
78 }
79
80 private def hasComponentInstace() {
81 componentDefinition !== null
82 }
83
84 private def isTopLevel() {
85 mappingDefinition.topLevel
86 }
87
88 private def hasConnections() {
89 !mappingDefinition.assignments.empty
90 }
91}
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend
new file mode 100644
index 00000000..6683b3f8
--- /dev/null
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend
@@ -0,0 +1,38 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft
2
3import com.google.common.collect.ImmutableMap
4import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition
5import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition
6import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition
7import java.util.Map
8import org.eclipse.viatra.query.patternlanguage.emf.specification.SpecificationBuilder
9import org.eclipse.viatra.query.runtime.api.GenericQueryGroup
10import org.eclipse.viatra.query.runtime.api.IPatternMatch
11import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
12import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
13
14class MappingQueries {
15 val Map<MappingDefinition, ViatraQueryMatcher<? extends IPatternMatch>> matchersMap
16
17 new(TransformationDefinition transformationDefinition, ViatraQueryEngine viatraQueryEngine) {
18 val specificationBuilder = new SpecificationBuilder
19 val querySpecificationsMap = transformationDefinition.mappingDefinitions.toMap([it], [
20 specificationBuilder.getOrCreateSpecification(pattern)
21 ])
22 GenericQueryGroup.of(querySpecificationsMap.values).prepare(viatraQueryEngine)
23 matchersMap = ImmutableMap.copyOf(querySpecificationsMap.mapValues[getMatcher(viatraQueryEngine)])
24 }
25
26 def getMatcher(MappingDefinition mappingDefinition) {
27 val matcher = matchersMap.get(mappingDefinition)
28 if (matcher === null) {
29 throw new IllegalArgumentException("Unknown mapping definition: " + mappingDefinition)
30 }
31 matcher
32 }
33
34 def createLookupHandler(MappingDefinition mappingDefinition, LookupDefinition lookupDefinition) {
35 val lookedUpMatcher = getMatcher(lookupDefinition.mapping)
36 new LookupHandler(mappingDefinition, lookupDefinition, lookedUpMatcher)
37 }
38}
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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft;
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree;
4
5@SuppressWarnings("all")
6public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory;
4import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition;
5import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree;
6import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output;
7import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace;
8import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentNameGenerator;
9import java.util.Map;
10import org.eclipse.emf.common.util.EList;
11import org.eclipse.viatra.query.runtime.api.IPatternMatch;
12import org.eclipse.xtend.lib.annotations.Accessors;
13import org.eclipse.xtext.xbase.lib.CollectionLiterals;
14import org.eclipse.xtext.xbase.lib.IterableExtensions;
15import org.eclipse.xtext.xbase.lib.Pure;
16
17@SuppressWarnings("all")
18public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import com.google.common.collect.Maps;
4import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory;
5import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component;
6import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition;
7import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree;
8import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration;
9import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent;
10import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output;
11import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentNameGenerator;
12import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.InputTrace;
13import java.util.Map;
14import org.eclipse.emf.common.util.EList;
15
16@SuppressWarnings("all")
17public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition;
4import java.util.Map;
5import org.eclipse.xtext.xbase.lib.CollectionLiterals;
6
7@SuppressWarnings("all")
8public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import com.google.common.collect.ImmutableList;
4import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition;
5import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition;
6import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace;
7import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingHandler;
8import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries;
9import java.util.List;
10import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
11import org.eclipse.xtext.xbase.lib.Functions.Function1;
12import org.eclipse.xtext.xbase.lib.ListExtensions;
13
14@SuppressWarnings("all")
15public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory;
4import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component;
5import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection;
6import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input;
7import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent;
8import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output;
9import java.util.Map;
10import org.eclipse.emf.common.util.EList;
11import org.eclipse.xtext.xbase.lib.CollectionLiterals;
12
13@SuppressWarnings("all")
14public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import com.google.common.base.Objects;
4import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition;
5import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition;
6import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingParameter;
7import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace;
8import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace;
9import org.eclipse.emf.ecore.EObject;
10import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern;
11import org.eclipse.viatra.query.runtime.api.IPatternMatch;
12import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
13import org.eclipse.xtext.xbase.lib.Conversions;
14
15@SuppressWarnings("all")
16public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import com.google.common.collect.ImmutableMap;
4import com.google.common.collect.Iterables;
5import com.google.common.collect.Maps;
6import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Assignment;
7import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentInstance;
8import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventReference;
9import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition;
10import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition;
11import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable;
12import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition;
13import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace;
14import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace;
15import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler;
16import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries;
17import java.util.HashMap;
18import java.util.HashSet;
19import java.util.Map;
20import java.util.Set;
21import java.util.function.Consumer;
22import org.eclipse.emf.common.util.EList;
23import org.eclipse.viatra.query.runtime.api.IPatternMatch;
24import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
25import org.eclipse.xtext.xbase.lib.CollectionLiterals;
26import org.eclipse.xtext.xbase.lib.Functions.Function1;
27import org.eclipse.xtext.xbase.lib.IterableExtensions;
28
29@SuppressWarnings("all")
30public 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 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft;
2
3import com.google.common.collect.ImmutableMap;
4import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition;
5import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition;
6import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition;
7import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler;
8import java.util.Map;
9import org.eclipse.viatra.query.patternlanguage.emf.specification.SpecificationBuilder;
10import org.eclipse.viatra.query.runtime.api.GenericQueryGroup;
11import org.eclipse.viatra.query.runtime.api.IPatternMatch;
12import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
13import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
14import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
15import org.eclipse.xtext.xbase.lib.Conversions;
16import org.eclipse.xtext.xbase.lib.Functions.Function1;
17import org.eclipse.xtext.xbase.lib.IterableExtensions;
18import org.eclipse.xtext.xbase.lib.MapExtensions;
19
20@SuppressWarnings("all")
21public 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}