|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright 2011-2017 Data Access Technologies, Inc. (Model Driven Solutions) |
| 2 | + * Copyright 2011-2018 Data Access Technologies, Inc. (Model Driven Solutions) |
3 | 3 | * All rights reserved worldwide. This program and the accompanying materials |
4 | 4 | * are made available for use under the terms of the GNU General Public License |
5 | 5 | * (GPL) version 3 that accompanies this distribution and is available at |
@@ -59,45 +59,60 @@ public Action mapAction() throws MappingError { |
59 | 59 |
|
60 | 60 | public Action mapAction(boolean mayWrapAction) throws MappingError { |
61 | 61 | Action action = this.mapTarget(); |
62 | | - |
| 62 | + |
63 | 63 | InvocationExpression expression = this.getInvocationExpression(); |
64 | | - |
| 64 | + |
65 | 65 | Tuple tuple = expression.getTuple(); |
66 | 66 | FumlMapping mapping = this.fumlMap(tuple); |
67 | | - if (mapping instanceof TupleMapping) { |
| 67 | + if (!(mapping instanceof TupleMapping)) { |
| 68 | + this.throwError("Error mapping tuple:" + tuple); |
| 69 | + } else { |
68 | 70 | TupleMapping tupleMapping = (TupleMapping)mapping; |
69 | 71 | tupleMapping.setIsIndexFrom0(this.isIndexFrom0()); |
70 | 72 | tupleMapping.mapTo(action); |
71 | 73 | this.graph.addAll(tupleMapping.getTupleGraph()); |
72 | 74 | this.lhsGraph = tupleMapping.getLhsGraph(); |
73 | 75 | this.assignedValueSourceMap = tupleMapping.getAssignedValueSourceMap(); |
74 | | - } else { |
75 | | - this.throwError("Error mapping tuple:" + tuple); |
76 | | - } |
77 | 76 |
|
78 | | - action = this.mapFeature(action); |
79 | | - |
80 | | - // NOTE: mayWrapAction is only set to false for the mapping of the |
81 | | - // equivalent invocation expression of a sequence access expression. |
82 | | - if (mayWrapAction && |
83 | | - (action instanceof CallBehaviorAction || |
84 | | - action instanceof CallOperationAction) && |
85 | | - !((CallAction)action).getArgument().isEmpty() && |
86 | | - this.resultSource instanceof OutputPin) { |
87 | | - action = this.adjustAction( |
88 | | - this.graph, action, (OutputPin)this.resultSource); |
89 | | - this.resultSource = ((StructuredActivityNode)action). |
90 | | - getStructuredNodeOutput().get(0); |
91 | | - |
92 | | - } |
93 | | - |
94 | | - // NOTE: Adding left-hand side elements here prevents them from being |
95 | | - // wrapped in the expansion region mapped from a sequence feature |
96 | | - // invocation. |
97 | | - this.graph.addAll(this.lhsGraph); |
| 77 | + action = this.mapFeature(action); |
| 78 | + |
| 79 | + // NOTE: mayWrapAction is only set to false for the mapping of the |
| 80 | + // equivalent invocation expression of a sequence access expression. |
| 81 | + if (mayWrapAction && |
| 82 | + (action instanceof CallBehaviorAction || |
| 83 | + action instanceof CallOperationAction) && |
| 84 | + !((CallAction)action).getArgument().isEmpty() && |
| 85 | + this.resultSource instanceof OutputPin) { |
| 86 | + StructuredActivityNode node = this.adjustAction( |
| 87 | + this.graph, action, (OutputPin)this.resultSource); |
| 88 | + this.resultSource = node.getStructuredNodeOutput().get(0); |
| 89 | + |
| 90 | + ActivityNode tupleNode = (ActivityNode)tupleMapping.getElement(); |
| 91 | + if (tupleNode != null) { |
| 92 | + this.graph.addControlFlow(tupleNode, node); |
| 93 | + if (action instanceof CallOperationAction) { |
| 94 | + InputPin targetPin = ((CallOperationAction)action).getTarget(); |
| 95 | + InputPin inputPin = graph.createInputPin( |
| 96 | + "Input(" + targetPin.getName() + ")", |
| 97 | + targetPin.getType(), 1, 1); |
| 98 | + ActivityEdge incomingEdge = targetPin.getIncoming().remove(0); |
| 99 | + incomingEdge.setTarget(inputPin); |
| 100 | + node.addStructuredNodeInput(inputPin); |
| 101 | + node.addEdge(this.graph.createObjectFlow(inputPin, targetPin)); |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + action = node; |
| 106 | + } |
| 107 | + |
| 108 | + // NOTE: Adding left-hand side elements here prevents them from being |
| 109 | + // wrapped in the expansion region mapped from a sequence feature |
| 110 | + // invocation. |
| 111 | + this.graph.addAll(this.lhsGraph); |
| 112 | + } |
98 | 113 |
|
99 | 114 | return action; |
100 | | - } |
| 115 | + } |
101 | 116 |
|
102 | 117 | private StructuredActivityNode adjustAction( |
103 | 118 | ActivityGraph graph, Action action, OutputPin resultPin) throws MappingError { |
|
0 commit comments