Commit 9a396b1f authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DSE-SolConv: Fix programmatic use of the service

* Fixes the Gantt preview in the DSE perspective.
* The DSE project model tree walk methods are now based on BiConsumers
  instead of BiFunctions since the output parameter was effectively
  never used and could cause confusion.
* Adds a second transform method for programmatic use of the
  transformation service.

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

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 9c89aeb8
GanttComposite.java c68c5336aff3f563cf35d113b9c876586a88080a GREEN
GanttScheduleVisualization.java 17f4e3078ea1276b4680ef8213c2fd59545aad07 YELLOW
GanttScheduleVisualization.java fe781c4c1ddff5f3209050c1f6b9840b3c1c014f YELLOW
......@@ -16,26 +16,22 @@
package org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.gantt;
import static java.util.Arrays.asList;
import static org.fortiss.af3.allocation.utils.AllocationModelElementFactory.createAllocationTableCollection;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createSuperSetMap;
import static org.fortiss.af3.task.util.TaskModelElementFactory.createTasksToExecutionUnitAllocationTable;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.af3.exploration.util.ExplorationUtils.getRootElementsFromSnaps;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ExplorationStep;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.project.SolutionSelectionStep;
import org.fortiss.af3.exploration.model.solutions.ExplorationSolution;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
import org.fortiss.af3.exploration.solutionconverter.DSESolutionArtifacts;
import org.fortiss.af3.exploration.solutionconverter.ScheduleConverter;
import org.fortiss.af3.exploration.ui.perspective.service.EventBroker;
......@@ -43,10 +39,8 @@ import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager
import org.fortiss.af3.exploration.ui.perspective.service.IEventListener;
import org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.IVisualizationView;
import org.fortiss.af3.schedule.model.ResourceAllocation;
import org.fortiss.af3.schedule.model.ResourceSchedule;
import org.fortiss.af3.schedule.model.SystemSchedule;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationTable;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
/**
* Visualizes a {@link SystemSchedule} if one has been calculated by the last DSE run.
......@@ -58,14 +52,17 @@ public final class GanttScheduleVisualization implements IVisualizationView, IEv
/** Viewer. */
private GanttComposite ganttViewer;
/** Active {@link DSE} node. */
DSE dse;
/** {@inheritDoc} */
@Override
public void createView(final Composite composite) {
ganttViewer = new GanttComposite(composite, SWT.NONE);
addSolutionSelectionComboLogic();
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
if(IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE() != null) {
dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
if(dse != null) {
updateSolutionSelectionCombo(dse);
}
......@@ -78,41 +75,19 @@ public final class GanttScheduleVisualization implements IVisualizationView, IEv
StructuredSelection selection = (StructuredSelection)event.getSelection();
Object selElem = selection.getFirstElement();
if(selElem instanceof SingleExplorationSolution) {
SuperSetMap superSets = createSuperSetMap();
SingleExplorationSolution solution = (SingleExplorationSolution)selElem;
SuperSet<ResourceAllocation> resAllocs =
solution.getSolutionModel(ResourceAllocation.class);
superSets.put(ResourceAllocation.class, resAllocs);
// Get the allocations from a joint exploration, or an earlier exploration.
SuperSet<TaskToExecutionUnitAllocationEntry> alloc =
solution.getSolutionModel(TaskToExecutionUnitAllocationEntry.class);
if(alloc == null) {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSetMap prevSuperSets = dse.getCurrentStep().getSuperSetMap();
alloc = prevSuperSets.get(TaskToExecutionUnitAllocationEntry.class);
}
TaskToExecutionUnitAllocationTable ta2hw =
createTasksToExecutionUnitAllocationTable("temp_allocs");
// We must use copy here since we don't want to modify containment relations.
ta2hw.getContainedElements().addAll(copy(alloc.getEntries()));
AllocationTableCollection atc = createAllocationTableCollection("temp_atc");
atc.getContainedElements().add(ta2hw);
// Possibly retrieves a superset of resource schedules from the solution containing
// information about frequency exploration
SuperSet<ResourceSchedule> resSchedules =
solution.getSolutionModel(ResourceSchedule.class);
if(resSchedules != null) {
superSets.put(ResourceSchedule.class, resSchedules);
}
DSESolutionArtifacts solArtifacts =
new DSESolutionArtifacts(superSets, asList(atc));
// Prepare inputs and perform the transformation.
ProcessStep currentStep = dse.getCurrentStep();
Collection<IProjectRootElement> inputModels = getRootElementsFromSnaps(currentStep,
(new ScheduleConverter()).getRequiredInputCopies());
DSESolutionArtifacts solArtifacts = new DSESolutionArtifacts(inputModels, solution);
solArtifacts = IDSESolutionExporterService.getInstance()
.transform(asList(ResourceAllocation.class), solArtifacts, "temp");
// Present the transformed schedule.
SystemSchedule solutionSchedule =
(new ScheduleConverter()).transform(resAllocs, solArtifacts, "temp_sched");
solArtifacts.getElementOrThrow(SystemSchedule.class);
ganttViewer.viewer.setSchedule(null, solutionSchedule.getScheduleList(),
solutionSchedule.getMajorFrame());
}
......@@ -166,6 +141,7 @@ public final class GanttScheduleVisualization implements IVisualizationView, IEv
if(!ganttViewer.isDisposed()) {
dispose();
}
dse = null;
}
}
}
DSEStaticImpl.java ceaf5ecf8c77609d4ae13d40b88ac443fe6b09e9 GREEN
InitialInputDefinitionStepStaticImpl.java 6d9951e848a64687f83d750557f6d6dcc5c04d54 GREEN
ModelSnapshotStaticImpl.java a03d2e1273cd5130359a1d757a03c477d92997f0 GREEN
ProcessStepStaticImpl.java 7f1121a3d6f3849ec84533576e689ed065b7843b YELLOW
ProcessStepStaticImpl.java 397bd5182d3bb608c5b9c991586a02971947386c YELLOW
SolutionSelectionStepStaticImpl.java f62112f9d033b45294155eb8f77edfd74a633b07 YELLOW
......@@ -21,7 +21,7 @@ import static org.fortiss.af3.exploration.util.ExplorationUtils.recursiveTreeWal
import static org.fortiss.tooling.kernel.utils.EcoreUtils.convertList;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.BiConsumer;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
......@@ -87,12 +87,11 @@ public class ProcessStepStaticImpl {
*/
public static <S extends IModelElement> SuperSetMap recursiveSuperSetMapWalk(
ProcessStep processStep, SuperSetMap aggregateSuperSets, boolean traverseSnaps) {
BiFunction<ProcessStep, SuperSetMap, SuperSetMap> mapSearch =
new BiFunction<ProcessStep, SuperSetMap, SuperSetMap>() {
BiConsumer<ProcessStep, SuperSetMap> mapSearch =
new BiConsumer<ProcessStep, SuperSetMap>() {
@SuppressWarnings("unchecked")
@Override
public SuperSetMap apply(ProcessStep processStep,
SuperSetMap collectedElements) {
public void accept(ProcessStep processStep, SuperSetMap collectedElements) {
if(processStep instanceof SolutionSelectionStep) {
SolutionSelectionStep solStep = (SolutionSelectionStep)processStep;
SingleExplorationSolution selectedSolution =
......@@ -131,27 +130,28 @@ public class ProcessStepStaticImpl {
}
}
}
return collectedElements;
}
};
return recursiveTreeWalk(processStep, mapSearch, aggregateSuperSets);
recursiveTreeWalk(processStep, mapSearch, aggregateSuperSets);
return aggregateSuperSets;
}
/** Static implementation of the method {@link ProcessStep#getTargets()}. */
public static EList<ExplorationTarget<?>> getTargets(ProcessStepImpl processStepImpl) {
BiFunction<ProcessStep, EList<ExplorationTarget<?>>, EList<ExplorationTarget<?>>> collectExpTargets =
new BiFunction<ProcessStep, EList<ExplorationTarget<?>>, EList<ExplorationTarget<?>>>() {
BiConsumer<ProcessStep, EList<ExplorationTarget<?>>> collectExpTargets =
new BiConsumer<ProcessStep, EList<ExplorationTarget<?>>>() {
@Override
public EList<ExplorationTarget<?>> apply(ProcessStep processStep,
public void accept(ProcessStep processStep,
EList<ExplorationTarget<?>> collectedElements) {
if(processStep instanceof TargetDefinitionStep) {
TargetDefinitionStep tgtStep = ((TargetDefinitionStep)processStep);
collectedElements.addAll(tgtStep.getDefinedTargets());
}
return collectedElements;
}
};
return recursiveTreeWalk(processStepImpl, collectExpTargets, new BasicEList<>());
EList<ExplorationTarget<?>> collectedTargets = new BasicEList<>();
recursiveTreeWalk(processStepImpl, collectExpTargets, collectedTargets);
return collectedTargets;
}
/**
......@@ -163,14 +163,14 @@ public class ProcessStepStaticImpl {
@SuppressWarnings("unchecked")
private static EList<IInputArtifact> aggregateLatestSnapshots(ProcessStepImpl processStepImpl) {
EList<ModelSnapshot> collectedSnapshots = new BasicEList<>();
BiFunction<IInputArtifact, EList<ModelSnapshot>, EList<ModelSnapshot>> getNonPresentSnapshots =
new BiFunction<IInputArtifact, EList<ModelSnapshot>, EList<ModelSnapshot>>() {
BiConsumer<IInputArtifact, EList<ModelSnapshot>> getNonPresentSnapshots =
new BiConsumer<IInputArtifact, EList<ModelSnapshot>>() {
@Override
public EList<ModelSnapshot> apply(IInputArtifact thisArtifact,
public void accept(IInputArtifact thisArtifact,
EList<ModelSnapshot> collectedSnapshots) {
if(!(thisArtifact instanceof ModelSnapshot)) {
// Just ignore non-ModelSnapshot artifacts
return collectedSnapshots;
return;
}
ModelSnapshot thisSnapshot = (ModelSnapshot)thisArtifact;
boolean snapShotPresent = false;
......@@ -182,16 +182,10 @@ public class ProcessStepStaticImpl {
if(!snapShotPresent) {
collectedSnapshots.add(thisSnapshot);
}
return collectedSnapshots;
}
};
// Sigh... Generics... This is not really unchecked since the ModelSnapshots are
// IInputArtifacts ==> Raw cast.
// We do not want <? extends IInputArtifact>, since this would complicate the handling
// elsewhere.
return (EList<IInputArtifact>)(EList<?>)recursiveArtifactWalk(processStepImpl,
getNonPresentSnapshots, collectedSnapshots);
recursiveArtifactWalk(processStepImpl, getNonPresentSnapshots, collectedSnapshots);
return (EList<IInputArtifact>)(EList<?>)collectedSnapshots;
}
/**
......@@ -224,19 +218,19 @@ public class ProcessStepStaticImpl {
/** Static implementation of {@link ProcessStep#getRuleSets()}. */
public static EList<RuleSet> getRuleSets(ProcessStepImpl processStepImpl) {
BiFunction<ProcessStep, EList<RuleSet>, EList<RuleSet>> collectExpTargets =
new BiFunction<ProcessStep, EList<RuleSet>, EList<RuleSet>>() {
BiConsumer<ProcessStep, EList<RuleSet>> collectExpTargets =
new BiConsumer<ProcessStep, EList<RuleSet>>() {
@Override
public EList<RuleSet> apply(ProcessStep processStep,
EList<RuleSet> collectedElements) {
public void accept(ProcessStep processStep, EList<RuleSet> collectedElements) {
if(processStep instanceof TargetDefinitionStep) {
TargetDefinitionStep tgtDefStep = ((TargetDefinitionStep)processStep);
collectedElements.addAll(tgtDefStep.getDefinedRuleSets());
}
return collectedElements;
}
};
return recursiveTreeWalk(processStepImpl, collectExpTargets, new BasicEList<>());
EList<RuleSet> collectedRuleSets = new BasicEList<>();
recursiveTreeWalk(processStepImpl, collectExpTargets, collectedRuleSets);
return collectedRuleSets;
}
/** Static implementation of {@link ProcessStep#getModelSnapshots()} */
......
DSESolutionVisualization.java f405ef1fbe8ce64f754ead646fa352fc405d2eda GREEN
IDSEBackend.java c66d2c151caf79fa2f99665bc75d61884e677eaa GREEN
IDSEBackendService.java 88c7ef5131025ef0e83e64ec26cdf3c2fa48abbe GREEN
IDSESolutionExporterService.java 439dca33402ed7a6b6cf4eb0f7bbcbc52ffaacba YELLOW
IDSESolutionExporterService.java 17797ddb10aa13a2ad45049d53c454175eb588b6 YELLOW
......@@ -66,11 +66,11 @@ public interface IDSESolutionExporterService {
IDSESolutionConverter<? extends IProjectRootElement, ? extends IModelElement> converter);
/**
* Transforms the given {@link SuperSet} into an {@link IModelElement} that can be used in an
* AF3 Project.
* Transforms the given {@code inputArtifacts} into an {@link DSESolutionArtifacts} of
* {@link IProjectRootElement}s that can be embedded in an AF3 {@link FileProject}.
*
* @param inputArtifacts
* List of artifact types to be transformed ba the service.
* List of artifact types to be transformed by the service.
* @param solSelStep
* Current step of the {@link DSE}. The method may only be called from a
* SolutionSelectionStep. It provides access to the {@link IInputArtifact}s if
......@@ -83,6 +83,25 @@ public interface IDSESolutionExporterService {
Collection<Class<? extends IModelElement>> inputArtifacts,
SolutionSelectionStep solSelStep, String baseName);
/**
* Transforms the given {@code inputArtifacts} into an {@link DSESolutionArtifacts} of
* {@link IProjectRootElement}s that can be embedded in an AF3 {@link FileProject}. Here, a
* pre-constructed {@link DSESolutionArtifacts} container holding the required input models for
* the transformation is required.
*
* @param inputArtifacts
* List of artifact types to be transformed by the service.
* @param solutionArtifacts
* Container with the required input models and solution artifacts as
* {@link SuperSet}s.
* @param baseName
* Name of a solution which is used as a prefix to denote each exported element.
* @return AF3 {@link IModelElement}.
*/
<O extends IProjectRootElement, I extends IModelElement> DSESolutionArtifacts transform(
Collection<Class<? extends IModelElement>> inputArtifacts,
DSESolutionArtifacts solutionArtifacts, String baseName);
/**
* IMPORTANT: This method may only be called after a previous transform call!
* Exports transformed model elements to the original AF3 {@link FileProject} that is
......
DSEBackendService.java 6af7d976cfa9d49875dc3183b034c958b14d167f GREEN
DSESolutionExporterService.java cf7c86c3325ccfa7bb13fd896ea13e483f953b47 YELLOW
DSESolutionExporterService.java e95a2cf64cfd02f1a046e28438bc4a431c3a9b8d YELLOW
......@@ -15,9 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.service.internal;
import static java.util.stream.Collectors.toList;
import static org.fortiss.af3.exploration.util.DSESolutionConversionUtils.throwConversionError;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copyToRefMap;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import java.util.ArrayList;
......@@ -29,15 +27,11 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ModelSnapshot;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.project.SolutionSelectionStep;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.model.solutions.SolutionsPackage;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
import org.fortiss.af3.exploration.solutionconverter.DSESolutionArtifacts;
import org.fortiss.af3.exploration.solutionconverter.DSESolutionConversionContext;
......@@ -101,11 +95,19 @@ public class DSESolutionExporterService
public <O extends IProjectRootElement, I extends IModelElement> DSESolutionArtifacts transform(
Collection<Class<? extends IModelElement>> inputArtifacts,
SolutionSelectionStep solSelStep, String baseName) {
Collection<INamedCommentedElement> inputModels =
Collection<IProjectRootElement> inputModels =
collectInputModels(inputArtifacts, solSelStep);
DSESolutionArtifacts solutionArtifacts =
createTransformationInput(inputModels, solSelStep.getSelectedSolution());
new DSESolutionArtifacts(inputModels, solSelStep.getSelectedSolution());
return transform(inputArtifacts, solutionArtifacts, baseName);
}
/** {@inheritDoc} */
@Override
public <O extends IProjectRootElement, I extends IModelElement> DSESolutionArtifacts transform(
Collection<Class<? extends IModelElement>> inputArtifacts,
DSESolutionArtifacts solutionArtifacts, String baseName) {
for(IDSESolutionConverter<?, ?> converter : converterList) {
Class<? extends IModelElement> artifactType = converter.getSourceClass();
if(isConverterApplicable(converter, inputArtifacts)) {
......@@ -125,11 +127,11 @@ public class DSESolutionExporterService
* Collects the {@link IProjectRootElement}s that are required as inputs for the
* {@link IDSESolutionConverter}s from the {@link ModelSnapshot}s.
*/
protected Set<INamedCommentedElement> collectInputModels(
protected Set<IProjectRootElement> collectInputModels(
Collection<Class<? extends IModelElement>> inputArtifacts,
SolutionSelectionStep solSelStep) {
// Key: input type; Value: whether the input type is optional
Map<Class<? extends INamedCommentedElement>, Boolean> relevantInputs = new HashMap<>();
Map<Class<? extends IProjectRootElement>, Boolean> relevantInputs = new HashMap<>();
for(IDSESolutionConverter<?, ?> converter : converterList) {
if(isConverterApplicable(converter, inputArtifacts)) {
converter.getRequiredInputCopies().forEach(i -> relevantInputs.put(i, false));
......@@ -142,10 +144,10 @@ public class DSESolutionExporterService
}
}
Set<INamedCommentedElement> inputModels = new HashSet<>();
for(Entry<Class<? extends INamedCommentedElement>, Boolean> input : relevantInputs
Set<IProjectRootElement> inputModels = new HashSet<>();
for(Entry<Class<? extends IProjectRootElement>, Boolean> input : relevantInputs
.entrySet()) {
INamedCommentedElement element = getRootElementFromSnapshot(solSelStep, input.getKey());
IProjectRootElement element = getRootElementFromSnapshot(solSelStep, input.getKey());
if(element != null) {
inputModels.add(element);
} else if(input.getValue() == false) {
......@@ -176,39 +178,6 @@ public class DSESolutionExporterService
return null;
}
/**
* Creates a {@link DSESolutionArtifacts} container that provides the inputs for the individual
* {@link IDSESolutionConverter}s. For its construction, the relevant inputs are copied such
* that all cross-references are updated.
*
* @param inputModels
* Set of {@link IProjectRootElement}s that form the core of the snapshot models that
* are the basis for the solution sets produced by the DSE.
* @param expSol
* {@link SingleExplorationSolution} carrying the {@link SuperSetMap} of the relevant
* solutions and the contained elements of the solution sets.
* @return {@link DSESolutionArtifacts} of the transformation inputs.
*/
protected DSESolutionArtifacts createTransformationInput(
Collection<INamedCommentedElement> inputModels, SingleExplorationSolution expSol) {
Set<EObject> artifactsToCopy = new HashSet<>(inputModels.size() + 1);
// We copy the complete SingleExplorationSolution, since it contains the SuperSetMap
// (result) and has a containment list of the elements referenced from SuperSets. This way,
// we do not need to care about correct cross-references between the elements of SuperSets.
artifactsToCopy.add(expSol);
artifactsToCopy.addAll(inputModels);
Map<EObject, EObject> copiedArtifacts = copyToRefMap(artifactsToCopy);
SuperSetMap origSolutionMap = (SuperSetMap)expSol
.eGet(SolutionsPackage.eINSTANCE.getSingleExplorationSolution_SolutionSets());
SuperSetMap copiedSolutionMap = (SuperSetMap)copiedArtifacts.get(origSolutionMap);
Collection<IProjectRootElement> copiedInputModels = inputModels.stream()
.map(i -> (IProjectRootElement)copiedArtifacts.get(i)).collect(toList());
return new DSESolutionArtifacts(copiedSolutionMap, copiedInputModels);
}
/** {@inheritDoc} */
@Override
public <O extends IProjectRootElement, I extends IModelElement> void exportToAF3Project(
......
DSESolutionArtifacts.java 786585611e8c76f93bb8a7be1fa8e6f4cebd321b YELLOW
DSESolutionArtifacts.java 85584fe235366abad2652f985996e1fa0d560d23 YELLOW
DSESolutionConversionContext.java d16e052e6c3b56b7e2ae21ffec97bd41df1d3d4d YELLOW
DSESolutionConverterBase.java ddfd79b2535b7242b39c331ba8a12ccc36155677 YELLOW
IDSESolutionConverter.java 4c3f3555b98c19d0642797a28de1d9bdd113ab5a YELLOW
RouteConverter.java b63f6c096b3c33595ff3d6225e294b894208b07e YELLOW
ScheduleConverter.java d9d5d86b56fc7dd5fa518c9d8a5ef477bac6b90a RED
SignalToRouteConverter.java 1ff7b1028d62be16b1778b1f207cf91698f461a5 RED
ScheduleConverter.java f2d1d0b9bd99e81f70155f99d5c0034ce922d964 YELLOW
SignalToRouteConverter.java 0aac4963f9ae0f24814ccfb510a02c4ea84e1443 YELLOW
TaskToExecUnitConverter.java 2566b87947007df54a4cc96f71f066a944629d23 YELLOW
......@@ -17,19 +17,28 @@ package org.fortiss.af3.exploration.solutionconverter;
import static java.util.stream.Collectors.toMap;
import static org.fortiss.af3.exploration.util.DSESolutionConversionUtils.throwConversionError;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copyToRefMap;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getInterfaceType;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.model.solutions.SolutionsPackage;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
/**
* Container for the artifacts that are in- and outputs to the Solution Conversion service
* ({@link IDSESolutionExporterService}). Also, it holds the artifacts generated by the DSE and also
* provides to the service.
*
* @author diewald
*/
......@@ -43,12 +52,23 @@ public class DSESolutionArtifacts {
/** Constructor. */
@SuppressWarnings("unchecked")
public DSESolutionArtifacts(SuperSetMap solutionMapCopy,
Collection<IProjectRootElement> inputModelCopies) {
this.solutionMap = solutionMapCopy;
this.inOutArtifacts = inputModelCopies.stream()
public DSESolutionArtifacts(Collection<IProjectRootElement> inputModels,
SingleExplorationSolution expSol) {
Set<EObject> artifactsToCopy = new HashSet<>(inputModels.size() + 1);
// We copy the complete SingleExplorationSolution, since it contains the SuperSetMap
// (result) and has a containment list of the elements referenced from SuperSets. This way,
// we do not need to care about correct cross-references between the elements of SuperSets.
artifactsToCopy.add(expSol);
artifactsToCopy.addAll(inputModels);
Map<EObject, EObject> copiedArtifacts = copyToRefMap(artifactsToCopy);
SuperSetMap origSolutionMap = (SuperSetMap)expSol
.eGet(SolutionsPackage.eINSTANCE.getSingleExplorationSolution_SolutionSets());
this.solutionMap = (SuperSetMap)copiedArtifacts.get(origSolutionMap);
this.inOutArtifacts = inputModels.stream()
.collect(toMap(i -> (Class<? extends IProjectRootElement>)getInterfaceType(i),
Function.identity()));
i -> (IProjectRootElement)copiedArtifacts.get(i)));
}
/**
......
......@@ -136,7 +136,6 @@ public class ScheduleConverter
resSched = createResourceSchedule(allocResource, "Sched_" + resName);
sysSched.getContainedElements().add(resSched);
// TODO(AD): Needed?
// Possibly adds to the system schedule information about the frequencies.
SuperSet<ResourceSchedule> freqSchedules =
solArtifacts.getSuperSetOrThrow(ResourceSchedule.class);
......
......@@ -54,32 +54,6 @@ public class SignalToRouteConverter
TaskToExecutionUnitAllocationTable ta2pa =
atc.getAllocationTable(TaskToExecutionUnitAllocationTable.class);
// // If no task-to-ECU allocation entries have been exported (e.g. due to a pure scheduling
// // run), a new allocation table for the signal-to-route entries is created by copying the
// // respective model snapshot.
// if(filterByType(prevResults, TaskToExecutionUnitAllocationTable.class).isEmpty()) {
// ta2pa = copy(ta2pa, copyRefMap);
//
// @SuppressWarnings("unchecked") Optional<PlatformArchitecture> convPA =
// (Optional<PlatformArchitecture>)getFirst(prevResults,
// r -> r instanceof PlatformArchitecture);
// if(convPA.isPresent()) {
// ta2pa.setTargetView(convPA.get());
// for(TaskToExecutionUnitAllocationEntry entry : ta2pa
// .getAllocationEntries(TaskToExecutionUnitAllocationEntry.class)) {
// ExecutionUnit copyExecUnit =
// (ExecutionUnit)copyRefMap.get(entry.getExecutionUnit());
// entry.setTargetElement(copyExecUnit);
// }
// for(TaskPortToTransceiverAllocationEntry entry : ta2pa
// .getAllocationEntries(TaskPortToTransceiverAllocationEntry.class)) {
// IModelElement copyElement =
// (IModelElement)copyRefMap.get(entry.getTargetElement());
// entry.setTargetElement(copyElement);
// }
// }
// }
final TaskToExecutionUnitAllocationTable ta2paFin = ta2pa;
for(SignalToRouteAllocationEntry entry : fromSuperSet.getEntries()) {
// Route (as part of PA) has been copied in RouteConverter: Dereference in map
......
......@@ -4,6 +4,6 @@ DSMLModelElementFactory.java 24b8cf9c900e948dcc71eb2a7fa26232baa6f7a5 GREEN
DSMLUtils.java c07eeef09787cea9db98533d346e3e384a232593 GREEN
ExplorationModelElementFactory.java bb48b2d09b92efcb1b2d3e382555089bb7ed5db5 GREEN
ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN
ExplorationUtils.java 3e317c851bd1a0b48fbec3fdbe039d8b66506c51 GREEN
ExplorationUtils.java cd48d4910a1a6668d8c39cbd93c220e1b87bdef4 YELLOW
ModelSnapshotExtractUtils.java dde8b42c5a7228478ffe8c67820bcac91e875562 GREEN
PatternFactoryUtils.java bcb1d325aecfef12d29d4eb53b28fe59dbd20e9a GREEN