Changes for new EMA Version

parent f90a4558
Pipeline #98741 failed with stages
in 5 minutes and 27 seconds
......@@ -2,6 +2,9 @@ package de.monticore.lang.monticar.generator.middleware.clustering;
import de.monticore.expressionsbasis._ast.ASTExpression;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAConnectorInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.math._ast.ASTNumberExpression;
import de.monticore.lang.monticar.common2._ast.ASTCommonMatrixType;
......@@ -21,25 +24,21 @@ public class AutomaticClusteringHelper {
static double MAXCOST= 999999;
public static double[][] createAdjacencyMatrix(List<ExpandedComponentInstanceSymbol> subcomps, Collection<ConnectorSymbol> connectors, Map<String, Integer> subcompLabels) {
public static double[][] createAdjacencyMatrix(List<EMAComponentInstanceSymbol> subcomps, Collection<EMAConnectorInstanceSymbol> connectors, Map<String, Integer> subcompLabels) {
// Nodes = subcomponents
// Verts = connectors between subcomponents
double[][] res = new double[subcomps.size()][subcomps.size()];
connectors.forEach(con -> {
Optional<ExpandedComponentInstanceSymbol> sourceCompOpt = con.getSourcePort().getComponentInstance();
Optional<ExpandedComponentInstanceSymbol> targetCompOpt = con.getTargetPort().getComponentInstance();
EMAComponentInstanceSymbol sourceCompOpt = con.getSourcePort().getComponentInstance();
EMAComponentInstanceSymbol targetCompOpt = con.getTargetPort().getComponentInstance();
if (sourceCompOpt.isPresent() && targetCompOpt.isPresent()) {
int index1 = subcompLabels.get(sourceCompOpt.get().getFullName());
int index2 = subcompLabels.get(targetCompOpt.get().getFullName());
int index1 = subcompLabels.get(sourceCompOpt.getFullName());
int index2 = subcompLabels.get(targetCompOpt.getFullName());
res[index1][index2] = getTypeCostHeuristic(con.getSourcePort());
res[index2][index1] = getTypeCostHeuristic(con.getSourcePort());
} else {
Log.error("0xADE65: Component of source or target not found!");
}
});
......@@ -105,16 +104,16 @@ public class AutomaticClusteringHelper {
return normalizeMatrix(inverseProbabilitiesMatrix(adjacencyMatrix));
}
public static void annotateComponentWithRosTagsForClusters(ExpandedComponentInstanceSymbol componentInstanceSymbol, List<Set<ExpandedComponentInstanceSymbol>> clusters) {
Collection<ConnectorSymbol> connectors = componentInstanceSymbol.getConnectors();
public static void annotateComponentWithRosTagsForClusters(EMAComponentInstanceSymbol componentInstanceSymbol, List<Set<EMAComponentInstanceSymbol>> clusters) {
Collection<EMAConnectorInstanceSymbol> connectors = componentInstanceSymbol.getConnectorInstances();
connectors.forEach(con -> {
// -1 = super comp
int sourceClusterLabel = -1;
int targetClusterLabel = -1;
ExpandedComponentInstanceSymbol sourceComp = con.getSourcePort().getComponentInstance().get();
ExpandedComponentInstanceSymbol targetComp = con.getTargetPort().getComponentInstance().get();
EMAComponentInstanceSymbol sourceComp = con.getSourcePort().getComponentInstance();
EMAComponentInstanceSymbol targetComp = con.getTargetPort().getComponentInstance();
for(int i = 0; i < clusters.size(); i++){
if(clusters.get(i).contains(sourceComp)){
......@@ -135,7 +134,7 @@ public class AutomaticClusteringHelper {
}
public static double getTypeCostHeuristic(PortSymbol port){
public static double getTypeCostHeuristic(EMAPortSymbol port){
return getTypeCostHeuristic(port.getTypeReference());
}
......
package de.monticore.lang.monticar.generator.middleware.clustering;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import java.util.List;
import java.util.Set;
// product if for clustering factory
public interface ClusteringAlgorithm {
public List<Set<ExpandedComponentInstanceSymbol>> cluster(ExpandedComponentInstanceSymbol component, Object... args);
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args);
}
......@@ -2,7 +2,7 @@ package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import com.clust4j.algo.AffinityPropagation;
import com.clust4j.algo.AffinityPropagationParameters;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.helpers.ComponentHelper;
......@@ -14,9 +14,9 @@ import java.util.*;
public class AffinityPropagationAlgorithm implements ClusteringAlgorithm {
@Override
public List<Set<ExpandedComponentInstanceSymbol>> cluster(ExpandedComponentInstanceSymbol component, Object... args) {
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
List<ExpandedComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
List<EMAComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
Map<String, Integer> labelsForSubcomps = ComponentHelper.getLabelsForSubcomps(subcompsOrderedByName);
double[][] adjMatrix = AutomaticClusteringHelper.createAdjacencyMatrix(subcompsOrderedByName,
ComponentHelper.getInnerConnectors(component),
......@@ -28,7 +28,7 @@ public class AffinityPropagationAlgorithm implements ClusteringAlgorithm {
final int[] labels = clustering.getLabels();
List<Set<ExpandedComponentInstanceSymbol>> res = new ArrayList<>();
List<Set<EMAComponentInstanceSymbol>> res = new ArrayList<>();
for(int i = 0; i < labels.length; i++){
res.add(new HashSet<>());
......
package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.helpers.ComponentHelper;
......@@ -12,9 +12,9 @@ import java.util.*;
// DBSCAN clusterer product implementation
public class DBSCANClusteringAlgorithm implements ClusteringAlgorithm {
@Override
public List<Set<ExpandedComponentInstanceSymbol>> cluster(ExpandedComponentInstanceSymbol component, Object... args) {
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
List<Set<ExpandedComponentInstanceSymbol>> res = new ArrayList<>();
List<Set<EMAComponentInstanceSymbol>> res = new ArrayList<>();
// params
Integer minPts= null;
......@@ -69,7 +69,7 @@ public class DBSCANClusteringAlgorithm implements ClusteringAlgorithm {
if (error) {
Log.error("DBSCANClusteringAlgorithm: Mandatory parameter(s) missing!");
} else {
List<ExpandedComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
List<EMAComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
Map<String, Integer> labelsForSubcomps = ComponentHelper.getLabelsForSubcomps(subcompsOrderedByName);
double[][] adjMatrix = AutomaticClusteringHelper.createAdjacencyMatrix(subcompsOrderedByName,
ComponentHelper.getInnerConnectors(component),
......
package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.helpers.ComponentHelper;
......@@ -67,9 +67,9 @@ public class MarkovClusteringAlgorithm implements ClusteringAlgorithm {
}
@Override
public List<Set<ExpandedComponentInstanceSymbol>> cluster(ExpandedComponentInstanceSymbol component, Object... args) {
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
List<Set<ExpandedComponentInstanceSymbol>> res = new ArrayList<>();
List<Set<EMAComponentInstanceSymbol>> res = new ArrayList<>();
// params
Double maxResidual= null;
......@@ -136,7 +136,7 @@ public class MarkovClusteringAlgorithm implements ClusteringAlgorithm {
if (error) {
Log.error("MarkovClusteringAlgorithm: Mandatory parameter(s) missing!");
} else {
List<ExpandedComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
List<EMAComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
Map<String, Integer> labelsForSubcomps = ComponentHelper.getLabelsForSubcomps(subcompsOrderedByName);
double[][] adjMatrix = AutomaticClusteringHelper.createAdjacencyMatrix(subcompsOrderedByName,
ComponentHelper.getInnerConnectors(component),
......
package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.helpers.ComponentHelper;
......@@ -12,9 +12,9 @@ import java.util.*;
// spectral clusterer product implementation
public class SpectralClusteringAlgorithm implements ClusteringAlgorithm {
@Override
public List<Set<ExpandedComponentInstanceSymbol>> cluster(ExpandedComponentInstanceSymbol component, Object... args) {
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
List<Set<ExpandedComponentInstanceSymbol>> res = new ArrayList<>();
List<Set<EMAComponentInstanceSymbol>> res = new ArrayList<>();
// params
Integer numClusters= null;
......@@ -75,7 +75,7 @@ public class SpectralClusteringAlgorithm implements ClusteringAlgorithm {
if (error) {
Log.error("SpectralClusteringAlgorithm: Mandatory parameter(s) missing!");
} else {
List<ExpandedComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
List<EMAComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(component);
Map<String, Integer> labelsForSubcomps = ComponentHelper.getLabelsForSubcomps(subcompsOrderedByName);
double[][] adjMatrix = AutomaticClusteringHelper.createAdjacencyMatrix(subcompsOrderedByName,
ComponentHelper.getInnerConnectors(component),
......
package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAConnectorInstanceSymbol;
import java.util.*;
import java.util.stream.Collectors;
public class ComponentHelper {
public static List<ExpandedComponentInstanceSymbol> getSubcompsOrderedByName(ExpandedComponentInstanceSymbol componentInstanceSymbol){
public static List<EMAComponentInstanceSymbol> getSubcompsOrderedByName(EMAComponentInstanceSymbol componentInstanceSymbol){
return componentInstanceSymbol.getSubComponents().stream()
.sorted(Comparator.comparing(ExpandedComponentInstanceSymbol::getFullName))
.sorted(Comparator.comparing(EMAComponentInstanceSymbol::getFullName))
.collect(Collectors.toList());
}
public static Collection<ConnectorSymbol> getInnerConnectors(ExpandedComponentInstanceSymbol componentInstanceSymbol){
public static Collection<EMAConnectorInstanceSymbol> getInnerConnectors(EMAComponentInstanceSymbol componentInstanceSymbol){
String superCompName = componentInstanceSymbol.getFullName();
return componentInstanceSymbol.getConnectors().stream()
return componentInstanceSymbol.getConnectorInstances().stream()
//filter out all connectors to super component
.filter(con -> !con.getSourcePort().getComponentInstance().get().getFullName().equals(superCompName)
&& !con.getTargetPort().getComponentInstance().get().getFullName().equals(superCompName))
.filter(con -> !con.getSourcePort().getComponentInstance().getFullName().equals(superCompName)
&& !con.getTargetPort().getComponentInstance().getFullName().equals(superCompName))
.collect(Collectors.toList());
}
public static Map<String, Integer> getLabelsForSubcomps(List<ExpandedComponentInstanceSymbol> subcomps) {
public static Map<String, Integer> getLabelsForSubcomps(List<EMAComponentInstanceSymbol> subcomps) {
Map<String, Integer> componentIndecies = new HashMap<>();
int[] i = {0};
......
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.MiddlewareSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.FileContent;
......@@ -21,21 +21,21 @@ public class MiddlewareTagGenImpl implements GeneratorImpl {
private String generationTargetPath;
@Override
public List<File> generate(ExpandedComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
List<File> res = new ArrayList<>();
//Collect Ports with Middleware Symbols from Super Component and first level subcomponents
List<PortSymbol> middlewarePortsSuper = componentInstanceSymbol.getPortsList().stream()
List<EMAPortInstanceSymbol> middlewarePortsSuper = componentInstanceSymbol.getPortInstanceList().stream()
.filter(portSymbol -> portSymbol.getMiddlewareSymbol().isPresent())
.collect(Collectors.toList());
List<PortSymbol> middlewarePortsSub = componentInstanceSymbol.getSubComponents()
List<EMAPortInstanceSymbol> middlewarePortsSub = componentInstanceSymbol.getSubComponents()
.stream()
.flatMap(ecis -> ecis.getPortsList().stream())
.flatMap(ecis -> ecis.getPortInstanceList().stream())
.filter(portSymbol -> portSymbol.getMiddlewareSymbol().isPresent())
.collect(Collectors.toList());
List<PortSymbol> middlewarePorts = new ArrayList<>();
List<EMAPortInstanceSymbol> middlewarePorts = new ArrayList<>();
middlewarePorts.addAll(middlewarePortsSub);
middlewarePorts.addAll(middlewarePortsSuper);
......@@ -44,9 +44,9 @@ public class MiddlewareTagGenImpl implements GeneratorImpl {
return res;
}
private File generateRosTags(String packageName ,List<PortSymbol> middlewarePorts) throws IOException {
List<PortSymbol> rosPorts = middlewarePorts.stream()
.filter(PortSymbol::isRosPort)
private File generateRosTags(String packageName ,List<EMAPortInstanceSymbol> middlewarePorts) throws IOException {
List<EMAPortInstanceSymbol> rosPorts = middlewarePorts.stream()
.filter(EMAPortInstanceSymbol::isRosPort)
.collect(Collectors.toList());
FileContent result = new FileContent();
......@@ -88,7 +88,7 @@ public class MiddlewareTagGenImpl implements GeneratorImpl {
}
@Override
public boolean willAccept(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
//TODO: fill?
return true;
}
......
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAConnectorInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.*;
import de.monticore.lang.monticar.generator.middleware.clustering.algorithms.*;
import com.clust4j.algo.AffinityPropagation;
......@@ -41,10 +41,10 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
public void testAdjacencyMatrixCreation(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("lab.system", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("lab.system", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
List<ExpandedComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(componentInstanceSymbol);
List<EMAComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(componentInstanceSymbol);
double[][] matrix = AutomaticClusteringHelper.createAdjacencyMatrix(subcompsOrderedByName,
ComponentHelper.getInnerConnectors(componentInstanceSymbol),
ComponentHelper.getLabelsForSubcomps(subcompsOrderedByName));
......@@ -102,15 +102,15 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
public void testFlattenAlgorithm1(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<ExpandedComponentInstanceSymbol>resolve("lab.overallSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<EMAComponentInstanceSymbol>resolve("lab.overallSystem", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
EMAComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
Collection<EMAComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<EMAConnectorInstanceSymbol> connectors = newComponentInstanceSymbol.getConnectorInstances();
assertEquals(10, subComponents.size());
assertEquals(20, connectors.size());
}
......@@ -119,15 +119,15 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
public void testFlattenAlgorithm1ShortNames(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<ExpandedComponentInstanceSymbol>resolve("lab.overallSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<EMAComponentInstanceSymbol>resolve("lab.overallSystem", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
EMAComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol, new HashMap<>());
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
Collection<EMAComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<EMAConnectorInstanceSymbol> connectors = newComponentInstanceSymbol.getConnectorInstances();
assertEquals(10, subComponents.size());
assertEquals(20, connectors.size());
}
......@@ -136,15 +136,15 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
public void testFlattenAlgorithm2(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<EMAComponentInstanceSymbol>resolve("lab.spanningSystem", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
EMAComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
Collection<EMAComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<EMAConnectorInstanceSymbol> connectors = newComponentInstanceSymbol.getConnectorInstances();
assertEquals(20, subComponents.size());
assertEquals(40, connectors.size());
}
......@@ -153,15 +153,15 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
public void testFlattenAlgorithm2ShortNames() {
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<EMAComponentInstanceSymbol>resolve("lab.spanningSystem", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
EMAComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol, new HashMap<>());
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
Collection<EMAComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<EMAConnectorInstanceSymbol> connectors = newComponentInstanceSymbol.getConnectorInstances();
assertEquals(20, subComponents.size());
assertEquals(40, connectors.size());
}
......@@ -170,15 +170,15 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
public void testFlattenAlgorithmWithLevels() {
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<EMAComponentInstanceSymbol>resolve("lab.spanningSystem", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
EMAComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol, new HashMap<>(), 2);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
Collection<EMAComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<EMAConnectorInstanceSymbol> connectors = newComponentInstanceSymbol.getConnectorInstances();
assertEquals(4, subComponents.size());
assertEquals(24, connectors.size());
}
......@@ -509,12 +509,12 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
//UnambiguousCluster
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("clustering.unambiguousCluster", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("clustering.unambiguousCluster", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
System.out.println(algorithm);
List<Set<ExpandedComponentInstanceSymbol>> clusters = null;
List<Set<EMAComponentInstanceSymbol>> clusters = null;
if (params != null) clusters = algorithm.cluster(componentInstanceSymbol, params); else
clusters = algorithm.cluster(componentInstanceSymbol);
......@@ -523,8 +523,8 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
assertTrue(clusters.size() == 2);
Set<ExpandedComponentInstanceSymbol> cluster1 = clusters.get(0);
Set<ExpandedComponentInstanceSymbol> cluster2 = clusters.get(1);
Set<EMAComponentInstanceSymbol> cluster1 = clusters.get(0);
Set<EMAComponentInstanceSymbol> cluster2 = clusters.get(1);
assertTrue(cluster1.size() == 2);
assertTrue(cluster2.size() == 2);
......@@ -555,10 +555,10 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
assertTrue(clusters.size() == 4);
Set<ExpandedComponentInstanceSymbol> cluster1 = clusters.get(0);
Set<ExpandedComponentInstanceSymbol> cluster2 = clusters.get(1);
Set<ExpandedComponentInstanceSymbol> cluster3 = clusters.get(2);
Set<ExpandedComponentInstanceSymbol> cluster4 = clusters.get(3);
Set<EMAComponentInstanceSymbol> cluster1 = clusters.get(0);
Set<EMAComponentInstanceSymbol> cluster2 = clusters.get(1);
Set<EMAComponentInstanceSymbol> cluster3 = clusters.get(2);
Set<EMAComponentInstanceSymbol> cluster4 = clusters.get(3);
assertTrue(cluster1.size() == 1);
assertTrue(cluster2.size() == 1);
assertTrue(cluster3.size() == 1);
......@@ -584,18 +584,18 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
//ClustersWithSingleConnection
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("clustering.clustersWithSingleConnection", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("clustering.clustersWithSingleConnection", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
//Force cluster; spectral would not cluster this way!
List<Set<ExpandedComponentInstanceSymbol>> clusters = new ArrayList<>();
List<Set<EMAComponentInstanceSymbol>> clusters = new ArrayList<>();
HashSet<ExpandedComponentInstanceSymbol> cluster1 = new HashSet<>();
HashSet<EMAComponentInstanceSymbol> cluster1 = new HashSet<>();
cluster1.add(componentInstanceSymbol.getSubComponent("outComp1").get());
cluster1.add(componentInstanceSymbol.getSubComponent("inOutComp").get());
clusters.add(cluster1);
HashSet<ExpandedComponentInstanceSymbol> cluster2 = new HashSet<>();
HashSet<EMAComponentInstanceSymbol> cluster2 = new HashSet<>();
cluster2.add(componentInstanceSymbol.getSubComponent("outComp2").get());
cluster2.add(componentInstanceSymbol.getSubComponent("doubleInComp").get());
clusters.add(cluster2);
......@@ -603,15 +603,15 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
AutomaticClusteringHelper.annotateComponentWithRosTagsForClusters(componentInstanceSymbol, clusters);
List<String> rosPortsSuper = componentInstanceSymbol.getPortsList().stream()
.filter(PortSymbol::isRosPort)
.map(PortSymbol::getFullName)
List<String> rosPortsSuper = componentInstanceSymbol.getPortInstanceList().stream()
.filter(EMAPortInstanceSymbol::isRosPort)
.map(EMAPortInstanceSymbol::getFullName)
.collect(Collectors.toList());
List<String> rosPortsSubComps = componentInstanceSymbol.getSubComponents().stream()
.flatMap(subc -> subc.getPortsList().stream())
.filter(PortSymbol::isRosPort)
.map(PortSymbol::getFullName)
.flatMap(subc -> subc.getPortInstanceList().stream())
.filter(EMAPortInstanceSymbol::isRosPort)
.map(EMAPortInstanceSymbol::getFullName)
.collect(Collectors.toList());
//No Ports in super comp
......@@ -636,28 +636,28 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
//CostHeuristic
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("test.costHeuristic", ExpandedComponentInstanceSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("test.costHeuristic", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
double inC = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inC").get());
double inQ = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQ").get());
double inZ = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inZ").get());
double inB = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inB").get());
double inC = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPortInstance("inC").get());
double inQ = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPortInstance("inQ").get());
double inZ = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPortInstance("inZ").get());
double inB = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPortInstance("inB").get());
assertTrue(inC > inQ);
assertTrue(inQ > inZ);
assertTrue(inZ > inB);
double inQVec = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQVec").get());
double inQVec2 = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQVec2").get());
double inQVec = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPortInstance("inQVec").get());
double inQVec2 = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPortInstance(