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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations