Commit 0eeed4a3 authored by Alexander Diewald's avatar Alexander Diewald

Exploration(.*): Introduce typeParameter fields for Sets and ExplorationTargets.

* Change the MM accordingly.
* Introduce static helper methods to implement the getters/setters of the affected maps: Runtime exceptions are thrown on mismatching types.
* Add a migrator to set the DSESuperSet types of old models.
* Adjust the factory methods.
refs 3289
parent 1618343d
......@@ -21,7 +21,7 @@
</eAnnotations>
</eStructuralFeatures>
<eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationObjective">
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/>
</eGenericSuperTypes>
<eGenericSuperTypes eClassifier="#//CustomDimension"/>
</eClassifiers>
......
DSLtoSMT.java e12ce3bb3403de23b22070b2072e5e9979b2167e RED
ScheduleRun.java c07040dcdc506c2b9c82e4ed9ca559f9478b1f3b RED
ScheduleRun.java 536036bf20d42e72ef6842c94ff66a932a7f56a3 RED
SolverRun.java dc28d21b774cdf0b44a4b0ea760417605554c37d RED
BasicDeploymentConstraint.java 20b61cba24661109cbffb2548042f54ae4c3d7e0 RED
ConstraintToNONQuantifiedSMT.java 99f852223c25442c395ff888cabbcc3b18694a5a RED
ConstraintToQuantifiedSMT.java 9cbb27b1ac997015a642a652351c96ec726a35d5 RED
DeploymentRun2.java 1e097286ea15d33b5349a297935d30700f1ce7db RED
DeploymentRun2.java 94039014c1832101b603478325b027da80be9218 RED
ITransformationService.java fcddb7beb90eb693983babba30728d4600c15fc6 RED
LanguageTransformation.java 8354240819f62669b590dfc54fbc26ea8595e2c8 RED
SMTTransformationUtils.java c7a344d8141974b01dbcd6f9b89f8c4a4af668db RED
SolverRun2.java 877e3a5e04b8bcc0df20857d9fa447c3105ce480 RED
SolverRun2.java 401e6d8dc6193d87c8d82228e6336aeaeffbdc33 RED
TransformationService.java 1dd5542305402ee2f0e28fd25350265251ad801f RED
......@@ -131,7 +131,8 @@ public class DeploymentRun2 extends SolverRun2 {
ComponentToExecutionUnitAllocationTable alloc =
modelAllocTableAssoc.get(entry.getKey());
SingleExplorationSolution singleSolution = createSingleExplorationSolution();
SuperSet<ComponentToTaskAllocationEntry> allocSet = createSuperSet("Allocations");
SuperSet<ComponentToTaskAllocationEntry> allocSet =
createSuperSet("Allocations", ComponentToTaskAllocationEntry.class);
allocSet.getEntries()
.addAll(alloc.getAllocationEntries(ComponentToTaskAllocationEntry.class));
singleSolution.putSolutionModel(ComponentToTaskAllocationEntry.class, allocSet);
......
......@@ -36,8 +36,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
......@@ -53,7 +51,6 @@ import org.fortiss.af3.exploration.smt.AF3ExplorationSMTActivator;
import org.fortiss.af3.exploration.smt.model.SMTConstraint;
import org.fortiss.af3.exploration.smt.model.SMTObjective;
import org.fortiss.af3.exploration.util.DesignSpaceExplorationModelElementFactory;
import org.fortiss.af3.exploration.util.ExplorationUtils;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
import com.microsoft.z3.ArithExpr;
......@@ -289,21 +286,21 @@ public abstract class SolverRun2 {
// FIXME: Specifying the SMTObjective as an ExplorationObjective of the type Boolean
// is a misuse of the concept. The type of ExplorationTargets specifies the expected
// return value.
if(!ExplorationUtils.getReturnTypeOf(entry.getValue()).equals(Integer.class)) {
if(!entry.getValue().getResultType().equals(Double.class)) {
LoggingUtils.error(AF3ExplorationSMTActivator.getDefault(),
"Could not transform " + z3EvalResult + " into integer value. Not" +
"Could not transform " + z3EvalResult + " into double value. Not" +
" supported.");
continue;
}
ExplorationResult<Integer> result = createExplorationResult();
ExplorationResult<Double> result = createExplorationResult();
if(z3EvalResult instanceof IntNum) {
result.setResult(((IntNum)z3EvalResult).getInt());
result.setResult(Double.valueOf(((IntNum)z3EvalResult).getInt()));
} else if(z3EvalResult instanceof RatNum) {
RatNum ratnum = (RatNum)z3EvalResult;
IntNum denominator = ratnum.getDenominator();
IntNum numerator = ratnum.getNumerator();
if(denominator.getInt() == 1) {
result.setResult(numerator.getInt());
result.setResult(Double.valueOf(numerator.getInt()));
} else {
// not supported yet
LoggingUtils.error(AF3ExplorationSMTActivator.getDefault(),
......@@ -316,9 +313,6 @@ public abstract class SolverRun2 {
} catch(Z3Exception e) {
// TODO(AD): Use LoggingUtils from the kernel/base.
e.printStackTrace();
} catch(InvalidTargetObjectTypeException e) {
LoggingUtils.error(AF3ExplorationSMTActivator.getDefault(),
"Could not determine the result type of an objective.", e);
}
}
}
DashboardWizard.java 12347eabc51ee751395117904ecac42cf6e89f50 RED
DashboardWizard.java 7061851d640bb190099f901765aa1f7f2a4a26b2 RED
DashboardWizardSelectLA.java 28fc4820cc53dfae5ebc14e48e8a5804cd14da25 RED
DashboardWizardSelectProjectSource.java 4aced80f395b72b86a37213bde1c2cd5298d3911 RED
DashboardWizardSelectTA.java 524c82afa4262a6cdffbc58985206a63df05a0ec RED
DeploymentSynthesisViewBackend.java c46b90000000d2be57f846d330339243abbda894 RED
DeploymentSynthesisViewBackend.java bf26beb00e006ba6c59b686ef2b1306c6931ff01 RED
ExplorationSynthesisView.java b4b02d2727254cbd0636b79fdf3e1b61c3cb1318 RED
PlatformSynthesisViewBackend.java 5fe5715872810a72030aea1f1db65e73bd06d5a6 RED
ScheduleSynthesisViewBackend.java 2553687b90aa211979782cf0fca37792c93baacd RED
......@@ -119,7 +119,16 @@ public class DeploymentSynthesisViewBackend extends DeploymentSynthesisViewGUI {
expSpec.getTargets().addAll(convertRuleSetsToExplorationSpec(ruleSets));
DSESuperSets dseSuperSets =
IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE().getDseSuperSet();
SuperSetMap superSets = ExplorationUtils.convertToMap(dseSuperSets);
SuperSetMap superSets;
try {
superSets = ExplorationUtils.convertToMap(dseSuperSets);
} catch(Exception ex) {
Display.getDefault().syncExec(() -> MessageDialog.openError(new Shell(),
"SuperSet conversion error.",
"Failed to convert the DSE perspectives' Supersets to SuperSets to " +
"be passed to the DSE."));
return;
}
expSpec.setSearchSpace(superSets);
DseBackendHandler.getInstance().setExplorationSpec(expSpec);
DseBackendHandler.getInstance().setRequiredSolutions(solModels);
......@@ -228,7 +237,9 @@ public class DeploymentSynthesisViewBackend extends DeploymentSynthesisViewGUI {
}
/** Updates the basic deployment constraint. (every component is mapped to one ecu). */
/**
* Updates the basic deployment constraint. (every component is mapped to one ecu).
*/
private void updateBasicDeploymentConstraint() {
DSEPlatformArtifact platform = IDSEPerspectiveManager.INSTANCE.getPArchitectureInScope();
TaskArchitecture taskArchitecture =
......@@ -238,9 +249,18 @@ public class DeploymentSynthesisViewBackend extends DeploymentSynthesisViewGUI {
EList<Signal> signals = taskArchitecture.getSignals();
List<IConnection> connections = new ArrayList<>();
connections.addAll(signals);
List<SMTConstraint> createBasicSignalConstraint =
BasicDeploymentConstraint.createBasicSignalConstraint(connections, platform,
ExplorationUtils.convertToMap(dse.getDseSuperSet()));
List<SMTConstraint> createBasicSignalConstraint;
try {
createBasicSignalConstraint = BasicDeploymentConstraint.createBasicSignalConstraint(
connections, platform, ExplorationUtils.convertToMap(dse.getDseSuperSet()));
} catch(Exception e1) {
Display.getDefault()
.syncExec(() -> MessageDialog.openError(new Shell(),
"SuperSet conversion error.",
"Failed to convert the DSE perspectives' Supersets to SuperSets to " +
"be passed to the DSE."));
return;
}
subSet.getExplorationTargets().addAll(createBasicSignalConstraint);
subSet.setImplicit(true);
......
......@@ -2,7 +2,7 @@ ComponentContentProvider.java 7e99c789a787f525f66861ec97800ceccb92cd6d RED
DSEContentProviderBase.java 9743f1bd6b9fd6f22b2eb09ac7e604066ba5f4f5 RED
DSETreeContentProvider.java 043caab50784f68289c86fbca0cd54aa59f27bdd RED
DSLPatternArchitectureContentProvider.java 3a35cbb27d2df9073bc0b64aadaf0e970fd17b69 RED
ExplorationSolutionVisualizationUtils.java c332b2d236e839af5b39b2426d4fd0bfecd42a9d RED
ExplorationSolutionVisualizationUtils.java 4043131b13b869011e78cd8de747f52651d599e7 YELLOW
ExplorationUiUtil.java 47b186e43dae59afebd2f60c14254c46e2bebcee RED
PerspectiveUtils.java bd9fa331633d59b8a09b290c2ffa01bb07d910f9 RED
SpiderChartUtils.java 8e03188636d69cef87a48bff14fa518dbfc7ac16 RED
......@@ -15,7 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.util;
import static org.fortiss.af3.exploration.util.ExplorationUtils.getReturnTypeOf;
import static org.fortiss.tooling.base.utils.VisualizationModelElementFactory.createAxis;
import static org.fortiss.tooling.base.utils.VisualizationModelElementFactory.createDataSet;
import static org.fortiss.tooling.base.utils.VisualizationModelElementFactory.createDataSetCollection;
......@@ -131,8 +130,6 @@ public class ExplorationSolutionVisualizationUtils {
for(ExplorationObjective<?> expObjective : filterTypeSafe(expSolution.keySet(),
ExplorationObjective.class)) {
ExplorationObjective<T> castedObjective = (ExplorationObjective<T>)expObjective;
// Throws an exception if the return type is unexpected / non-matching.
getReturnTypeOf(castedObjective);
// TODO(#2942): Consider Problem Dimensions also in the transformation to visualization
// data. Here, we construct a Problem Dimension per Objective.
Dimension<T> dim = VisualizationModelElementFactory
......
......@@ -581,21 +581,42 @@
</eAnnotations>
<eParameters name="other" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
</eOperations>
<eOperations name="getElementType" lowerBound="1">
<eOperations name="getEntryType" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return org.fortiss.af3.exploration.model.expression.impl.ExpressionStaticImpl.getElementType(this);"/>
<details key="documentation" value="Returns the type that is expected from an evaluation result of this {@link ExplorationTarget}."/>
<details key="body" value="if(entryTypeInternal != null) {&#xD;&#xA; return entryTypeInternal;&#xD;&#xA;}&#xD;&#xA;&#xD;&#xA;return org.fortiss.af3.exploration.util.ExplorationReflectionUtils.getSubstitutionTypeOfGenericIface(this, Set.class, entryTypeInternal);"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//expression/Set/T"/>
</eGenericType>
</eOperations>
<eOperations name="setEntryType" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Sets the type that is expected from an evaluation result of this {@link ExplorationTarget}. NOTE: the type can be only set once."/>
<details key="body" value="if(type != null) {&#xD;&#xA; entryTypeInternal = type;&#xD;&#xA;}"/>
</eAnnotations>
<eParameters name="type" lowerBound="1">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//expression/Set/T"/>
</eGenericType>
</eParameters>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="entryTypeInternal">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="suppressedGetVisibility" value="true"/>
<details key="suppressedSetVisibility" value="true"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//expression/Set/T"/>
</eGenericType>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="entries" upperBound="-1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="TODO: write documentation (in the model!)"/>
</eAnnotations>
<eGenericType eTypeParameter="#//expression/Set/T"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="superSetReference">
<eStructuralFeatures xsi:type="ecore:EReference" name="superSetReference" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="TODO: write documentation (in the model!)"/>
</eAnnotations>
......
......@@ -252,6 +252,7 @@
</genClasses>
<genClasses ecoreClass="dsl_v2.ecore#//expression/Set">
<genTypeParameters ecoreTypeParameter="dsl_v2.ecore#//expression/Set/T"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute dsl_v2.ecore#//expression/Set/entryTypeInternal"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference dsl_v2.ecore#//expression/Set/entries"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
......@@ -260,7 +261,10 @@
<genOperations ecoreOperation="dsl_v2.ecore#//expression/Set/equals">
<genParameters ecoreParameter="dsl_v2.ecore#//expression/Set/equals/other"/>
</genOperations>
<genOperations ecoreOperation="dsl_v2.ecore#//expression/Set/getElementType"/>
<genOperations ecoreOperation="dsl_v2.ecore#//expression/Set/getEntryType"/>
<genOperations ecoreOperation="dsl_v2.ecore#//expression/Set/setEntryType">
<genParameters ecoreParameter="dsl_v2.ecore#//expression/Set/setEntryType/type"/>
</genOperations>
</genClasses>
<genClasses ecoreClass="dsl_v2.ecore#//expression/SuperSet">
<genTypeParameters ecoreTypeParameter="dsl_v2.ecore#//expression/SuperSet/T"/>
......
......@@ -32,6 +32,26 @@
<details key="documentation" value="Interface to define targets that are to be considered by a DSE process, e.g., objectives and constraints."/>
</eAnnotations>
<eTypeParameters name="T"/>
<eOperations name="getResultType" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the type that is expected from an evaluation result of this {@link ExplorationTarget}."/>
<details key="body" value="if(resultTypeInternal != null) {&#xD;&#xA; return resultTypeInternal;&#xD;&#xA;}&#xD;&#xA;&#xD;&#xA;return org.fortiss.af3.exploration.util.ExplorationReflectionUtils.getSubstitutionTypeOfGenericIface(this, ExplorationTarget.class, resultTypeInternal);"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//ExplorationTarget/T"/>
</eGenericType>
</eOperations>
<eOperations name="setResultType" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Sets the type that is expected from an evaluation result of this {@link ExplorationTarget}."/>
<details key="body" value="if(type != null) {&#xD;&#xA; resultTypeInternal = type;&#xD;&#xA;}"/>
</eAnnotations>
<eParameters name="type" lowerBound="1">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//ExplorationTarget/T"/>
</eGenericType>
</eParameters>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="expression" eType="ecore:EClass dsl_v2.ecore#//expression/IExpression"
containment="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
......@@ -44,6 +64,15 @@
<eTypeArguments eTypeParameter="#//ExplorationTarget/T"/>
</eGenericType>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="resultTypeInternal">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="suppressedGetVisibility" value="true"/>
<details key="suppressedSetVisibility" value="true"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//ExplorationTarget/T"/>
</eGenericType>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ExplorationObjective" abstract="true"
interface="true">
......@@ -112,7 +141,7 @@
<eOperations name="get" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Mirrors the standard {@link java.util.Map#get} method, except that the Types of the key ({@link Class}) and the returned value ({@link SuperSet}) will match."/>
<details key="body" value="return (SuperSet&lt;T>)superSetMap.get(key);"/>
<details key="body" value="return SuperSetMapStaticImpl.get(this, key);"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EClass dsl_v2.ecore#//expression/SuperSet">
<eTypeArguments eTypeParameter="#//SuperSetMap/get/T"/>
......@@ -191,6 +220,8 @@
upperBound="-1" eType="#//EJavaClassToSuperSetMap" containment="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Allows to optionally attach calculated solution models to a single solution. They are identified by their type."/>
<details key="suppressedGetVisibility" value="true"/>
<details key="suppressedSetVisibility" value="true"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
......@@ -280,7 +311,7 @@
<eOperations name="get" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Mirrors the standard {@link java.util.Map#get} method, except that the Types of the key ({@link ExplorationTarget}) and the returned value ({@link ExplorationValue}) will match."/>
<details key="body" value="return (ExplorationResult&lt;T>)solutionMap.get(key);"/>
<details key="body" value="return SingleExplorationSolutionStaticImpl.get(this, key);"/>
</eAnnotations>
<eGenericType eClassifier="#//solutions/ExplorationResult">
<eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolution/get/T"/>
......@@ -306,7 +337,7 @@
<eOperations name="put" lowerBound="1">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Mirrors the standard {@link java.util.Map#get} method, except that the Types of the key ({@link ExplorationTarget}) and the returned value ({@link ExplorationValue}) must match."/>
<details key="body" value="return (ExplorationResult&lt;T>)solutionMap.put(key, value);"/>
<details key="body" value="return SingleExplorationSolutionStaticImpl.put(this, key, value);"/>
</eAnnotations>
<eGenericType eClassifier="#//solutions/ExplorationResult">
<eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolution/put/T"/>
......@@ -392,6 +423,8 @@
containment="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="EMF-implementation of the backend map."/>
<details key="suppressedGetVisibility" value="true"/>
<details key="suppressedSetVisibility" value="true"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="solutionSets" lowerBound="1"
......
......@@ -19,6 +19,11 @@
<genTypeParameters ecoreTypeParameter="exploration.ecore#//ExplorationTarget/T"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference exploration.ecore#//ExplorationTarget/expression"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference exploration.ecore#//ExplorationTarget/containedTargets"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute exploration.ecore#//ExplorationTarget/resultTypeInternal"/>
<genOperations ecoreOperation="exploration.ecore#//ExplorationTarget/getResultType"/>
<genOperations ecoreOperation="exploration.ecore#//ExplorationTarget/setResultType">
<genParameters ecoreParameter="exploration.ecore#//ExplorationTarget/setResultType/type"/>
</genOperations>
</genClasses>
<genClasses image="false" ecoreClass="exploration.ecore#//ExplorationObjective">
<genTypeParameters ecoreTypeParameter="exploration.ecore#//ExplorationObjective/T"/>
......
......@@ -105,6 +105,12 @@
objectClass="org.fortiss.af3.efficientdeployment.model.DSEProjectConfiguration">
</objectClass>
</migrationProvider>
<migrationProvider
migrationProvider="org.fortiss.af3.exploration.migration.DSESuperSetTypeMigrator">
<objectClass
objectClass="org.fortiss.af3.exploration.projectmodel.dseArtifacts.DSESuperSets">
</objectClass>
</migrationProvider>
<migrationProvider
migrationProvider="org.fortiss.af3.exploration.migration.VisualizationToExpSolutionMigrator">
<objectClass
......
ExplorationActivator.java e2dae1cdf014c8ae994579bb887e1271114fad60 RED
ExplorationActivator.java e2dae1cdf014c8ae994579bb887e1271114fad60 YELLOW
DSEExplorationTargetContainmentMigrator.java 9090b5aa621346b1090e2c64dc18ea7aeee7b600 GREEN
DSEMigrationProvider.java 020ecea087aa8390ca5431e0ba366cc243ac29d2 RED
DSEExplorationTargetContainmentMigrator.java 9090b5aa621346b1090e2c64dc18ea7aeee7b600 YELLOW
DSEMigrationProvider.java 6e954d63703d7dfdbca75df669d8d0b446a068d1 RED
DSEProjectConfigurationRemoval.java 0f5ab87740e8d7e5aabcfeddbae548c4fe7ce368 RED
VisualizationToExpSolutionMigrator.java 7b04ac95fe1793218f61294c8e3ae9cd0eda010c GREEN
DSESuperSetTypeMigrator.java f8a450775702ca4612b14e96214c80291d039b27 YELLOW
VisualizationToExpSolutionMigrator.java c42278b60c1fb739aacab275b7ffb7e7d221aa39 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.migration;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.af3.deployment.model.VirtualLink;
import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet;
import org.fortiss.af3.exploration.projectmodel.DSE;
import org.fortiss.af3.exploration.projectmodel.dseArtifacts.DSESuperSets;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.project.utils.ProjectUtils;
import org.fortiss.af3.task.model.Signal;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationEntry;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
/**
* Sets the element type of SuperSets for old models. A code hack would undermine the intention
* of the element type's introduction.
*
* Created: 2018-02-27
* To be removed before AF3 Release 2.14
*
* @author diewald
*/
public class DSESuperSetTypeMigrator implements IMigrationProvider {
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
for(DSESuperSets superSets : getChildrenWithType(modelElement.getRootModelElement(),
DSESuperSets.class)) {
SuperSet<TransmissionUnit> busses = superSets.getBusSuperSet();
if(busses != null && busses.getEntryType() == null) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
FileProject fp = ProjectUtils.getFileProject(modelElement.getRootModelElement());
for(DSE dseProjects : pickInstanceOf(DSE.class, fp.getRootElements())) {
DSESuperSets superSets = dseProjects.getDseSuperSet();
SuperSet<TransmissionUnit> busses = superSets.getBusSuperSet();
busses.setEntryType(TransmissionUnit.class);
SuperSet<ComponentToTaskAllocationEntry> allocs =
superSets.getComponentTaskAllocations();
allocs.setEntryType(ComponentToTaskAllocationEntry.class);
SuperSet<ExecutionUnit> execUnits = superSets.getECUSuperSet();
execUnits.setEntryType(ExecutionUnit.class);
SuperSet<VirtualLink> routes = superSets.getRouteSuperSet();
routes.setEntryType(VirtualLink.class);
SuperSet<Signal> signals = superSets.getSignalSuperSet();
signals.setEntryType(Signal.class);
SuperSet<Task> tasks = superSets.getTaskSuperSet();
tasks.setEntryType(Task.class);
}
}
}
......@@ -160,7 +160,12 @@ public class VisualizationToExpSolutionMigrator implements IMigrationProvider {
// Up to now, only single points instead of ranges were generated as results of
// DSE executions, so using only
result.setResult(dataPoint.getStart());
singleExpSol.put(assocObjective, result);
try {
singleExpSol.put(assocObjective, result);
} catch(Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
expSol.getSolutions().add(singleExpSol);
......
ExpressionStaticImpl.java ba5a631d225bd1c62d603096f6fd3e402e810200 GREEN
ExpressionStaticImpl.java 1181ed4e5886ebd539bccebfc5ce61606ace8f2c YELLOW
......@@ -26,7 +26,7 @@ import org.fortiss.tooling.base.model.element.IModelElement;
/**
* Static implementation of Expression to string methods.
*
* @author philip
* @author offtermatt
*/
public class ExpressionStaticImpl {
......@@ -67,6 +67,6 @@ public class ExpressionStaticImpl {
@SuppressWarnings("unchecked")
public static <T extends IModelElement> Class<T> getElementType(Set<T> set) {
return (Class<T>)ExplorationReflectionUtils.getSubstitutionTypeOfGenericIface(set,
Set.class);
Set.class, Object.class);
}
}
HistoryStaticImpl.java 892e2e2e47a8e26183813e8380a0aec04cc55132 RED
PlatformEntryStaticImpl.java 9c6bc5f0f56eb4800d523e4943e3a5561940f61b RED
SuperSetMapStaticImpl.java 5080580ae8dfb6008fa6189b07fa01c70e612fc3 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.model.impl;
import org.eclipse.emf.ecore.EClass;
import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.tooling.base.model.element.IModelElement;
/**
* Static eoperation implementations of the {@link EClass} {@link SuperSetMap}.
*
* @author diewald
*/
public class SuperSetMapStaticImpl {
/** Static implementation of {@link SuperSetMap#get(Class)}. */
@SuppressWarnings("unchecked")
public static <T extends IModelElement> SuperSet<T> get(SuperSetMapImpl superSetMap,
Class<T> key) {
SuperSet<?> value = superSetMap.getSuperSetMap().get(key);
if(value == null || key.equals(value.getEntryType())) {
return (SuperSet<T>)value;
}
throw new IllegalArgumentException(
"The type of elements enclosed in the returned SuperSet does not match" +
" the key type " + key.getSimpleName() + ".");
}
/** Static implementation of {@link SuperSetMap#put(Class, SuperSet)}. */
@SuppressWarnings("unchecked")
public static <T extends IModelElement> SuperSet<T> put(SuperSetMapImpl superSetMap,
Class<T> key, SuperSet<T> value) {
if(key.equals(value.getEntryType())) {
return (SuperSet<T>)superSetMap.getSuperSetMap().put(key, value);
}
throw new IllegalArgumentException(
"The type of elements enclosed in the returned SuperSet does not match" +
" the key type " + key.getSimpleName() + ".");
}
}
SingleExplorationSolutionStaticImpl.java c39841217da9bdc5f0fb6b357b151638904db6c6 GREEN
SingleExplorationSolutionStaticImpl.java 89e769476923dbcea67daffcfc6215fd87a9631b YELLOW
......@@ -15,9 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.model.solutions.impl;
import java.util.Map.Entry;
import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.ExplorationTarget;
import org.fortiss.af3.exploration.model.solutions.ExplorationResult;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.tooling.base.model.element.IModelElement;
......@@ -33,18 +33,9 @@ public class SingleExplorationSolutionStaticImpl {
* {@link SingleExplorationSolution#getSolutionModel(Class)}.
*/
@SuppressWarnings("unchecked")
public static <T extends IModelElement> T getModel(SingleExplorationSolution singleExpSol,
public static <T extends IModelElement> T getModel(SingleExplorationSolutionImpl singleExpSol,
Class<T> modelType) {
T solutionModel = (T)singleExpSol.getSolutionSets().get(modelType);