Commit 8eec1cf4 authored by René Schöne's avatar René Schöne
Browse files

Fix property resolving.

parent d8d3e817
......@@ -189,7 +189,7 @@ aspect Navigation {
return Optional.of(instance);
}
}
return Optional.empty();
return getResourceRequirement().resolveInstance(name);
}
syn Optional<Instance> ResourceRequirement.resolveInstance(String name) {
......@@ -281,27 +281,41 @@ aspect Navigation {
}
}
}
// if no component instance has been found, look for a resource instance
ResourceRequirement currentRequirement = null;
Instance currentInstance = null;
// first resolve the instance
Optional<Instance> hwInstance;
// resolve all names but the last (which is a property)
for (int currentName = 0; currentName < qn.getNumName() - 1; currentName++) {
if (currentRequirement == null) {
currentRequirement = getResourceRequirement();
// TODO this has to be extended if the one resource requirement there is has more than one instance
currentInstance = getResourceRequirement().getInstance(0);
hwInstance = resolveInstance(instanceName);
if (!hwInstance.isPresent()) {
// instance can not be resolved -> bad
logger.error("Could not resolve first instance {}", instanceName);
return null;
}
currentInstance = hwInstance.get();
currentRequirement = currentInstance.containingResourceRequirement();
} else {
for (ResourceRequirement newResourceRequirement : currentRequirement.getResourceRequirementList())
for (Instance instance : newResourceRequirement.getInstanceList()) {
if (instance.name().equals(qn.getName(currentName).getName())) {
currentRequirement = newResourceRequirement;
currentInstance = instance;
}
}
hwInstance = currentRequirement.resolveInstance(qn.getName(currentName).getName());
if (!hwInstance.isPresent()) {
// instance can not be resolved -> bad
logger.error("Could not resolve {}th instance {}", currentName, qn.getName(currentName).getName());
return null;
}
currentInstance = hwInstance.get();
currentRequirement = currentInstance.containingResourceRequirement();
}
}
// now, currentRequirement refers to the final resource type
return new PropertyResourceDesignator(currentInstance.createRef(), currentRequirement.getResourceTypeRef().getRef().resolveProperty(qn.getName(qn.getNumName()-1).getName()).get().createRef());
Optional<Property> resolvedProperty = currentRequirement.getResourceTypeRef().getRef().resolveProperty(qn.getName(qn.getNumName() - 1).getName());
if (resolvedProperty.isPresent()) {
return new PropertyResourceDesignator(currentInstance.createRef(), resolvedProperty.get().createRef());
}
logger.error("Could not resolve property {}", qn);
return null;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment