Commit ede784ad authored by Simon Barner's avatar Simon Barner

Merge branch '4078' into 'master'

DSE Sol-Transformation/Validation : Fixup Object References

See merge request !382
parents c134d828 a87897c5
DeploymentValidatorStartMenu.java 7e3fe8187d99934f939cc99ba81392566b27e05d GREEN
DeploymentValidatorStartMenu.java 618ac88c731985550ded887625f326572c8971b6 GREEN
......@@ -15,7 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.menu;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showWarning;
......@@ -109,7 +108,8 @@ public class DeploymentValidatorStartMenu implements IContextMenuContributor {
}
ExplorationExpressionDeploymentValidator validator =
new ExplorationExpressionDeploymentValidator(ta2hw, asList(selRuleSet));
new ExplorationExpressionDeploymentValidator(ta2hw,
selRuleSet.getExplorationTargets());
Boolean validationPassed = false;
try {
......
ExecuteDSECommandLineHandler.java 7955b0bf22da3f4c4b72b441d201cf60d71ae6b6 GREEN
TestCaseGenerationCommandLineHandler.java 8df52cceacf8e873d612643e6b0ba50202b97c71 GREEN
ValidateDSESolutionCommandLineInterface.java 1b882428463c21c355d96c883af428d3fa4cce2d GREEN
ValidateDSESolutionCommandLineInterface.java 40196b64bf3d90cd12ede84ae186304ae1b84992 GREEN
......@@ -27,12 +27,14 @@ import static org.fortiss.tooling.kernel.utils.LoggingUtils.info;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.lang.ExplorationExpressionDeploymentValidator;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ExplorationStep;
import org.fortiss.af3.exploration.model.project.ModelSnapshot;
......@@ -152,9 +154,11 @@ public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwit
solStep.getSolutionSuperSetMap().get(TaskToExecutionUnitAllocationEntry.class);
if(allocationSet != null) {
ExplorationStep expStep = (ExplorationStep)solStep.eContainer();
List<IExplorationTarget<?>> appliedTargets = expStep.getUsedRuleSets().stream()
.flatMap(rS -> rS.getExplorationTargets().stream()).collect(toList());
ExplorationExpressionDeploymentValidator validator =
new ExplorationExpressionDeploymentValidator(allocationSet.getEntries(),
expStep.getRuleSets());
appliedTargets);
return validator.validate();
}
......@@ -168,10 +172,13 @@ public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwit
private boolean validateTransformedSolution(SolutionSelectionStep solStep,
Set<Class<? extends ISynthesisCategory>> synthTypes,
SingleExplorationSolution singleSolution) throws Exception {
ExplorationStep expStep = (ExplorationStep)solStep.eContainer();
List<IExplorationTarget<?>> appliedTargets = expStep.getUsedRuleSets().stream()
.flatMap(rS -> rS.getExplorationTargets().stream()).collect(toList());
Collection<IProjectRootElement> rootInputElements = solStep.getInputArtifacts().stream()
.map(i -> ((ModelSnapshot)i).getRootElement()).collect(toList());
DSESolutionArtifacts solAritfacts =
new DSESolutionArtifacts(rootInputElements, asList(singleSolution));
new DSESolutionArtifacts(rootInputElements, asList(singleSolution), appliedTargets);
solAritfacts = dseExportService.transform(singleSolution.getAvailableSolutionModels(),
solAritfacts, "CLI solution");
......@@ -182,10 +189,9 @@ public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwit
TaskToExecutionUnitAllocationTable outArtifact = outArtifactContainer
.getAllocationTable(TaskToExecutionUnitAllocationTable.class);
ExplorationStep expStep = (ExplorationStep)solStep.eContainer();
ExplorationExpressionDeploymentValidator validator =
new ExplorationExpressionDeploymentValidator(outArtifact,
expStep.getUsedRuleSets());
solAritfacts.getAppliedTargets());
return validator.validate();
}
......
ExplorationExpressionDeploymentValidator.java 9f2b3e3fc412c70ee4909e8b1ef1e23eaf744e48 GREEN
ExplorationExpressionDeploymentValidator.java 7a38992407efd970f066a8c740935d7fd5778006 GREEN
ExplorationExpressionEvaluator.java 276ed06e2af609e79fb990acfa1d1bc6ed977b28 GREEN
ExpressionVisitorBase.java d3b60238c6685e05f9c75980d1869bd1f0af4132 GREEN
Function.java 9f4dc40006029d2ae58b62936893c2cd0de7e172 GREEN
......
......@@ -15,7 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.lang;
import static java.util.stream.Collectors.toList;
import static org.fortiss.tooling.common.util.LambdaUtils.filterByType;
import java.util.Collection;
......@@ -36,7 +35,6 @@ import org.fortiss.af3.exploration.dseml.model.function.StronglyCausal;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationEntry;
......@@ -56,7 +54,7 @@ public class ExplorationExpressionDeploymentValidator extends ExplorationExpress
* {@link IExplorationConstraint}s against which the {@link TaskToExecutionUnitAllocationTable}
* will be evaluated.
*/
private Collection<RuleSet> ruleSets;
private Collection<IExplorationTarget<?>> appliedTargets;
/** Reference to the {@link TaskToExecutionUnitAllocationTable} to validate. */
private TaskToExecutionUnitAllocationTable ta2hw;
......@@ -69,13 +67,13 @@ public class ExplorationExpressionDeploymentValidator extends ExplorationExpress
*
* @param ta2hw
* {@link TaskToExecutionUnitAllocationTable} to validate.
* @param ruleSets
* @param appliedTargets
* Defines the constraints on the given {@link TaskToExecutionUnitAllocationTable}.
*/
public ExplorationExpressionDeploymentValidator(TaskToExecutionUnitAllocationTable ta2hw,
Collection<RuleSet> ruleSets) {
Collection<IExplorationTarget<?>> appliedTargets) {
this.ta2hw = ta2hw;
this.ruleSets = ruleSets;
this.appliedTargets = appliedTargets;
}
/**
......@@ -83,14 +81,14 @@ public class ExplorationExpressionDeploymentValidator extends ExplorationExpress
*
* @param ta2hwEntries
* {@link TaskToExecutionUnitAllocationTable} to validate.
* @param ruleSets
* @param appliedTargets
* Defines the constraints on the given {@link TaskToExecutionUnitAllocationTable}.
*/
public ExplorationExpressionDeploymentValidator(
Collection<TaskToExecutionUnitAllocationEntry> ta2hwEntries,
Collection<RuleSet> ruleSets) {
Collection<IExplorationTarget<?>> appliedTargets) {
this.ta2hwEntries = ta2hwEntries;
this.ruleSets = ruleSets;
this.appliedTargets = appliedTargets;
}
/**
......@@ -100,10 +98,8 @@ public class ExplorationExpressionDeploymentValidator extends ExplorationExpress
public Boolean validate() throws Exception {
boolean validationResult = true;
Collection<IExplorationTarget<?>> targets = ruleSets.stream()
.flatMap(rS -> rS.getExplorationTargets().stream()).collect(toList());
Queue<IExplorationConstraint<?>> constraintSet =
new LinkedList<>(filterByType(targets, IExplorationConstraint.class));
new LinkedList<>(filterByType(appliedTargets, IExplorationConstraint.class));
while(!constraintSet.isEmpty()) {
IExplorationTarget<?> constraint = constraintSet.poll();
if(((IExplorationConstraint<?>)constraint).getExpression() == null) {
......
DSESolutionArtifacts.java 90cde5439502de8dc8eac7014e654999279569fa GREEN
DSESolutionArtifacts.java f4cec8f90c58ee40c20d7600a22fa01a5acd9178 GREEN
DSESolutionConversionContext.java d16e052e6c3b56b7e2ae21ffec97bd41df1d3d4d GREEN
DSESolutionConverterBase.java a45df8907205ea4549cf34aea91a96287613fb59 GREEN
IDSESolutionConverter.java 4c3f3555b98c19d0642797a28de1d9bdd113ab5a GREEN
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.solutionconverter;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static org.fortiss.af3.exploration.util.DSESolutionConversionUtils.throwConversionError;
......@@ -32,6 +33,7 @@ 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.IExplorationTarget;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
......@@ -53,10 +55,18 @@ public class DSESolutionArtifacts {
/** Holder for all input and transformed artifacts. */
private Map<Class<? extends IProjectRootElement>, IProjectRootElement> inOutArtifacts;
/**
* Holds the {@link IExplorationTarget}s that were used to generate the input artifact. Their
* object references point to element copies contained in this {@link DSESolutionArtifacts}
* container.
*/
private Collection<IExplorationTarget<?>> appliedTargets;
/** Constructor. */
@SuppressWarnings("unchecked")
public DSESolutionArtifacts(Collection<IProjectRootElement> inputModels,
List<SingleExplorationSolution> selSolutions) {
List<SingleExplorationSolution> selSolutions,
Collection<IExplorationTarget<?>> expTargets) {
Set<EObject> artifactsToCopy = new HashSet<>(inputModels.size() + 1);
// We copy the complete SingleExplorationSolution, since it contains the SuperSetMap
......@@ -64,6 +74,7 @@ public class DSESolutionArtifacts {
// we do not need to care about correct cross-references between the elements of SuperSets.
artifactsToCopy.addAll(selSolutions);
artifactsToCopy.addAll(inputModels);
artifactsToCopy.addAll(expTargets);
Map<EObject, EObject> copiedArtifacts = copyToRefMap(artifactsToCopy);
......@@ -79,6 +90,14 @@ public class DSESolutionArtifacts {
this.inOutArtifacts = inputModels.stream()
.collect(toMap(i -> (Class<? extends IProjectRootElement>)getInterfaceType(i),
i -> (IProjectRootElement)copiedArtifacts.get(i)));
this.appliedTargets = expTargets.stream()
.map(eT -> (IExplorationTarget<?>)copiedArtifacts.get(eT)).collect(toList());
}
/** Constructor. */
public DSESolutionArtifacts(Collection<IProjectRootElement> inputModels,
List<SingleExplorationSolution> selSolutions) {
this(inputModels, selSolutions, emptyList());
}
/**
......@@ -147,6 +166,15 @@ public class DSESolutionArtifacts {
return inOutArtifacts.entrySet();
}
/**
* Returns the {@link IExplorationTarget}s that were applied to generate input artifacts. The
* returned {@link IExplorationTarget}s are applicable to the elements contained in this
* {@link DSESolutionArtifacts}.
*/
public Collection<IExplorationTarget<?>> getAppliedTargets() {
return appliedTargets;
}
/**
* Returns the name of the failing converter. May only be called in the context of this utility
* class.
......
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