Search in sources :

Example 1 with Message

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;
}
Also used : Message(org.obeonetwork.dsl.interaction.Message) DestroyParticipantMessage(org.obeonetwork.dsl.interaction.DestroyParticipantMessage) End(org.obeonetwork.dsl.interaction.End)

Example 2 with Message

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;
    }
}
Also used : Message(org.obeonetwork.dsl.interaction.Message) DestroyParticipantMessage(org.obeonetwork.dsl.interaction.DestroyParticipantMessage) Interaction(org.obeonetwork.dsl.interaction.Interaction) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) End(org.obeonetwork.dsl.interaction.End) Stack(java.util.Stack)

Example 3 with Message

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;
}
Also used : Message(org.obeonetwork.dsl.interaction.Message) Interaction(org.obeonetwork.dsl.interaction.Interaction) ArrayList(java.util.ArrayList)

Example 4 with Message

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;
}
Also used : DestroyParticipantMessage(org.obeonetwork.dsl.interaction.DestroyParticipantMessage) Message(org.obeonetwork.dsl.interaction.Message) DestroyParticipantMessage(org.obeonetwork.dsl.interaction.DestroyParticipantMessage) Interaction(org.obeonetwork.dsl.interaction.Interaction) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList)

Aggregations

Message (org.obeonetwork.dsl.interaction.Message)4 ArrayList (java.util.ArrayList)3 DestroyParticipantMessage (org.obeonetwork.dsl.interaction.DestroyParticipantMessage)3 Interaction (org.obeonetwork.dsl.interaction.Interaction)3 EObject (org.eclipse.emf.ecore.EObject)2 End (org.obeonetwork.dsl.interaction.End)2 Stack (java.util.Stack)1