use of org.obeonetwork.dsl.interaction.Message in project InformationSystem by ObeoNetwork.
the class InteractionServices method computePredecessorForMessage.
public Message computePredecessorForMessage(Message message) {
// Get the preceding end
List<End> precedingEnds = getPrecedingEnds(message.getStartingEnd());
// The predecessor is the last Message found amongst the preceding messages
Message predecessor = null;
for (End end : precedingEnds) {
if (end.isMessageEnd() && end.isFinishingEnd()) {
predecessor = end.getMessage();
}
}
return predecessor;
}
use of org.obeonetwork.dsl.interaction.Message in project InformationSystem by ObeoNetwork.
the class InteractionServices method computeContainmentStructure.
private List<EventContext> computeContainmentStructure(Participant owner) {
if (!(owner.eContainer() instanceof Interaction)) {
return Collections.emptyList();
} else {
Interaction interaction = (Interaction) owner.eContainer();
Stack<EObject> ancestors = new Stack<EObject>();
ancestors.push(owner);
List<EventContext> result = new ArrayList<EventContext>();
for (End end : interaction.getEnds()) {
if (end.getContext() != owner) {
continue;
}
if (end.isStartingEnd() && end.isExecutionEnd()) {
result.add(new EventContext(ancestors.peek(), end.getExecution(), true, ancestors.size() + 1));
ancestors.push(end.getExecution());
}
if (end.isStartingEnd() && end.isStateInvariantEnd()) {
result.add(new EventContext(ancestors.peek(), end.getStateInvariant(), true, ancestors.size() + 1));
ancestors.push(end.getStateInvariant());
}
if (end.isMessageEnd()) {
Message msg = end.getMessage();
if (msg != null) {
result.add(new EventContext(ancestors.peek(), end.getMessage(), end.equals(msg.getStartingEnd()), ancestors.size()));
}
}
if (end.isFinishingEnd() && end.isExecutionEnd()) {
ancestors.pop();
result.add(new EventContext(ancestors.peek(), end.getExecution(), false, ancestors.size() + 1));
}
if (end.isFinishingEnd() && (end.isStateInvariantEnd())) {
ancestors.pop();
result.add(new EventContext(ancestors.peek(), end.getStateInvariant(), false, ancestors.size() + 1));
}
}
return result;
}
}
use of org.obeonetwork.dsl.interaction.Message in project InformationSystem by ObeoNetwork.
the class DeleteServices method getMessagesForParticipant.
private List<Message> getMessagesForParticipant(Participant participant) {
Interaction interaction = (Interaction) participant.eContainer();
List<Message> result = new ArrayList<Message>();
for (Message message : interaction.getMessages()) {
if (message.getStartingEnd() != null && participant.equals(message.getStartingEnd().getContext())) {
result.add(message);
} else if (message.getFinishingEnd() != null && participant.equals(message.getFinishingEnd().getContext())) {
result.add(message);
}
}
return result;
}
use of org.obeonetwork.dsl.interaction.Message in project InformationSystem by ObeoNetwork.
the class InteractionServices method isPointedByDestroyMessage.
/**
* Return true if the context is pointed by a DestroyParticipantMessage.
* @param context the context on which is applied the service
* @return boolean, true if the context is pointed by a DestroyParticipantMessage, false otherwise
*/
public boolean isPointedByDestroyMessage(Participant context) {
boolean isPointedByDestroyMessage = false;
Interaction interaction = null;
EObject container = context.eContainer();
while (container != null) {
if (container instanceof Interaction) {
interaction = (Interaction) container;
// loop output
container = null;
} else {
container = container.eContainer();
}
}
if (interaction != null) {
List<Message> messages = interaction.getMessages();
List<DestroyParticipantMessage> destroyParticipantMesssages = new ArrayList<DestroyParticipantMessage>();
for (Message message : messages) {
// Retrieve DestroParticipantMessage
if (message instanceof DestroyParticipantMessage) {
destroyParticipantMesssages.add((DestroyParticipantMessage) message);
}
}
for (DestroyParticipantMessage destroyParticipantMessage : destroyParticipantMesssages) {
// Retrieve the finishingEnd that the context is the same as parameter
if (destroyParticipantMessage.getFinishingEnd().getContext() == context) {
isPointedByDestroyMessage = true;
}
}
}
return isPointedByDestroyMessage;
}
Aggregations