Skip to content

Commit 1f13952

Browse files
committed
Issue #48 - Added mapping of import refs on an operation subunit.
1 parent 14a1ab9 commit 1f13952

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/units/OperationDefinitionMapping.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2017 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2018 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -19,10 +19,11 @@
1919
import org.modeldriven.alf.syntax.common.ElementReference;
2020
import org.modeldriven.alf.syntax.statements.Block;
2121
import org.modeldriven.alf.syntax.units.ExternalNamespace;
22+
import org.modeldriven.alf.syntax.units.ImportReference;
2223
import org.modeldriven.alf.syntax.units.NamespaceDefinition;
2324
import org.modeldriven.alf.syntax.units.OperationDefinition;
2425
import org.modeldriven.alf.syntax.units.RootNamespace;
25-
26+
import org.modeldriven.alf.syntax.units.UnitDefinition;
2627
import org.modeldriven.alf.uml.*;
2728

2829
import java.util.ArrayList;
@@ -255,6 +256,22 @@ public List<Element> mapBody() throws MappingError {
255256
}
256257

257258
this.otherElements = ActivityDefinitionMapping.addElements(activity, elements, body, this);
259+
260+
// If the operation definition has a subunit, then map any import references for
261+
// the subunit to imports on the operation method.
262+
UnitDefinition subunit = definition.getSubunit();
263+
if (subunit != null) {
264+
for (ImportReference importReference: subunit.getImport()) {
265+
FumlMapping mapping = this.fumlMap(importReference);
266+
for (Element element: mapping.getModelElements()) {
267+
if (element instanceof ElementImport) {
268+
activity.addElementImport((ElementImport)element);
269+
} else if (element instanceof PackageImport) {
270+
activity.addPackageImport((PackageImport)element);
271+
}
272+
}
273+
}
274+
}
258275
}
259276

260277
return this.otherElements;

0 commit comments

Comments
 (0)