Commit 5b0ea001 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

Fix the migration of MemoryRequirement annotations

MemoryRequirement annotations are now correctly migrated, even with multiple ComponentToTaskAllocationTable instances pointing to the same TaskArchitecture. In that case duplicate task architectures are generated.

Issue-Ref: 3598
Issue-Url: https://af3-developer.fortiss.org/issues/3598

Signed-off-by: Tiziano Munaro's avatarTiziano Munaro <munaro@fortiss.org>
parent 650995c2
AllocationToDeploymentTransformation.java a886f42410d752a4134fc768c997e731ed3a2b09 GREEN
MemoryRequirementAnnotationMigrationProvider.java aaf84d505fe7817054f8245f2ff983f92b393480 GREEN
MemoryRequirementAnnotationMigrationProvider.java 2b7c0b7fab51ce5d02adec4113aa3fedafc5f21b YELLOW
PeriodMigrationProvider.java 2fe676ee748e41d38c3f5afcbb3fa2e6188cbc80 GREEN
......@@ -19,6 +19,7 @@ import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.af3.allocation.utils.AllocationModelElementFactory.createAllocationTableCollection;
import static org.fortiss.af3.allocation.utils.AllocationUtils.cloneView;
import static org.fortiss.af3.allocation.utils.AllocationUtils.getOrCreateAllocationTable;
import static org.fortiss.tooling.common.util.LambdaUtils.asStream;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
......@@ -121,18 +122,44 @@ public class MemoryRequirementAnnotationMigrationProvider implements IMigrationP
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
createDuplicateTaskArchitectures(modelElement);
getMemoryRequirementAnnotationToMigrate(modelElement).forEach(memoryRequirement -> {
getOrCreateComponentToTaskAllocationTables(modelElement, memoryRequirement)
.forEach(allocationTable -> {
Component component = (Component)memoryRequirement.getSpecificationOf();
allocationTable.getTasks(component).forEach(task -> {
RamRequirement ramRequirement =
getOrCreateRamRequirementAnnotation(task);
ramRequirement.setBytes(ramRequirement.getBytes() +
memoryRequirement.getLocalMemoryRequirement());
});
});
List<ComponentToTaskAllocationTable> allocationTables =
getOrCreateComponentToTaskAllocationTables(modelElement, memoryRequirement);
allocationTables.forEach(allocationTable -> {
Component component = (Component)memoryRequirement.getSpecificationOf();
allocationTable.getTasks(component).forEach(task -> {
RamRequirement ramRequirement = getOrCreateRamRequirementAnnotation(task);
ramRequirement.setBytes(ramRequirement.getBytes() +
memoryRequirement.getLocalMemoryRequirement());
});
});
delete(memoryRequirement);
});
}
/**
* Creates duplicates of {@link TaskArchitecture} instances which are referenced by multiple
* {@link ComponentToTaskAllocationTable} instances
*/
private void createDuplicateTaskArchitectures(ITopLevelElement modelElement) {
FileProject fileProject = (FileProject)modelElement.getRootModelElement();
for(TaskArchitecture taskArchitecture : getChildrenWithType(fileProject,
TaskArchitecture.class)) {
List<ComponentToTaskAllocationTable> allocationTablesPerTaskArchitecture =
getChildrenWithType(fileProject, ComponentToTaskAllocationTable.class).stream()
.filter(allocationTable -> allocationTable
.getTargetView() == taskArchitecture)
.collect(toList());
int i = 0;
for(ComponentToTaskAllocationTable allocationTable : allocationTablesPerTaskArchitecture) {
// Reuse first task architecture
if(++i == 1) {
continue;
}
cloneView(allocationTable, false, true);
allocationTable.getTargetView().setName(taskArchitecture.getName() + (i - 1));
}
}
}
}
Markdown is supported
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