private String createElseGuardCondition(Transition in_oTransition) throws Exception
{
StringBuffer sElseGuard = new StringBuffer();
// find all other outgoing transitions
Vertex oSourceState = in_oTransition.getSource();
for(Transition oOutgoingTransition : oSourceState.getOutgoings()) {
// only consider transitions that are not the current one (in_oTransition)
if(oOutgoingTransition.equals(in_oTransition)) {
continue;
}
// transition has to have the same trigger as the original transition!
if(oOutgoingTransition.getTriggers().isEmpty()) {
if(!in_oTransition.getTriggers().isEmpty()) {
continue;
}
}
else {
if(in_oTransition.getTriggers().isEmpty()) {
continue;
}
else {
boolean bOverlap = false;
// check overlapping of trigger events
for(Trigger oOutgoingTrigger : oOutgoingTransition.getTriggers()) {
for(Trigger oInTrigger : in_oTransition.getTriggers()) {
if(oOutgoingTrigger.getEvent().equals(oInTrigger.getEvent()))
bOverlap = true;
}
}
if(bOverlap == false)
continue;
}
}
// model validation: no other empty guard and no other "else"
String sOutgoingGuard = ((LiteralString)oOutgoingTransition.getGuard().getSpecification()).getValue();
if(sOutgoingGuard.compareTo("else") == 0) {
throw new Exception("too many else conditions from node >" + oSourceState.getQualifiedName() + "<");
}
else if(sOutgoingGuard.isEmpty()) {
throw new Exception("one empty guard and one else guard together are not allowed from node >" + oSourceState.getQualifiedName() + "<");
}
// negate all other guards of transitions triggered by the same event and conjoin them at the else-guard
if(sElseGuard.length() > 0) {
sElseGuard.append(" and ");