Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Execution Occurrence linking to Lifeline
Execution Occurrence linking to Lifeline [message #468913] Wed, 24 January 2007 00:03 Go to next message
Paul Smith is currently offline Paul SmithFriend
Messages: 10
Registered: July 2009
Junior Member
I am currently using Rational Software Architects version of the UML api
to try and create sequence diagrams. I am having difficulty in working out
how to attach the ExecutionOccurrence to the Lifeline. My basic code is
attempting to create two Lifelines and a synchronous message between the
two. The code I have is as follows:

String sequenceName = serviceClass.getName() +
operation.getName().substring(0, 1).toUpperCase() +
operation.getName().substring(1);
//Add a collaboration instance to the class
Collaboration collaboration = (Collaboration)
serviceClass.createNestedClassifier(UML2Package.eINSTANCE.ge tCollaboration());
collaboration.setName(sequenceName + "Sequence");
//Add an interaction to the collaboration
Interaction interaction = (Interaction)
collaboration.createOwnedBehavior(UML2Package.eINSTANCE.getI nteraction());
interaction.setName(sequenceName + "Interaction");
//Add the start lifeline
Lifeline start =
interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
start.setName("Start");
start.setRepresents(getStartProperty(collaboration));
//Add the service lifeline
Lifeline serviceLifeline =
interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
serviceLifeline.setName(serviceClass.getName());
serviceLifeline.setRepresents(getServiceProperty(serviceClas s,
collaboration));

//Create a synchronous message from the start lifeline to the
service
Message createSendMessage =
interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
createSendMessage.setSignature(operation);

createSendMessage.setMessageSort(MessageSort.SYNCH_CALL_LITE RAL);
createSendMessage.setName("create");


//Create the signal message back to the start lifeline
Message createReturnMessage =
interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
createReturnMessage.setSignature(operation);

createReturnMessage.setMessageSort(MessageSort.SYNCH_SIGNAL_ LITERAL);
createReturnMessage.setName("create");
createReturnMessage.addKeyword("return");

//Create the two connector ends
Connector connector = (Connector)
interaction.createOwnedConnector(UML2Package.eINSTANCE.getCo nnector());
ConnectorEnd startEnd =
connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
startEnd.setRole(start.getRepresents());
ConnectorEnd serviceEnd =
connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
serviceEnd.setRole(serviceLifeline.getRepresents());

createSendMessage.setConnector(connector);
createReturnMessage.setConnector(connector);

//theModels.createSequenceDiagram(connector.getNamespace(),
sequenceName + "SequenceDiagram", false, interaction);


//Create the event occurrences
EventOccurrence outSendEventOccurrence = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
outSendEventOccurrence.setSendMessage(createSendMessage);

EventOccurrence outReceiveEventOccurrence = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
outReceiveEventOccurrence.setReceiveMessage(createSendMessag e);


EventOccurrence inSendEventOccurrence = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
inSendEventOccurrence.setSendMessage(createReturnMessage);

EventOccurrence inReceiveEventOccurrence = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());

inReceiveEventOccurrence.setReceiveMessage(createReturnMessa ge);

//Build an execution occurrence
ExecutionOccurrence executionOccurrence =
(ExecutionOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getExecutio nOccurrence());

executionOccurrence.setStart(outReceiveEventOccurrence);

executionOccurrence.setFinish(inSendEventOccurrence);

Everything seems to be created correctly however when I try to create a
sequence diagram from this in RSA it fails and it seems to be because of
the ExecutionOccurence. If I remove the creation of this fragment I can
view the sequence digram but obviously no message connectors display
because there is no ExecutionOccurence assigned. Does any one have any
idea what I'm doing wrong.
Re: Execution Occurrence linking to Lifeline [message #468918 is a reply to message #468913] Wed, 24 January 2007 14:46 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

.... Looks like you are using the older version of RSA 6.x... I would highly
recommend upgrading since there have been many changes in this area ( see
the migration document
http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html).
Any code you write will have to change significantly after you upgrade.

One way to figure out the problem is to create such a sequence diagram in
RSA, save out the .emx and have a look at how the semantic portion of the
model is serialized out. That will indicate exacly what constructs are
needed to satisfy RSA. RSA used some special conventions to get around
shortcommings in the spec in regards to create messages etc.

If you still can't figure out what the issue is after that re-ask the
question and we'll have to debug it.

Regards,

- James.


"Paul Smith" <paul.t.smith@gmail.com> wrote in message
news:127bfef0686fbcc9103f0cf31a2e49a5$1@www.eclipse.org...
> I am currently using Rational Software Architects version of the UML api
> to try and create sequence diagrams. I am having difficulty in working out
> how to attach the ExecutionOccurrence to the Lifeline. My basic code is
> attempting to create two Lifelines and a synchronous message between the
> two. The code I have is as follows:
>
> String sequenceName = serviceClass.getName() +
> operation.getName().substring(0, 1).toUpperCase() +
> operation.getName().substring(1);
> //Add a collaboration instance to the class
> Collaboration collaboration = (Collaboration)
>
serviceClass.createNestedClassifier(UML2Package.eINSTANCE.ge tCollaboration()
);
> collaboration.setName(sequenceName + "Sequence");
> //Add an interaction to the collaboration
> Interaction interaction = (Interaction)
> collaboration.createOwnedBehavior(UML2Package.eINSTANCE.getI nteraction());
> interaction.setName(sequenceName + "Interaction");
> //Add the start lifeline
> Lifeline start =
> interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
> start.setName("Start");
> start.setRepresents(getStartProperty(collaboration));
> //Add the service lifeline
> Lifeline serviceLifeline =
> interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
> serviceLifeline.setName(serviceClass.getName());
> serviceLifeline.setRepresents(getServiceProperty(serviceClas s,
> collaboration));
>
> //Create a synchronous message from the start lifeline to the
> service
> Message createSendMessage =
> interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
> createSendMessage.setSignature(operation);
>
> createSendMessage.setMessageSort(MessageSort.SYNCH_CALL_LITE RAL);
> createSendMessage.setName("create");
>
>
> //Create the signal message back to the start lifeline
> Message createReturnMessage =
> interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
> createReturnMessage.setSignature(operation);
>
> createReturnMessage.setMessageSort(MessageSort.SYNCH_SIGNAL_ LITERAL);
> createReturnMessage.setName("create");
> createReturnMessage.addKeyword("return");
>
> //Create the two connector ends
> Connector connector = (Connector)
> interaction.createOwnedConnector(UML2Package.eINSTANCE.getCo nnector());
> ConnectorEnd startEnd =
> connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
> startEnd.setRole(start.getRepresents());
> ConnectorEnd serviceEnd =
> connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
> serviceEnd.setRole(serviceLifeline.getRepresents());
>
> createSendMessage.setConnector(connector);
> createReturnMessage.setConnector(connector);
>
> //theModels.createSequenceDiagram(connector.getNamespace(),
> sequenceName + "SequenceDiagram", false, interaction);
>
>
> //Create the event occurrences
> EventOccurrence outSendEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
> outSendEventOccurrence.setSendMessage(createSendMessage);
>
> EventOccurrence outReceiveEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
>
outReceiveEventOccurrence.setReceiveMessage(createSendMessag e);
>
>
> EventOccurrence inSendEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
> inSendEventOccurrence.setSendMessage(createReturnMessage);
>
> EventOccurrence inReceiveEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
>
> inReceiveEventOccurrence.setReceiveMessage(createReturnMessa ge);
>
> //Build an execution occurrence
> ExecutionOccurrence executionOccurrence =
> (ExecutionOccurrence)
>
interaction.createFragment(UML2Package.eINSTANCE.getExecutio nOccurrence());
>
> executionOccurrence.setStart(outReceiveEventOccurrence);
>
> executionOccurrence.setFinish(inSendEventOccurrence);
>
> Everything seems to be created correctly however when I try to create a
> sequence diagram from this in RSA it fails and it seems to be because of
> the ExecutionOccurence. If I remove the creation of this fragment I can
> view the sequence digram but obviously no message connectors display
> because there is no ExecutionOccurence assigned. Does any one have any
> idea what I'm doing wrong.
>
Re: Execution Occurrence linking to Lifeline [message #468926 is a reply to message #468918] Thu, 25 January 2007 02:25 Go to previous messageGo to next message
Paul Smith is currently offline Paul SmithFriend
Messages: 10
Registered: July 2009
Junior Member
Thanks for responding. We are in the process of scoping the move from RSA6
to RSA7 but it's a big job for us so I'm stuck with this version of the
api for now.

It seems that when I create the messages etc I'm not getting the 'covered'
attributes set in the model.

The following are the elements that I create via the api

<ownedConnector xmi:id="_3nYw46wVEducqaiCEy30_g">
<end xmi:id="_3nYw5KwVEducqaiCEy30_g"
role="_3nPm9qwVEducqaiCEy30_g"/>
<end xmi:id="_3nYw5awVEducqaiCEy30_g"
role="_3nPm-KwVEducqaiCEy30_g"/>
</ownedConnector>
<lifeline xmi:id="_3nPm9awVEducqaiCEy30_g" name="Start"
represents="_3nPm9qwVEducqaiCEy30_g"/>
<lifeline xmi:id="_3nPm96wVEducqaiCEy30_g" name="Example"
represents="_3nPm-KwVEducqaiCEy30_g"/>
<message xmi:id="_3nPm-awVEducqaiCEy30_g" name="create"
receiveEvent="_3nYw56wVEducqaiCEy30_g" sendEvent="_3nYw5qwVEducqaiCEy30_g"
connector="_3nYw46wVEducqaiCEy30_g" signature="_3m8sA6wVEducqaiCEy30_g"/>
<message xmi:id="_3nYw4KwVEducqaiCEy30_g" name="create"
messageSort="synchSignal" receiveEvent="_3nih4awVEducqaiCEy30_g"
sendEvent="_3nih4KwVEducqaiCEy30_g" connector="_3nYw46wVEducqaiCEy30_g"
signature="_3m8sA6wVEducqaiCEy30_g">
<eAnnotations xmi:id="_3nYw4awVEducqaiCEy30_g"
source="keywords">
<details xmi:id="_3nYw4qwVEducqaiCEy30_g" key="return"/>
</eAnnotations>
</message>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nYw5qwVEducqaiCEy30_g" sendMessage="_3nPm-awVEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nYw56wVEducqaiCEy30_g" receiveMessage="_3nPm-awVEducqaiCEy30_g"
startExec="_3nih4qwVEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nih4KwVEducqaiCEy30_g" sendMessage="_3nYw4KwVEducqaiCEy30_g"
finishExec="_3nih4qwVEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nih4awVEducqaiCEy30_g" receiveMessage="_3nYw4KwVEducqaiCEy30_g"/>
<fragment xmi:type="uml:ExecutionOccurrence"
xmi:id="_3nih4qwVEducqaiCEy30_g" start="_3nYw56wVEducqaiCEy30_g"
finish="_3nih4KwVEducqaiCEy30_g"/>
</ownedBehavior>
<ownedAttribute xmi:id="_3nPm9qwVEducqaiCEy30_g" name="start"
end="_3nYw5KwVEducqaiCEy30_g"/>
<ownedAttribute xmi:id="_3nPm-KwVEducqaiCEy30_g" name="service"
type="_3l5jJawVEducqaiCEy30_g" end="_3nYw5awVEducqaiCEy30_g"/>

However when I create a similar sequence using RSA I get the following

<ownedConnector xmi:id="_N8HXMKwWEducqaiCEy30_g">
<end xmi:id="_N8HXMawWEducqaiCEy30_g"
role="_3ob5wawVEducqaiCEy30_g"/>
<end xmi:id="_N8HXMqwWEducqaiCEy30_g"
role="_3ob5w6wVEducqaiCEy30_g"/>
</ownedConnector>
<lifeline xmi:id="_3ob5wKwVEducqaiCEy30_g" name="Start"
coveredBy="_N79mMawWEducqaiCEy30_g _N8HXOKwWEducqaiCEy30_g"
represents="_3ob5wawVEducqaiCEy30_g"/>
<lifeline xmi:id="_3ob5wqwVEducqaiCEy30_g" name="Example"
coveredBy="_N79mMqwWEducqaiCEy30_g _N8HXM6wWEducqaiCEy30_g
_N8HXNKwWEducqaiCEy30_g" represents="_3ob5w6wVEducqaiCEy30_g"/>
<message xmi:id="_N79mMKwWEducqaiCEy30_g" name="delete"
receiveEvent="_N79mMqwWEducqaiCEy30_g" sendEvent="_N79mMawWEducqaiCEy30_g"
connector="_N8HXMKwWEducqaiCEy30_g" signature="_3oIXy6wVEducqaiCEy30_g"/>
<message xmi:id="_N8HXNawWEducqaiCEy30_g" name="delete"
messageSort="synchSignal" receiveEvent="_N8HXOKwWEducqaiCEy30_g"
sendEvent="_N8HXNKwWEducqaiCEy30_g" connector="_N8HXMKwWEducqaiCEy30_g"
signature="_3oIXy6wVEducqaiCEy30_g">
<eAnnotations xmi:id="_N8HXNqwWEducqaiCEy30_g"
source="keywords">
<details xmi:id="_N8HXN6wWEducqaiCEy30_g" key="return"/>
</eAnnotations>
</message>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N79mMawWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
sendMessage="_N79mMKwWEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N79mMqwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
receiveMessage="_N79mMKwWEducqaiCEy30_g"
startExec="_N8HXM6wWEducqaiCEy30_g"/>
<fragment xmi:type="uml:ExecutionOccurrence"
xmi:id="_N8HXM6wWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
start="_N79mMqwWEducqaiCEy30_g" finish="_N8HXNKwWEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N8HXNKwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
sendMessage="_N8HXNawWEducqaiCEy30_g"
finishExec="_N8HXM6wWEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N8HXOKwWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
receiveMessage="_N8HXNawWEducqaiCEy30_g"/>
</ownedBehavior>
<ownedAttribute xmi:id="_3ob5wawVEducqaiCEy30_g" name="start"
end="_N8HXMawWEducqaiCEy30_g"/>
<ownedAttribute xmi:id="_3ob5w6wVEducqaiCEy30_g" name="service"
type="_3l5jJawVEducqaiCEy30_g" end="_N8HXMqwWEducqaiCEy30_g"/>

Notice the covered on the EventOccurrence and Lifelines. I've scoured the
newsgroups but cannot seem to find out how I set these up. Can you point
me at some examples that might indicate how to do this. I asked IBM but
they basically say "sure, just pay us and we'll have someone come over and
do it for you..."
Re: Execution Occurrence linking to Lifeline [message #468929 is a reply to message #468926] Thu, 25 January 2007 04:31 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

From your EventOccurrences you can do something like the following...

EventOccurrence outSendEventOccurrence = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
outSendEventOccurrence.setSendMessage(createSendMessage);

outSendEventOccurrence.getCovereds().add(myLifeline);

etc..


The old EventOccurrence is an InteractionFragment. The covereds collection
is defined there. The opposite end of that association is the Lifeline's
"covered by" collection.

Regards,

- James.



From your
"Paul Smith" <paul.t.smith@gmail.com> wrote in message
news:f5db63949c69d583ccb0f7d91b55339b$1@www.eclipse.org...
> Thanks for responding. We are in the process of scoping the move from RSA6
> to RSA7 but it's a big job for us so I'm stuck with this version of the
> api for now.
>
> It seems that when I create the messages etc I'm not getting the 'covered'
> attributes set in the model.
> The following are the elements that I create via the api
>
> <ownedConnector xmi:id="_3nYw46wVEducqaiCEy30_g">
> <end xmi:id="_3nYw5KwVEducqaiCEy30_g"
> role="_3nPm9qwVEducqaiCEy30_g"/>
> <end xmi:id="_3nYw5awVEducqaiCEy30_g"
> role="_3nPm-KwVEducqaiCEy30_g"/>
> </ownedConnector>
> <lifeline xmi:id="_3nPm9awVEducqaiCEy30_g" name="Start"
> represents="_3nPm9qwVEducqaiCEy30_g"/>
> <lifeline xmi:id="_3nPm96wVEducqaiCEy30_g" name="Example"
> represents="_3nPm-KwVEducqaiCEy30_g"/>
> <message xmi:id="_3nPm-awVEducqaiCEy30_g" name="create"
> receiveEvent="_3nYw56wVEducqaiCEy30_g" sendEvent="_3nYw5qwVEducqaiCEy30_g"
> connector="_3nYw46wVEducqaiCEy30_g" signature="_3m8sA6wVEducqaiCEy30_g"/>
> <message xmi:id="_3nYw4KwVEducqaiCEy30_g" name="create"
> messageSort="synchSignal" receiveEvent="_3nih4awVEducqaiCEy30_g"
> sendEvent="_3nih4KwVEducqaiCEy30_g" connector="_3nYw46wVEducqaiCEy30_g"
> signature="_3m8sA6wVEducqaiCEy30_g">
> <eAnnotations xmi:id="_3nYw4awVEducqaiCEy30_g"
> source="keywords">
> <details xmi:id="_3nYw4qwVEducqaiCEy30_g" key="return"/>
> </eAnnotations>
> </message>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nYw5qwVEducqaiCEy30_g" sendMessage="_3nPm-awVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nYw56wVEducqaiCEy30_g" receiveMessage="_3nPm-awVEducqaiCEy30_g"
> startExec="_3nih4qwVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nih4KwVEducqaiCEy30_g" sendMessage="_3nYw4KwVEducqaiCEy30_g"
> finishExec="_3nih4qwVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nih4awVEducqaiCEy30_g"
> receiveMessage="_3nYw4KwVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:ExecutionOccurrence"
> xmi:id="_3nih4qwVEducqaiCEy30_g" start="_3nYw56wVEducqaiCEy30_g"
> finish="_3nih4KwVEducqaiCEy30_g"/>
> </ownedBehavior>
> <ownedAttribute xmi:id="_3nPm9qwVEducqaiCEy30_g" name="start"
> end="_3nYw5KwVEducqaiCEy30_g"/>
> <ownedAttribute xmi:id="_3nPm-KwVEducqaiCEy30_g" name="service"
> type="_3l5jJawVEducqaiCEy30_g" end="_3nYw5awVEducqaiCEy30_g"/>
>
> However when I create a similar sequence using RSA I get the following
>
> <ownedConnector xmi:id="_N8HXMKwWEducqaiCEy30_g">
> <end xmi:id="_N8HXMawWEducqaiCEy30_g"
> role="_3ob5wawVEducqaiCEy30_g"/>
> <end xmi:id="_N8HXMqwWEducqaiCEy30_g"
> role="_3ob5w6wVEducqaiCEy30_g"/>
> </ownedConnector>
> <lifeline xmi:id="_3ob5wKwVEducqaiCEy30_g" name="Start"
> coveredBy="_N79mMawWEducqaiCEy30_g _N8HXOKwWEducqaiCEy30_g"
> represents="_3ob5wawVEducqaiCEy30_g"/>
> <lifeline xmi:id="_3ob5wqwVEducqaiCEy30_g" name="Example"
> coveredBy="_N79mMqwWEducqaiCEy30_g _N8HXM6wWEducqaiCEy30_g
> _N8HXNKwWEducqaiCEy30_g" represents="_3ob5w6wVEducqaiCEy30_g"/>
> <message xmi:id="_N79mMKwWEducqaiCEy30_g" name="delete"
> receiveEvent="_N79mMqwWEducqaiCEy30_g" sendEvent="_N79mMawWEducqaiCEy30_g"
> connector="_N8HXMKwWEducqaiCEy30_g" signature="_3oIXy6wVEducqaiCEy30_g"/>
> <message xmi:id="_N8HXNawWEducqaiCEy30_g" name="delete"
> messageSort="synchSignal" receiveEvent="_N8HXOKwWEducqaiCEy30_g"
> sendEvent="_N8HXNKwWEducqaiCEy30_g" connector="_N8HXMKwWEducqaiCEy30_g"
> signature="_3oIXy6wVEducqaiCEy30_g">
> <eAnnotations xmi:id="_N8HXNqwWEducqaiCEy30_g"
> source="keywords">
> <details xmi:id="_N8HXN6wWEducqaiCEy30_g" key="return"/>
> </eAnnotations>
> </message>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N79mMawWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
> sendMessage="_N79mMKwWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N79mMqwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
> receiveMessage="_N79mMKwWEducqaiCEy30_g"
> startExec="_N8HXM6wWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:ExecutionOccurrence"
> xmi:id="_N8HXM6wWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
> start="_N79mMqwWEducqaiCEy30_g" finish="_N8HXNKwWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N8HXNKwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
> sendMessage="_N8HXNawWEducqaiCEy30_g"
> finishExec="_N8HXM6wWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N8HXOKwWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
> receiveMessage="_N8HXNawWEducqaiCEy30_g"/>
> </ownedBehavior>
> <ownedAttribute xmi:id="_3ob5wawVEducqaiCEy30_g" name="start"
> end="_N8HXMawWEducqaiCEy30_g"/>
> <ownedAttribute xmi:id="_3ob5w6wVEducqaiCEy30_g" name="service"
> type="_3l5jJawVEducqaiCEy30_g" end="_N8HXMqwWEducqaiCEy30_g"/>
>
> Notice the covered on the EventOccurrence and Lifelines. I've scoured the
> newsgroups but cannot seem to find out how I set these up. Can you point
> me at some examples that might indicate how to do this. I asked IBM but
> they basically say "sure, just pay us and we'll have someone come over and
> do it for you..."
>
Re: Execution Occurrence linking to Lifeline [message #469705 is a reply to message #468929] Mon, 29 January 2007 01:42 Go to previous message
Paul Smith is currently offline Paul SmithFriend
Messages: 10
Registered: July 2009
Junior Member
Thanks for helping out with this one. I finally found out what the issue
was so I'll publish the code here because it really annoys me when people
find the solution and don't publish it. I'd missed a couple of things. I
hadn't created EvenOccurrences that covered the start lifeline and I
hadn't added those to list of fragments in the right order.

The following is basically an RSA6 solution.

//Add a collaboration instance to the class
Collaboration collaboration = (Collaboration)
serviceClass.createNestedClassifier(UML2Package.eINSTANCE.ge tCollaboration());
collaboration.setName(sequenceName + "Sequence");
//Add an interaction to the collaboration
Interaction interaction = (Interaction)
collaboration.createOwnedBehavior(UML2Package.eINSTANCE.getI nteraction());
interaction.setName(sequenceName + "Interaction");
//Add the start lifeline
Lifeline start =
interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
start.setName("Start");
start.setRepresents(getStartProperty(collaboration));
//Add the service lifeline
Lifeline serviceLifeline =
interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
serviceLifeline.setName(serviceClass.getName());
serviceLifeline.setRepresents(getServiceProperty(serviceClas s,
collaboration));


//Create a synchronous message from the start lifeline to the
service
Message createSendMessage =
interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
createSendMessage.setSignature(operation);

createSendMessage.setMessageSort(MessageSort.SYNCH_CALL_LITE RAL);
createSendMessage.setName("create");
EventOccurrence outSendEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
EventOccurrence outReceiveEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
outSendEvent.getCovereds().add(start);
outReceiveEvent.getCovereds().add(serviceLifeline);
outSendEvent.setSendMessage(createSendMessage);
outReceiveEvent.setReceiveMessage(createSendMessage);


//Create the signal message back to the start lifeline
Message createReturnMessage =
interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
createReturnMessage.setSignature(operation);

createReturnMessage.setMessageSort(MessageSort.SYNCH_SIGNAL_ LITERAL);
createReturnMessage.setName("create");
createReturnMessage.addKeyword("return");
EventOccurrence inSendEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
EventOccurrence inReceiveEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
inSendEvent.getCovereds().add(serviceLifeline);
inReceiveEvent.getCovereds().add(start);
inSendEvent.setSendMessage(createReturnMessage);
inReceiveEvent.setReceiveMessage(createReturnMessage);


//Create the two connector ends
Connector connector = (Connector)
interaction.createOwnedConnector(UML2Package.eINSTANCE.getCo nnector());
ConnectorEnd startEnd =
connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
ConnectorEnd serviceEnd =
connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
serviceEnd.setRole(serviceLifeline.getRepresents());
createSendMessage.setConnector(connector);
createReturnMessage.setConnector(connector);


//Create the event occurrences
ExecutionOccurrence executionOccurrence =
(ExecutionOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getExecutio nOccurrence());
interaction.getFragments().add(outSendEvent);
interaction.getFragments().add(outReceiveEvent);
interaction.getFragments().add(executionOccurrence);
interaction.getFragments().add(inSendEvent);
interaction.getFragments().add(inReceiveEvent);
inSendEvent.getStartExecs().add(executionOccurrence);
outSendEvent.getStartExecs().add(executionOccurrence);
executionOccurrence.setStart(outReceiveEvent);
executionOccurrence.setFinish(inSendEvent);
Re: Execution Occurrence linking to Lifeline [message #573726 is a reply to message #468913] Wed, 24 January 2007 14:46 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

.... Looks like you are using the older version of RSA 6.x... I would highly
recommend upgrading since there have been many changes in this area ( see
the migration document
http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html).
Any code you write will have to change significantly after you upgrade.

One way to figure out the problem is to create such a sequence diagram in
RSA, save out the .emx and have a look at how the semantic portion of the
model is serialized out. That will indicate exacly what constructs are
needed to satisfy RSA. RSA used some special conventions to get around
shortcommings in the spec in regards to create messages etc.

If you still can't figure out what the issue is after that re-ask the
question and we'll have to debug it.

Regards,

- James.


"Paul Smith" <paul.t.smith@gmail.com> wrote in message
news:127bfef0686fbcc9103f0cf31a2e49a5$1@www.eclipse.org...
> I am currently using Rational Software Architects version of the UML api
> to try and create sequence diagrams. I am having difficulty in working out
> how to attach the ExecutionOccurrence to the Lifeline. My basic code is
> attempting to create two Lifelines and a synchronous message between the
> two. The code I have is as follows:
>
> String sequenceName = serviceClass.getName() +
> operation.getName().substring(0, 1).toUpperCase() +
> operation.getName().substring(1);
> //Add a collaboration instance to the class
> Collaboration collaboration = (Collaboration)
>
serviceClass.createNestedClassifier(UML2Package.eINSTANCE.ge tCollaboration()
);
> collaboration.setName(sequenceName + "Sequence");
> //Add an interaction to the collaboration
> Interaction interaction = (Interaction)
> collaboration.createOwnedBehavior(UML2Package.eINSTANCE.getI nteraction());
> interaction.setName(sequenceName + "Interaction");
> //Add the start lifeline
> Lifeline start =
> interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
> start.setName("Start");
> start.setRepresents(getStartProperty(collaboration));
> //Add the service lifeline
> Lifeline serviceLifeline =
> interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
> serviceLifeline.setName(serviceClass.getName());
> serviceLifeline.setRepresents(getServiceProperty(serviceClas s,
> collaboration));
>
> //Create a synchronous message from the start lifeline to the
> service
> Message createSendMessage =
> interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
> createSendMessage.setSignature(operation);
>
> createSendMessage.setMessageSort(MessageSort.SYNCH_CALL_LITE RAL);
> createSendMessage.setName("create");
>
>
> //Create the signal message back to the start lifeline
> Message createReturnMessage =
> interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
> createReturnMessage.setSignature(operation);
>
> createReturnMessage.setMessageSort(MessageSort.SYNCH_SIGNAL_ LITERAL);
> createReturnMessage.setName("create");
> createReturnMessage.addKeyword("return");
>
> //Create the two connector ends
> Connector connector = (Connector)
> interaction.createOwnedConnector(UML2Package.eINSTANCE.getCo nnector());
> ConnectorEnd startEnd =
> connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
> startEnd.setRole(start.getRepresents());
> ConnectorEnd serviceEnd =
> connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
> serviceEnd.setRole(serviceLifeline.getRepresents());
>
> createSendMessage.setConnector(connector);
> createReturnMessage.setConnector(connector);
>
> //theModels.createSequenceDiagram(connector.getNamespace(),
> sequenceName + "SequenceDiagram", false, interaction);
>
>
> //Create the event occurrences
> EventOccurrence outSendEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
> outSendEventOccurrence.setSendMessage(createSendMessage);
>
> EventOccurrence outReceiveEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
>
outReceiveEventOccurrence.setReceiveMessage(createSendMessag e);
>
>
> EventOccurrence inSendEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
> inSendEventOccurrence.setSendMessage(createReturnMessage);
>
> EventOccurrence inReceiveEventOccurrence = (EventOccurrence)
> interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
>
> inReceiveEventOccurrence.setReceiveMessage(createReturnMessa ge);
>
> //Build an execution occurrence
> ExecutionOccurrence executionOccurrence =
> (ExecutionOccurrence)
>
interaction.createFragment(UML2Package.eINSTANCE.getExecutio nOccurrence());
>
> executionOccurrence.setStart(outReceiveEventOccurrence);
>
> executionOccurrence.setFinish(inSendEventOccurrence);
>
> Everything seems to be created correctly however when I try to create a
> sequence diagram from this in RSA it fails and it seems to be because of
> the ExecutionOccurence. If I remove the creation of this fragment I can
> view the sequence digram but obviously no message connectors display
> because there is no ExecutionOccurence assigned. Does any one have any
> idea what I'm doing wrong.
>
Re: Execution Occurrence linking to Lifeline [message #573818 is a reply to message #468918] Thu, 25 January 2007 02:25 Go to previous message
Paul Smith is currently offline Paul SmithFriend
Messages: 10
Registered: July 2009
Junior Member
Thanks for responding. We are in the process of scoping the move from RSA6
to RSA7 but it's a big job for us so I'm stuck with this version of the
api for now.

It seems that when I create the messages etc I'm not getting the 'covered'
attributes set in the model.

The following are the elements that I create via the api

<ownedConnector xmi:id="_3nYw46wVEducqaiCEy30_g">
<end xmi:id="_3nYw5KwVEducqaiCEy30_g"
role="_3nPm9qwVEducqaiCEy30_g"/>
<end xmi:id="_3nYw5awVEducqaiCEy30_g"
role="_3nPm-KwVEducqaiCEy30_g"/>
</ownedConnector>
<lifeline xmi:id="_3nPm9awVEducqaiCEy30_g" name="Start"
represents="_3nPm9qwVEducqaiCEy30_g"/>
<lifeline xmi:id="_3nPm96wVEducqaiCEy30_g" name="Example"
represents="_3nPm-KwVEducqaiCEy30_g"/>
<message xmi:id="_3nPm-awVEducqaiCEy30_g" name="create"
receiveEvent="_3nYw56wVEducqaiCEy30_g" sendEvent="_3nYw5qwVEducqaiCEy30_g"
connector="_3nYw46wVEducqaiCEy30_g" signature="_3m8sA6wVEducqaiCEy30_g"/>
<message xmi:id="_3nYw4KwVEducqaiCEy30_g" name="create"
messageSort="synchSignal" receiveEvent="_3nih4awVEducqaiCEy30_g"
sendEvent="_3nih4KwVEducqaiCEy30_g" connector="_3nYw46wVEducqaiCEy30_g"
signature="_3m8sA6wVEducqaiCEy30_g">
<eAnnotations xmi:id="_3nYw4awVEducqaiCEy30_g"
source="keywords">
<details xmi:id="_3nYw4qwVEducqaiCEy30_g" key="return"/>
</eAnnotations>
</message>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nYw5qwVEducqaiCEy30_g" sendMessage="_3nPm-awVEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nYw56wVEducqaiCEy30_g" receiveMessage="_3nPm-awVEducqaiCEy30_g"
startExec="_3nih4qwVEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nih4KwVEducqaiCEy30_g" sendMessage="_3nYw4KwVEducqaiCEy30_g"
finishExec="_3nih4qwVEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_3nih4awVEducqaiCEy30_g" receiveMessage="_3nYw4KwVEducqaiCEy30_g"/>
<fragment xmi:type="uml:ExecutionOccurrence"
xmi:id="_3nih4qwVEducqaiCEy30_g" start="_3nYw56wVEducqaiCEy30_g"
finish="_3nih4KwVEducqaiCEy30_g"/>
</ownedBehavior>
<ownedAttribute xmi:id="_3nPm9qwVEducqaiCEy30_g" name="start"
end="_3nYw5KwVEducqaiCEy30_g"/>
<ownedAttribute xmi:id="_3nPm-KwVEducqaiCEy30_g" name="service"
type="_3l5jJawVEducqaiCEy30_g" end="_3nYw5awVEducqaiCEy30_g"/>

However when I create a similar sequence using RSA I get the following

<ownedConnector xmi:id="_N8HXMKwWEducqaiCEy30_g">
<end xmi:id="_N8HXMawWEducqaiCEy30_g"
role="_3ob5wawVEducqaiCEy30_g"/>
<end xmi:id="_N8HXMqwWEducqaiCEy30_g"
role="_3ob5w6wVEducqaiCEy30_g"/>
</ownedConnector>
<lifeline xmi:id="_3ob5wKwVEducqaiCEy30_g" name="Start"
coveredBy="_N79mMawWEducqaiCEy30_g _N8HXOKwWEducqaiCEy30_g"
represents="_3ob5wawVEducqaiCEy30_g"/>
<lifeline xmi:id="_3ob5wqwVEducqaiCEy30_g" name="Example"
coveredBy="_N79mMqwWEducqaiCEy30_g _N8HXM6wWEducqaiCEy30_g
_N8HXNKwWEducqaiCEy30_g" represents="_3ob5w6wVEducqaiCEy30_g"/>
<message xmi:id="_N79mMKwWEducqaiCEy30_g" name="delete"
receiveEvent="_N79mMqwWEducqaiCEy30_g" sendEvent="_N79mMawWEducqaiCEy30_g"
connector="_N8HXMKwWEducqaiCEy30_g" signature="_3oIXy6wVEducqaiCEy30_g"/>
<message xmi:id="_N8HXNawWEducqaiCEy30_g" name="delete"
messageSort="synchSignal" receiveEvent="_N8HXOKwWEducqaiCEy30_g"
sendEvent="_N8HXNKwWEducqaiCEy30_g" connector="_N8HXMKwWEducqaiCEy30_g"
signature="_3oIXy6wVEducqaiCEy30_g">
<eAnnotations xmi:id="_N8HXNqwWEducqaiCEy30_g"
source="keywords">
<details xmi:id="_N8HXN6wWEducqaiCEy30_g" key="return"/>
</eAnnotations>
</message>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N79mMawWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
sendMessage="_N79mMKwWEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N79mMqwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
receiveMessage="_N79mMKwWEducqaiCEy30_g"
startExec="_N8HXM6wWEducqaiCEy30_g"/>
<fragment xmi:type="uml:ExecutionOccurrence"
xmi:id="_N8HXM6wWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
start="_N79mMqwWEducqaiCEy30_g" finish="_N8HXNKwWEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N8HXNKwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
sendMessage="_N8HXNawWEducqaiCEy30_g"
finishExec="_N8HXM6wWEducqaiCEy30_g"/>
<fragment xmi:type="uml:EventOccurrence"
xmi:id="_N8HXOKwWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
receiveMessage="_N8HXNawWEducqaiCEy30_g"/>
</ownedBehavior>
<ownedAttribute xmi:id="_3ob5wawVEducqaiCEy30_g" name="start"
end="_N8HXMawWEducqaiCEy30_g"/>
<ownedAttribute xmi:id="_3ob5w6wVEducqaiCEy30_g" name="service"
type="_3l5jJawVEducqaiCEy30_g" end="_N8HXMqwWEducqaiCEy30_g"/>

Notice the covered on the EventOccurrence and Lifelines. I've scoured the
newsgroups but cannot seem to find out how I set these up. Can you point
me at some examples that might indicate how to do this. I asked IBM but
they basically say "sure, just pay us and we'll have someone come over and
do it for you..."
Re: Execution Occurrence linking to Lifeline [message #573850 is a reply to message #468926] Thu, 25 January 2007 04:31 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

From your EventOccurrences you can do something like the following...

EventOccurrence outSendEventOccurrence = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
outSendEventOccurrence.setSendMessage(createSendMessage);

outSendEventOccurrence.getCovereds().add(myLifeline);

etc..


The old EventOccurrence is an InteractionFragment. The covereds collection
is defined there. The opposite end of that association is the Lifeline's
"covered by" collection.

Regards,

- James.



From your
"Paul Smith" <paul.t.smith@gmail.com> wrote in message
news:f5db63949c69d583ccb0f7d91b55339b$1@www.eclipse.org...
> Thanks for responding. We are in the process of scoping the move from RSA6
> to RSA7 but it's a big job for us so I'm stuck with this version of the
> api for now.
>
> It seems that when I create the messages etc I'm not getting the 'covered'
> attributes set in the model.
> The following are the elements that I create via the api
>
> <ownedConnector xmi:id="_3nYw46wVEducqaiCEy30_g">
> <end xmi:id="_3nYw5KwVEducqaiCEy30_g"
> role="_3nPm9qwVEducqaiCEy30_g"/>
> <end xmi:id="_3nYw5awVEducqaiCEy30_g"
> role="_3nPm-KwVEducqaiCEy30_g"/>
> </ownedConnector>
> <lifeline xmi:id="_3nPm9awVEducqaiCEy30_g" name="Start"
> represents="_3nPm9qwVEducqaiCEy30_g"/>
> <lifeline xmi:id="_3nPm96wVEducqaiCEy30_g" name="Example"
> represents="_3nPm-KwVEducqaiCEy30_g"/>
> <message xmi:id="_3nPm-awVEducqaiCEy30_g" name="create"
> receiveEvent="_3nYw56wVEducqaiCEy30_g" sendEvent="_3nYw5qwVEducqaiCEy30_g"
> connector="_3nYw46wVEducqaiCEy30_g" signature="_3m8sA6wVEducqaiCEy30_g"/>
> <message xmi:id="_3nYw4KwVEducqaiCEy30_g" name="create"
> messageSort="synchSignal" receiveEvent="_3nih4awVEducqaiCEy30_g"
> sendEvent="_3nih4KwVEducqaiCEy30_g" connector="_3nYw46wVEducqaiCEy30_g"
> signature="_3m8sA6wVEducqaiCEy30_g">
> <eAnnotations xmi:id="_3nYw4awVEducqaiCEy30_g"
> source="keywords">
> <details xmi:id="_3nYw4qwVEducqaiCEy30_g" key="return"/>
> </eAnnotations>
> </message>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nYw5qwVEducqaiCEy30_g" sendMessage="_3nPm-awVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nYw56wVEducqaiCEy30_g" receiveMessage="_3nPm-awVEducqaiCEy30_g"
> startExec="_3nih4qwVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nih4KwVEducqaiCEy30_g" sendMessage="_3nYw4KwVEducqaiCEy30_g"
> finishExec="_3nih4qwVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_3nih4awVEducqaiCEy30_g"
> receiveMessage="_3nYw4KwVEducqaiCEy30_g"/>
> <fragment xmi:type="uml:ExecutionOccurrence"
> xmi:id="_3nih4qwVEducqaiCEy30_g" start="_3nYw56wVEducqaiCEy30_g"
> finish="_3nih4KwVEducqaiCEy30_g"/>
> </ownedBehavior>
> <ownedAttribute xmi:id="_3nPm9qwVEducqaiCEy30_g" name="start"
> end="_3nYw5KwVEducqaiCEy30_g"/>
> <ownedAttribute xmi:id="_3nPm-KwVEducqaiCEy30_g" name="service"
> type="_3l5jJawVEducqaiCEy30_g" end="_3nYw5awVEducqaiCEy30_g"/>
>
> However when I create a similar sequence using RSA I get the following
>
> <ownedConnector xmi:id="_N8HXMKwWEducqaiCEy30_g">
> <end xmi:id="_N8HXMawWEducqaiCEy30_g"
> role="_3ob5wawVEducqaiCEy30_g"/>
> <end xmi:id="_N8HXMqwWEducqaiCEy30_g"
> role="_3ob5w6wVEducqaiCEy30_g"/>
> </ownedConnector>
> <lifeline xmi:id="_3ob5wKwVEducqaiCEy30_g" name="Start"
> coveredBy="_N79mMawWEducqaiCEy30_g _N8HXOKwWEducqaiCEy30_g"
> represents="_3ob5wawVEducqaiCEy30_g"/>
> <lifeline xmi:id="_3ob5wqwVEducqaiCEy30_g" name="Example"
> coveredBy="_N79mMqwWEducqaiCEy30_g _N8HXM6wWEducqaiCEy30_g
> _N8HXNKwWEducqaiCEy30_g" represents="_3ob5w6wVEducqaiCEy30_g"/>
> <message xmi:id="_N79mMKwWEducqaiCEy30_g" name="delete"
> receiveEvent="_N79mMqwWEducqaiCEy30_g" sendEvent="_N79mMawWEducqaiCEy30_g"
> connector="_N8HXMKwWEducqaiCEy30_g" signature="_3oIXy6wVEducqaiCEy30_g"/>
> <message xmi:id="_N8HXNawWEducqaiCEy30_g" name="delete"
> messageSort="synchSignal" receiveEvent="_N8HXOKwWEducqaiCEy30_g"
> sendEvent="_N8HXNKwWEducqaiCEy30_g" connector="_N8HXMKwWEducqaiCEy30_g"
> signature="_3oIXy6wVEducqaiCEy30_g">
> <eAnnotations xmi:id="_N8HXNqwWEducqaiCEy30_g"
> source="keywords">
> <details xmi:id="_N8HXN6wWEducqaiCEy30_g" key="return"/>
> </eAnnotations>
> </message>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N79mMawWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
> sendMessage="_N79mMKwWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N79mMqwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
> receiveMessage="_N79mMKwWEducqaiCEy30_g"
> startExec="_N8HXM6wWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:ExecutionOccurrence"
> xmi:id="_N8HXM6wWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
> start="_N79mMqwWEducqaiCEy30_g" finish="_N8HXNKwWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N8HXNKwWEducqaiCEy30_g" covered="_3ob5wqwVEducqaiCEy30_g"
> sendMessage="_N8HXNawWEducqaiCEy30_g"
> finishExec="_N8HXM6wWEducqaiCEy30_g"/>
> <fragment xmi:type="uml:EventOccurrence"
> xmi:id="_N8HXOKwWEducqaiCEy30_g" covered="_3ob5wKwVEducqaiCEy30_g"
> receiveMessage="_N8HXNawWEducqaiCEy30_g"/>
> </ownedBehavior>
> <ownedAttribute xmi:id="_3ob5wawVEducqaiCEy30_g" name="start"
> end="_N8HXMawWEducqaiCEy30_g"/>
> <ownedAttribute xmi:id="_3ob5w6wVEducqaiCEy30_g" name="service"
> type="_3l5jJawVEducqaiCEy30_g" end="_N8HXMqwWEducqaiCEy30_g"/>
>
> Notice the covered on the EventOccurrence and Lifelines. I've scoured the
> newsgroups but cannot seem to find out how I set these up. Can you point
> me at some examples that might indicate how to do this. I asked IBM but
> they basically say "sure, just pay us and we'll have someone come over and
> do it for you..."
>
Re: Execution Occurrence linking to Lifeline [message #576416 is a reply to message #468929] Mon, 29 January 2007 01:42 Go to previous message
Paul Smith is currently offline Paul SmithFriend
Messages: 10
Registered: July 2009
Junior Member
Thanks for helping out with this one. I finally found out what the issue
was so I'll publish the code here because it really annoys me when people
find the solution and don't publish it. I'd missed a couple of things. I
hadn't created EvenOccurrences that covered the start lifeline and I
hadn't added those to list of fragments in the right order.

The following is basically an RSA6 solution.

//Add a collaboration instance to the class
Collaboration collaboration = (Collaboration)
serviceClass.createNestedClassifier(UML2Package.eINSTANCE.ge tCollaboration());
collaboration.setName(sequenceName + "Sequence");
//Add an interaction to the collaboration
Interaction interaction = (Interaction)
collaboration.createOwnedBehavior(UML2Package.eINSTANCE.getI nteraction());
interaction.setName(sequenceName + "Interaction");
//Add the start lifeline
Lifeline start =
interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
start.setName("Start");
start.setRepresents(getStartProperty(collaboration));
//Add the service lifeline
Lifeline serviceLifeline =
interaction.createLifeline(UML2Package.eINSTANCE.getLifeline ());
serviceLifeline.setName(serviceClass.getName());
serviceLifeline.setRepresents(getServiceProperty(serviceClas s,
collaboration));


//Create a synchronous message from the start lifeline to the
service
Message createSendMessage =
interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
createSendMessage.setSignature(operation);

createSendMessage.setMessageSort(MessageSort.SYNCH_CALL_LITE RAL);
createSendMessage.setName("create");
EventOccurrence outSendEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
EventOccurrence outReceiveEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
outSendEvent.getCovereds().add(start);
outReceiveEvent.getCovereds().add(serviceLifeline);
outSendEvent.setSendMessage(createSendMessage);
outReceiveEvent.setReceiveMessage(createSendMessage);


//Create the signal message back to the start lifeline
Message createReturnMessage =
interaction.createMessage(UML2Package.eINSTANCE.getMessage() );
createReturnMessage.setSignature(operation);

createReturnMessage.setMessageSort(MessageSort.SYNCH_SIGNAL_ LITERAL);
createReturnMessage.setName("create");
createReturnMessage.addKeyword("return");
EventOccurrence inSendEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
EventOccurrence inReceiveEvent = (EventOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getEventOcc urrence());
inSendEvent.getCovereds().add(serviceLifeline);
inReceiveEvent.getCovereds().add(start);
inSendEvent.setSendMessage(createReturnMessage);
inReceiveEvent.setReceiveMessage(createReturnMessage);


//Create the two connector ends
Connector connector = (Connector)
interaction.createOwnedConnector(UML2Package.eINSTANCE.getCo nnector());
ConnectorEnd startEnd =
connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
ConnectorEnd serviceEnd =
connector.createEnd(UML2Package.eINSTANCE.getConnectorEnd()) ;
serviceEnd.setRole(serviceLifeline.getRepresents());
createSendMessage.setConnector(connector);
createReturnMessage.setConnector(connector);


//Create the event occurrences
ExecutionOccurrence executionOccurrence =
(ExecutionOccurrence)
interaction.createFragment(UML2Package.eINSTANCE.getExecutio nOccurrence());
interaction.getFragments().add(outSendEvent);
interaction.getFragments().add(outReceiveEvent);
interaction.getFragments().add(executionOccurrence);
interaction.getFragments().add(inSendEvent);
interaction.getFragments().add(inReceiveEvent);
inSendEvent.getStartExecs().add(executionOccurrence);
outSendEvent.getStartExecs().add(executionOccurrence);
executionOccurrence.setStart(outReceiveEvent);
executionOccurrence.setFinish(inSendEvent);
Previous Topic:Platform resource set/get
Next Topic:strange behavior when defining a profile
Goto Forum:
  


Current Time: Mon Aug 08 17:45:53 GMT 2022

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

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

Back to the top