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 #573691] Wed, 24 January 2007 00:03
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.
Previous Topic:State Machine - UML Editor & Programmatic
Next Topic:Re: [Announce] MDT UML2TOOLS 1.0.0M4 is available
Goto Forum:
  


Current Time: Sun Apr 05 01:59:17 GMT 2020

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

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

Back to the top