diff options
author | Kristóf Marussy <kris7topher@gmail.com> | 2019-02-07 18:24:45 +0100 |
---|---|---|
committer | Kristóf Marussy <kris7topher@gmail.com> | 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/ecore2cft/LookupHandler.java | |
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/ecore2cft/LookupHandler.java')
-rw-r--r-- | Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java | 84 |
1 files changed, 84 insertions, 0 deletions
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 | } | ||