EObject tObject = null;
TraceLink tl = null;
int i = 0;
for(TraceLinkNode tObjectTLN : modelCorrespondence.getCorrespondingElement(tiObject)){
if(tObjectTLN.getModel().getModelType()!=ModelType.TEMPLATE_MODEL){
throw new SynchronizingException("ME2MELink pointed from template instance to " + tObjectTLN.getModel().getModelType().toString());
}
if(tObjectTLN.isAttribute()){
throw new SynchronizingException("ModelElement in TemplateInstance is corresponding to attribute in template model");
}
if(tObject!=null){
throw new SynchronizingException("There can only be one TraceLink for one element in TemplateInstance");
}
tObject=tObjectTLN.getModelElement();
tl=tObjectTLN.getPartOfTraceLink();
i++;
}
if(i>1) log.info("BUG: More corresponding tObjects!");
if(i==0){
//FIXME As for now we through an exception later we could try to tolerate
// a certain degree of inconsistency
throw new SynchronizingException("Didn't find corresponding tObject for tiObject");
}
return new EObjectTraceLinkReturnContainer(tObject,tl);
}