Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to specify those operations to be run in a transition?
How to specify those operations to be run in a transition? [message #473185] Tue, 12 June 2007 13:44 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Hi Hi,
I have some problems with transitions. So I try to explain what I mean.
In UML the syntax of a transition looks like this:

transitionName[guard]/classMethod^foreignMethod

classMethod is a method of the class which owns the StateMachine and can
be run when the transition is reached. And foreignMethod is a method of
another Class which can be executed when the transition is reached. But
how do I specify those methods?

my try for classMethod:

Package pack = UMLFactory.eINSTANCE.createPackage();
pack.setName("package");
Class classA = pack.createOwnedClass("classA", false);
classA.setPackage(pack);
Operation opA = classA.createOwnedOperation("runThis", null, null);
//...some other elements
StateMachine machine = UMLFactory.eINSTANCE.createStateMachine();
//...creation of the StateMachine
Transition trans = UMLFactory.eINSTANCE.createTransition();
//...source, target
Activity activity = UMLFactory.eINSTANCE.createActivity();
activity.setName("activity");
activity.setSpecification(opA);
trans.setEffect(activity);
// add StateMachine to Class
classA.allOwnedElements().add(machine);

is it correct to model what I want in that way? And how to model the
foreignMethod?

Thank you.

Gilbert
Re: How to specify those operations to be run in a transition? [message #473199 is a reply to message #473185] Wed, 13 June 2007 14:30 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Gilbert,


I think you have 2 options here.


The effect of the transition is a Behavior to be performed when the
transition fires. ...

1). You could create an OpaqueBehavior, whose specification is set to the
operation in question ( call OpaqueBehavior.setSpecification() ( inherited
from Behavior) ).
Or you could create a textual description of your operation and set that
as the OpaqueBehavior ( This is most likely the real intent of
OpaqueBehavior).
The downside to this would be that there is no way to specify return
parameters or pass parameters to this operation etc.


2) Alternatively, you could set an Activity to be the effect of the
transition. Then create a CallOperationAction and set the operation to the
operation you are interested in. Any well formed Activity should have a
initial and final nodes so you could create those to.
This is a bit of a messy way to indicate that you want to call one
operation but I would favor this approach. You can in the future expand on
this activity to add more behavior.

The transition owning the Behavior (its effec) makes this a bit awkward
since the context of the behavior would be the first BehavioredClassifier
reached by following the chain of owner relationships.


Hope that helps.

- James.


"Gilbert Mirenque" <formatzeh@gmx.de> wrote in message
news:0e7692541ef0643ef81785a4a1f253ab$1@www.eclipse.org...
> Hi Hi,
> I have some problems with transitions. So I try to explain what I mean.
> In UML the syntax of a transition looks like this:
>
> transitionName[guard]/classMethod^foreignMethod
>
> classMethod is a method of the class which owns the StateMachine and can
> be run when the transition is reached. And foreignMethod is a method of
> another Class which can be executed when the transition is reached. But
> how do I specify those methods?
>
> my try for classMethod:
>
> Package pack = UMLFactory.eINSTANCE.createPackage();
> pack.setName("package");
> Class classA = pack.createOwnedClass("classA", false);
> classA.setPackage(pack);
> Operation opA = classA.createOwnedOperation("runThis", null, null);
> //...some other elements
> StateMachine machine = UMLFactory.eINSTANCE.createStateMachine();
> //...creation of the StateMachine
> Transition trans = UMLFactory.eINSTANCE.createTransition();
> //...source, target
> Activity activity = UMLFactory.eINSTANCE.createActivity();
> activity.setName("activity");
> activity.setSpecification(opA);
> trans.setEffect(activity);
> // add StateMachine to Class
> classA.allOwnedElements().add(machine);
>
> is it correct to model what I want in that way? And how to model the
> foreignMethod?
>
> Thank you.
>
> Gilbert
>
>
Re: How to specify those operations to be run in a transition? [message #621670 is a reply to message #473185] Wed, 13 June 2007 14:30 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Gilbert,


I think you have 2 options here.


The effect of the transition is a Behavior to be performed when the
transition fires. ...

1). You could create an OpaqueBehavior, whose specification is set to the
operation in question ( call OpaqueBehavior.setSpecification() ( inherited
from Behavior) ).
Or you could create a textual description of your operation and set that
as the OpaqueBehavior ( This is most likely the real intent of
OpaqueBehavior).
The downside to this would be that there is no way to specify return
parameters or pass parameters to this operation etc.


2) Alternatively, you could set an Activity to be the effect of the
transition. Then create a CallOperationAction and set the operation to the
operation you are interested in. Any well formed Activity should have a
initial and final nodes so you could create those to.
This is a bit of a messy way to indicate that you want to call one
operation but I would favor this approach. You can in the future expand on
this activity to add more behavior.

The transition owning the Behavior (its effec) makes this a bit awkward
since the context of the behavior would be the first BehavioredClassifier
reached by following the chain of owner relationships.


Hope that helps.

- James.


"Gilbert Mirenque" <formatzeh@gmx.de> wrote in message
news:0e7692541ef0643ef81785a4a1f253ab$1@www.eclipse.org...
> Hi Hi,
> I have some problems with transitions. So I try to explain what I mean.
> In UML the syntax of a transition looks like this:
>
> transitionName[guard]/classMethod^foreignMethod
>
> classMethod is a method of the class which owns the StateMachine and can
> be run when the transition is reached. And foreignMethod is a method of
> another Class which can be executed when the transition is reached. But
> how do I specify those methods?
>
> my try for classMethod:
>
> Package pack = UMLFactory.eINSTANCE.createPackage();
> pack.setName("package");
> Class classA = pack.createOwnedClass("classA", false);
> classA.setPackage(pack);
> Operation opA = classA.createOwnedOperation("runThis", null, null);
> //...some other elements
> StateMachine machine = UMLFactory.eINSTANCE.createStateMachine();
> //...creation of the StateMachine
> Transition trans = UMLFactory.eINSTANCE.createTransition();
> //...source, target
> Activity activity = UMLFactory.eINSTANCE.createActivity();
> activity.setName("activity");
> activity.setSpecification(opA);
> trans.setEffect(activity);
> // add StateMachine to Class
> classA.allOwnedElements().add(machine);
>
> is it correct to model what I want in that way? And how to model the
> foreignMethod?
>
> Thank you.
>
> Gilbert
>
>
Previous Topic:Load Model from Enterprise Architect
Next Topic:[Announce] MDT UML2 2.0.4 M200706131554 is available
Goto Forum:
  


Current Time: Fri Apr 26 20:52:10 GMT 2024

Powered by FUDForum. Page generated in 0.03017 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top