Private import statement

In MagicDraw 19.0 with Alf plugin, we defined an activity with import statements. The Alf code starts with:

private import Util::Protocol::Messages::Start;
private import Util::Protocol::Messages::End;

activity ‘AbstractSemanticTest$behavior$1’() {

The compiler marks the first word “private” as an error:

Capture

What’s wrong? Private import statements are supported by Alf.

Tim

The issue is that the MagicDraw Alf Plugin implements Alf at the so-called “full conformance” level. This level includes all the behavioral elements of Alf (i.e., statements and expressions), which can be used to specify the body of an activity or opaque behavior. This is the core use of Alf as an “action language”.

However, Alf can also be used to specify complete structural element definitions for activities, classes, packages, etc. Import declarations can only be attached to such Alf units, as they are attached to an activity definition unit in the code shown in your question. But units are only included at the “extended conformance” level of the Alf standard, so they are not supported by the MagicDraw Alf Plugin. (Note that Eclipse Moka implements Alf at the extended conformance level, and so would be able to accept the above code.)

In order to get this code to work in MagicDraw, remove everything but the sequence of statements in the body of the activity definition. Assuming that this code is already attached to a UML activity called AbstractSemanticTest$behavior$1, you can then re-create the import relationships in the UML model from that activity to the Start and End elements. Or you can just use fully qualified names in where the elements are referenced in the code.

1 Like