Search in sources :

Example 6 with End

use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.

the class InteractionServices method computePredecessorForInteractionUse.

public InteractionUse computePredecessorForInteractionUse(InteractionUse interactionUse) {
    // Get the preceding end
    List<End> precedingEnds = getPrecedingEnds(interactionUse.getStartingEnd());
    // The predecessor is the last InteractionUse found amongst the preceding interaction uses
    InteractionUse predecessor = null;
    for (End end : precedingEnds) {
        if (end.isInteractionUseEnd() && end.isStartingEnd()) {
            predecessor = end.getInteractionUse();
        }
    }
    return predecessor;
}
Also used : End(org.obeonetwork.dsl.interaction.End) InteractionUse(org.obeonetwork.dsl.interaction.InteractionUse)

Example 7 with End

use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.

the class InteractionServices method computeCombinedFragmentDepth.

/**
 * Compute the depth of a combined fragment. If the EObject if not a
 * combined fragment, this method return 0.
 *
 * @param eobject
 *            the EObject to find the depth if it is a combined fragment
 * @param nbOfColors Total number of colors
 * @return the depth if it is a combined fragment.
 */
public int computeCombinedFragmentDepth(EObject eobject, int nbOfColors) {
    int combinedFragmentDepth = 0;
    if (eobject instanceof CombinedFragment) {
        CombinedFragment currentCombinedFragment = (CombinedFragment) eobject;
        EList<Participant> coveredParticipants = currentCombinedFragment.getCoveredParticipants();
        End start = currentCombinedFragment.getStartingEnd();
        EObject eContainer = start.eContainer();
        EList<EObject> eContents = eContainer.eContents();
        int startIndex = eContents.lastIndexOf(start);
        List<EObject> contents = eContents.subList(0, startIndex);
        for (EObject obj : contents) {
            if (obj instanceof End) {
                End end = (End) obj;
                if (end.isCombinedFragmentEnd()) {
                    CombinedFragment combinedFragment = end.getCombinedFragment();
                    if (covers(end, coveredParticipants)) {
                        if (combinedFragment.getStartingEnd().equals(end)) {
                            combinedFragmentDepth++;
                        } else if (combinedFragment.getFinishingEnd().equals(end)) {
                            combinedFragmentDepth--;
                        }
                    }
                }
            }
        }
    }
    return getColorDepth(combinedFragmentDepth, nbOfColors);
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Example 8 with End

use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.

the class InteractionServices method getReceivingContext.

/**
 * Returns the semantic element corresponding to the target of a message.
 * This can be a participant, execution or an instance role.
 *
 * @param msg
 *            the message.
 * @return the semantic elements corresponding to the target of the message.
 */
public EObject getReceivingContext(Message msg) {
    End receivingEnd = msg.getFinishingEnd();
    if (receivingEnd != null) {
        Participant p = receivingEnd.getContext();
        List<EventContext> structure = computeContainmentStructure(p);
        for (EventContext ec : structure) {
            if (ec.getElement().equals(msg) && !ec.isStart()) {
                EObject parent = ec.getParent();
                if (parent != null) {
                    return parent;
                } else {
                    return p;
                }
            }
        }
    }
    return msg;
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End)

Example 9 with End

use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.

the class InteractionServices method computePredecessorForStateInvariant.

public StateInvariant computePredecessorForStateInvariant(StateInvariant stateInvariant) {
    // Get the preceding end
    List<End> precedingEnds = getPrecedingEnds(stateInvariant.getStartingEnd());
    // The predecessor is the last StateInvariant found amongst the preceding state invariants
    StateInvariant predecessor = null;
    for (End end : precedingEnds) {
        if (end.isStateInvariantEnd() && end.isStartingEnd()) {
            predecessor = end.getStateInvariant();
        }
    }
    return predecessor;
}
Also used : End(org.obeonetwork.dsl.interaction.End) StateInvariant(org.obeonetwork.dsl.interaction.StateInvariant)

Example 10 with End

use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.

the class InteractionServices method getSendingContext.

/**
 * Returns the event end which represents the finishing of an operand. An
 * operand only has a starting end in the model. Its finishing end must be
 * inferred from the context. If the operand is the last operand in the
 * Combined Fragment, it finishes with the end of the CF. Otherwise it
 * finished when the next operand starts.
 *
 * @param operand
 *            the operand.
 * @return the event end which represents the finishing of the operand.
 */
// public AbstractEnd getFinishingEnd(Operand operand) {
// AbstractEnd result = null;
// EObject eContainer = operand.eContainer();
// 
// if (eContainer instanceof CombinedFragment) {
// CombinedFragment cf = (CombinedFragment) eContainer;
// result = cf.getFinish();
// 
// Operand prev = null;
// for (Operand op : cf.getOwnedOperands()) {
// if (operand.equals(prev)) {
// result = op.getStart();
// break;
// } else {
// prev = op;
// }
// }
// }
// 
// return result;
// }
/**
 * Returns the semantic element corresponding to the source of a message.
 * This can be a participant or an execution.
 *
 * @param msg
 *            the message.
 * @return the semantic elements corresponding to the source of the message.
 */
public EObject getSendingContext(Message msg) {
    End sendingEnd = msg.getStartingEnd();
    if (sendingEnd != null) {
        Participant p = sendingEnd.getContext();
        List<EventContext> structure = computeContainmentStructure(p);
        for (EventContext ec : structure) {
            if (ec.getElement().equals(msg) && ec.isStart()) {
                EObject parent = ec.getParent();
                if (parent != null) {
                    return parent;
                } else {
                    return p;
                }
            }
        }
    }
    return msg;
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End)

Aggregations

End (org.obeonetwork.dsl.interaction.End)15 EObject (org.eclipse.emf.ecore.EObject)8 CombinedFragment (org.obeonetwork.dsl.interaction.CombinedFragment)4 Participant (org.obeonetwork.dsl.interaction.Participant)4 Operand (org.obeonetwork.dsl.interaction.Operand)3 ArrayList (java.util.ArrayList)2 CompoundEnd (org.obeonetwork.dsl.interaction.CompoundEnd)2 DestroyParticipantMessage (org.obeonetwork.dsl.interaction.DestroyParticipantMessage)2 Execution (org.obeonetwork.dsl.interaction.Execution)2 Interaction (org.obeonetwork.dsl.interaction.Interaction)2 Message (org.obeonetwork.dsl.interaction.Message)2 HashSet (java.util.HashSet)1 Stack (java.util.Stack)1 Session (org.eclipse.sirius.business.api.session.Session)1 ModelAccessor (org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor)1 InteractionUse (org.obeonetwork.dsl.interaction.InteractionUse)1 StateInvariant (org.obeonetwork.dsl.interaction.StateInvariant)1