use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.
the class InteractionServices method computeExecutionDepth.
/**
* Computes the depth of an Execution. If the EObject is not an Execution,
* this method returns 0.
*
* @param eobject the EObject to find the depth if it is an Execution
* @param nbOfColors Total number of colors
* @return the depth if it is an Execution.
*/
public int computeExecutionDepth(EObject eobject, int nbOfColors) {
int executionDepth = 0;
if (eobject instanceof Execution) {
Execution currentExecution = (Execution) eobject;
Participant currentLifeline = currentExecution.getOwner();
End start = currentExecution.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.isExecutionEnd()) {
Execution execution = end.getExecution();
if (currentLifeline != null && execution != null && currentLifeline.equals(execution.getOwner())) {
if (execution.getStartingEnd().equals(end)) {
executionDepth++;
} else if (execution.getFinishingEnd().equals(end)) {
executionDepth--;
}
}
}
}
}
}
return getColorDepth(executionDepth, nbOfColors);
}
use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.
the class InteractionServices method computePredecessorForOperand.
public Operand computePredecessorForOperand(Operand operand) {
// Get the preceding end
List<End> precedingEnds = getPrecedingEnds(operand.getStartingEnd());
// The predecessor is the last Operand found amongst the preceding operands for the same combined fragment
Operand predecessor = null;
for (End end : precedingEnds) {
if (end.isOperandEnd() && end.isStartingEnd() && operand.eContainer().equals(end.getOperand().eContainer())) {
predecessor = end.getOperand();
}
}
return predecessor;
}
use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.
the class InteractionServices method computePredecessorForCombinedFragment.
public CombinedFragment computePredecessorForCombinedFragment(CombinedFragment combinedFragment) {
// Get the preceding end
List<End> precedingEnds = getPrecedingEnds(combinedFragment.getStartingEnd());
// The predecessor is the last CombinedFragment found amongst the preceding combined fragments
CombinedFragment predecessor = null;
for (End end : precedingEnds) {
if (end.isCombinedFragmentEnd() && end.isStartingEnd()) {
predecessor = end.getCombinedFragment();
}
}
return predecessor;
}
use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.
the class InteractionServices method getPrecedingEnds.
private List<End> getPrecedingEnds(End end) {
List<End> result = new ArrayList<End>();
Interaction interaction = (Interaction) end.eContainer();
for (End siblingEnd : interaction.getEnds()) {
if (!end.equals(siblingEnd)) {
result.add(siblingEnd);
} else {
return result;
}
}
return result;
}
use of org.obeonetwork.dsl.interaction.End in project InformationSystem by ObeoNetwork.
the class OperandImpl method getFinishingEnd.
/**
* @generated NOT
*/
@Override
public End getFinishingEnd() {
End result = null;
EObject eContainer = eContainer();
if (eContainer instanceof CombinedFragment) {
CombinedFragment cf = (CombinedFragment) eContainer;
result = cf.getFinishingEnd();
Operand prev = null;
for (Operand op : cf.getOwnedOperands()) {
if (this.equals(prev)) {
result = op.getStartingEnd();
break;
} else {
prev = op;
}
}
}
return result;
}
Aggregations