Commit 41454d26 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3875' into 'master'

Platform Synthesis: Remove transformation-only specifications fully

See merge request af3/af3!261
parents 6a3e1918 82ca477c
PlatformConnectorInstanceConverter.java 073e050ad673f41e9d012de01c1aee6fdd04e4ce GREEN PlatformConnectorInstanceConverter.java 073e050ad673f41e9d012de01c1aee6fdd04e4ce GREEN
PlatformExecUnitInstantiationConverter.java a0426a3ad7d2efac9b0f73ddb76ee2060d4101e5 GREEN PlatformExecUnitInstantiationConverter.java 6a003e2fbc3fc115ad39578c87ddd64f23da9593 GREEN
PlatformTransmissionConnectionConverter.java 365a2fb563e4ed36a1b159dfa3bcce47216a935c GREEN PlatformTransmissionConnectionConverter.java 365a2fb563e4ed36a1b159dfa3bcce47216a935c GREEN
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
package org.fortiss.af3.exploration.solutionconverter.platform; package org.fortiss.af3.exploration.solutionconverter.platform;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; import static org.fortiss.af3.exploration.util.DSESolutionConversionUtils.getAndRemoveSpec;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
...@@ -72,8 +72,7 @@ public class PlatformExecUnitInstantiationConverter ...@@ -72,8 +72,7 @@ public class PlatformExecUnitInstantiationConverter
for(ExecutionUnit instExecUnit : fromSuperSet.getEntries()) { for(ExecutionUnit instExecUnit : fromSuperSet.getEntries()) {
// Fetch the template element such that it can be removed after the instances were // Fetch the template element such that it can be removed after the instances were
// added. // added.
InstanceOfElement instSpec = InstanceOfElement instSpec = getAndRemoveSpec(instExecUnit, InstanceOfElement.class);
pickFirstInstanceOf(InstanceOfElement.class, instExecUnit.getSpecifications());
ExecutionUnit templateExecUnit = (ExecutionUnit)instSpec.getTemplateElement(); ExecutionUnit templateExecUnit = (ExecutionUnit)instSpec.getTemplateElement();
templateExecUnits.add(templateExecUnit); templateExecUnits.add(templateExecUnit);
......
DSEProjectModelElementFactory.java a56e2cd564383726898336469ebc3203186e992f GREEN DSEProjectModelElementFactory.java a56e2cd564383726898336469ebc3203186e992f GREEN
DSESolutionConversionUtils.java d97459e189370cbfc202201832ed060e25564607 GREEN DSESolutionConversionUtils.java a6ccbba92864c653d1518a92455e87c17f7cc72b GREEN
DSMLModelElementFactory.java 24b8cf9c900e948dcc71eb2a7fa26232baa6f7a5 GREEN DSMLModelElementFactory.java 24b8cf9c900e948dcc71eb2a7fa26232baa6f7a5 GREEN
DSMLUtils.java c07eeef09787cea9db98533d346e3e384a232593 GREEN DSMLUtils.java c07eeef09787cea9db98533d346e3e384a232593 GREEN
ExplorationModelElementFactory.java bb48b2d09b92efcb1b2d3e382555089bb7ed5db5 GREEN ExplorationModelElementFactory.java bb48b2d09b92efcb1b2d3e382555089bb7ed5db5 GREEN
......
...@@ -19,6 +19,7 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; ...@@ -19,6 +19,7 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError; import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import org.fortiss.af3.exploration.model.specification.ContainedByElement; import org.fortiss.af3.exploration.model.specification.ContainedByElement;
import org.fortiss.af3.exploration.model.specification.IVolatileModelElementSpecification;
import org.fortiss.af3.exploration.solutionconverter.IDSESolutionConverter; import org.fortiss.af3.exploration.solutionconverter.IDSESolutionConverter;
import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.base.model.element.IModelElement;
...@@ -36,18 +37,31 @@ public class DSESolutionConversionUtils { ...@@ -36,18 +37,31 @@ public class DSESolutionConversionUtils {
// Prevent instantiation. // Prevent instantiation.
} }
/**
* Returns the given {@link IModelElementSpecification} if it is attached to the given
* {@link IModelElement} and deletes it. If no such {@link IModelElementSpecification} exists,
* {@code null} is returned.
*/
public static <T extends IVolatileModelElementSpecification> T
getAndRemoveSpec(IModelElement element, Class<? extends T> specType) {
T spec = pickFirstInstanceOf(specType, element.getSpecifications());
if(spec == null) {
return null;
}
element.getSpecifications().remove(spec);
return spec;
}
/** /**
* Returns the container element referenced by the {@link ContainedByElement} * Returns the container element referenced by the {@link ContainedByElement}
* {@link IModelElementSpecification} and removes the {@link IModelElementSpecification} form * {@link IModelElementSpecification} and removes the {@link IModelElementSpecification} form
* the element. Returns {@code null} if no such {@link IModelElementSpecification} is found. * the element. Returns {@code null} if no such {@link IModelElementSpecification} is found.
*/ */
public static IHierarchicElement getContainedByAndRemoveSpec(IModelElement element) { public static IHierarchicElement getContainedByAndRemoveSpec(IModelElement element) {
ContainedByElement containmentSpec = ContainedByElement containmentSpec = getAndRemoveSpec(element, ContainedByElement.class);
pickFirstInstanceOf(ContainedByElement.class, element.getSpecifications());
if(containmentSpec == null) { if(containmentSpec == null) {
return null; return null;
} }
element.getSpecifications().remove(containmentSpec);
return containmentSpec.getFutureContainerRef(); return containmentSpec.getFutureContainerRef();
} }
......
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