Commit 6a0cca0a authored by Alexander Diewald's avatar Alexander Diewald

Hier. Plat.: Fix Cluster exclusiveness logic.

It was not possible to add clusters if an OffChipGateway was present,
which is a valid use case where clusters shall still be addible.

Issue-Ref: 3980
Issue-Url: https://af3-developer.fortiss.org/issues/3980Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent bbe37a97
HierarchicPlatformArchitectureCompositor.java 1d2debd385e655339de4d60a5e3e84f26bab5a87 YELLOW HierarchicPlatformArchitectureCompositor.java fecefdbd64c391f179730ac5aea7e7265ec81fca YELLOW
HierarchicalCompositionRules.java 711685d75d9817ec37156dc087d997c119e4c561 YELLOW HierarchicalCompositionRules.java 711685d75d9817ec37156dc087d997c119e4c561 YELLOW
...@@ -15,8 +15,12 @@ ...@@ -15,8 +15,12 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.hierarchic.compose; package org.fortiss.af3.platform.hierarchic.compose;
import static org.fortiss.tooling.common.util.LambdaUtils.filterByType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.platform.hierarchic.compose.base.IPlatformHierarchicalCompositionRules; import org.fortiss.af3.platform.hierarchic.compose.base.IPlatformHierarchicalCompositionRules;
...@@ -27,6 +31,7 @@ import org.fortiss.af3.platform.hierarchic.model.electronics.Clock; ...@@ -27,6 +31,7 @@ import org.fortiss.af3.platform.hierarchic.model.electronics.Clock;
import org.fortiss.af3.platform.hierarchic.model.node.OffChipNetworkInterface; import org.fortiss.af3.platform.hierarchic.model.node.OffChipNetworkInterface;
import org.fortiss.af3.platform.hierarchic.model.node.OffChipNetworkPort; import org.fortiss.af3.platform.hierarchic.model.node.OffChipNetworkPort;
import org.fortiss.af3.platform.model.IArchitectureDomain; import org.fortiss.af3.platform.model.IArchitectureDomain;
import org.fortiss.af3.platform.model.IPlatformArchitectureElement;
import org.fortiss.af3.platform.model.PlatformArchitecture; import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
...@@ -62,10 +67,16 @@ public class HierarchicPlatformArchitectureCompositor extends PlatformArchitectu ...@@ -62,10 +67,16 @@ public class HierarchicPlatformArchitectureCompositor extends PlatformArchitectu
// Clusters and Nodes are used at the top-level. // Clusters and Nodes are used at the top-level.
EList<IHierarchicElement> paChildren = container.getContainedElements(); EList<IHierarchicElement> paChildren = container.getContainedElements();
boolean containsCluster = pickFirstInstanceOf(Cluster.class, paChildren) != null; boolean containsCluster = pickFirstInstanceOf(Cluster.class, paChildren) != null;
boolean containsNonCluster = !containsCluster && !paChildren.isEmpty(); Set<IPlatformArchitectureElement> childElems =
new HashSet<>(filterByType(paChildren, IPlatformArchitectureElement.class));
Set<IPlatformArchitectureElement> clusterElems =
new HashSet<>(filterByType(filterByType(paChildren, IClusterDomain.class),
IPlatformArchitectureElement.class));
childElems.removeAll(clusterElems);
boolean containsNonClusterDomElem = !childElems.isEmpty();
if((containsCluster && !(contained instanceof IClusterDomain)) || if((containsCluster && !(contained instanceof IClusterDomain)) ||
(containsNonCluster && contained instanceof Cluster)) { (containsNonClusterDomElem && contained instanceof Cluster)) {
return false; return false;
} }
......
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