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