Search in sources :

Example 1 with End

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

the class DeleteServices method deleteOperand.

public void deleteOperand(Operand operand) {
    EObject result = operand.eContainer();
    if (result instanceof CombinedFragment) {
        CombinedFragment combinedFragment = (CombinedFragment) result;
        End startingEnd = operand.getStartingEnd();
        End finishingEnd = null;
        EList<Operand> siblings = combinedFragment.getOwnedOperands();
        if (siblings.size() == 1) {
            deleteCombinedFragment(combinedFragment);
            return;
        }
        int index = siblings.indexOf(operand);
        if (index == siblings.size() - 1) {
            // The last operand ends with the CF
            finishingEnd = combinedFragment.getFinishingEnd();
        } else {
            // Other operands ends when their successor starts
            finishingEnd = siblings.get(index + 1).getStartingEnd();
        }
        delete((Interaction) combinedFragment.eContainer(), startingEnd, finishingEnd, false, combinedFragment.getCoveredParticipants());
    }
    return;
}
Also used : Operand(org.obeonetwork.dsl.interaction.Operand) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End) CompoundEnd(org.obeonetwork.dsl.interaction.CompoundEnd) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Example 2 with End

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

the class DeleteServices method delete.

private void delete(Interaction inter, End startingEnd, End finishingEnd, boolean deleteFinishingEnd, EList<Participant> coverage) {
    Set<EObject> toDelete = new HashSet<EObject>();
    boolean inside = false;
    for (End end : inter.getEnds()) {
        if (end == startingEnd) {
            toDelete.add(end);
            toDelete.add(end.getOwner());
            inside = true;
        } else if (end == finishingEnd) {
            if (deleteFinishingEnd) {
                toDelete.add(end);
                toDelete.add(end.getOwner());
            }
            break;
        } else if (inside && InteractionServices.covers(end, coverage)) {
            toDelete.add(end);
            toDelete.add(end.getOwner());
        }
    }
    Session session = null;
    ModelAccessor modelAccessor = null;
    for (EObject obj : toDelete) {
        if (session == null) {
            session = SessionManager.INSTANCE.getSession(obj);
        }
        if (modelAccessor == null) {
            modelAccessor = session.getModelAccessor();
        }
        delete(obj, session, modelAccessor);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) End(org.obeonetwork.dsl.interaction.End) CompoundEnd(org.obeonetwork.dsl.interaction.CompoundEnd) HashSet(java.util.HashSet) Session(org.eclipse.sirius.business.api.session.Session)

Example 3 with End

use of org.obeonetwork.dsl.interaction.End 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 4 with End

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

the class InteractionServices method computePredecessorForExecution.

public Execution computePredecessorForExecution(Execution execution) {
    // Get the preceding end
    List<End> precedingEnds = getPrecedingEnds(execution.getStartingEnd());
    // The predecessor is the last Execution found amongst the preceding executions
    Execution predecessor = null;
    for (End end : precedingEnds) {
        if (end.isExecutionEnd() && end.isStartingEnd()) {
            predecessor = end.getExecution();
        }
    }
    return predecessor;
}
Also used : Execution(org.obeonetwork.dsl.interaction.Execution) End(org.obeonetwork.dsl.interaction.End)

Example 5 with End

use of org.obeonetwork.dsl.interaction.End 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)

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