Skip to content
Snippets Groups Projects
Commit 27515144 authored by Johannes Mey's avatar Johannes Mey
Browse files

add attribute for potentially valid implementations

parent b539c508
Branches
No related tags found
No related merge requests found
...@@ -136,4 +136,76 @@ aspect Checking { ...@@ -136,4 +136,76 @@ aspect Checking {
throw new RuntimeException("Objective could not be computed!"); throw new RuntimeException("Objective could not be computed!");
} }
syn java.util.List<Implementation> Component.locallyValidImplementations(Request request) {
java.util.List<Implementation> locallyValidImplementations = new java.util.ArrayList<>();
for (Implementation implementation : this.getImplementationList()) {
Assignment assignment = new Assignment();
assignment.setTopLevel(true);
assignment.setRequest(request);
assignment.setImplementation(implementation);
boolean fitting = true;
for (Clause clause : request.getConstraintList()) {
if (clause.isRequiringClause() && clause.getDesignator().isSoftwareDesignator()) {
if (!clause.checkUsing(assignment)) {
fitting = false;
logger.info("found a not fitting top level impl");
break;
}
}
}
if (fitting) {
locallyValidImplementations.add(implementation);
}
}
return locallyValidImplementations;
}
syn java.util.List<Implementation> Component.locallyValidImplementations(Request request, Implementation parentImplementation, Instance instance) {
Assignment assignment = new Assignment();
assignment.setTopLevel(false);
assignment.setRequest(request);
assignment.setImplementation(parentImplementation);
java.util.List<Implementation> locallyValidImplementations = new java.util.ArrayList<>();
for (Implementation implementation : this.getImplementationList()) {
Assignment subAssignment = new Assignment();
subAssignment.setTopLevel(false);
subAssignment.setRequest(assignment.getRequest());
subAssignment.setImplementation(implementation);
ComponentMapping mapping = new ComponentMapping(instance, subAssignment);
int mappingIndex = 0;
for (; mappingIndex < assignment.getNumComponentMapping(); mappingIndex++) {
if (assignment.getComponentMapping(mappingIndex).getInstance() == instance) {
break;
}
}
assignment.setComponentMapping(mapping, mappingIndex);
boolean fitting = true;
for (Clause clause : assignment.getImplementation().getClauseList()) {
if (clause.isRequiringClause() && clause.getDesignator().isSoftwareDesignator()) {
if (clause.getDesignator().asSoftwareDesignator().getInstanceRef().getRef() == instance) {
if (!clause.checkUsing(assignment)) {
fitting = false;
logger.info("found a not fitting impl");
break;
}
}
}
}
assignment.getComponentMappingList().removeChild(mappingIndex);
if (fitting) {
locallyValidImplementations.add(implementation);
}
}
return locallyValidImplementations;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment