/*
* Creates an relToResolve only considering the relation. Not completely initialized.
*/
RelToResolve relToResolve = new RelToResolveImpl(source, rel);
Resolved<Component> resolved = null;
/*
* If the source is an instance, verify if there is explicit promotions declared in the composite
*
* TODO When an explicit promotion is declared, we perform resolution inside the composite if the
* promotion fails. This is not very intuitive but is more resilient, to discuss which is the good
* specification.
*/
if (source instanceof Instance) {
resolved = checkExplicitPromotion((Instance) source, relToResolve);
}
/*
* If the source is not an instance or there is no explicit promotion, delegate to managers
*/
if (resolved == null) {
/*
* Delegate resolution to managers and update the model
*/
resolved = this.resolveByManagers(relToResolve);
if (resolved != null) {
updateModel(source, relToResolve, resolved, relToResolve.hasConstraints(),false);
}
/*
* As a last resort try implicit promotion
*
* NOTE Notice that we recreate the relation to resolve from the declarations, to be sure
* that we ignore all constraints that could be added by the managers during the first try
*/
if (resolved == null && source instanceof Instance) {
resolved = checkImplicitPromotion((Instance) source,new RelToResolveImpl(source,rel));
}
else if (resolved != null && source instanceof Instance && relToResolve.isMultiple()) {
/*
* TODO For relations with cardinality multiple, we try to merge all available targets,
* so we merge the managers' result with the implicit promotions. This is not very intuitive
* but is more resilient, to discuss which is the good specification.
*/