From b6373f6b1910e345880b4f64f9421c0a6951a173 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <stu114708@informatik.uni-kiel.de>
Date: Mon, 20 Jun 2016 17:06:36 +0200
Subject: [PATCH] bug fixes

---
 .../analysis/TraceAnalysisConfiguration.java  | 30 ++++++-
 .../dev/SoftwareSystemAggregatorStage.java    | 90 +++++++++----------
 .../AssemblyDependencyGraphCreator.java       | 19 ++--
 3 files changed, 79 insertions(+), 60 deletions(-)

diff --git a/src/main/java/kieker/analysis/TraceAnalysisConfiguration.java b/src/main/java/kieker/analysis/TraceAnalysisConfiguration.java
index 44ab521e..f34d1c55 100644
--- a/src/main/java/kieker/analysis/TraceAnalysisConfiguration.java
+++ b/src/main/java/kieker/analysis/TraceAnalysisConfiguration.java
@@ -7,7 +7,10 @@ import java.io.File;
 
 import kieker.analysis.dev.ComponentStatisticsDecoratorStage;
 import kieker.analysis.dev.OperationsStatisticsDecoratorStage;
+import kieker.analysis.dev.SoftwareSystemAggregatorStage;
 import kieker.analysis.dev.SoftwareSystemCreatorStage;
+import kieker.analysis.dev.dependencygraphs.AssemblyDependencyGraphCreatorStage;
+import kieker.analysis.dev.dependencygraphs.AssemblyDependencyGraphLevel;
 import kieker.analysis.dev.dependencygraphs.DeploymentDependencyGraphCreatorStage;
 import kieker.analysis.dev.dependencygraphs.DeploymentDependencyGraphLevel;
 import kieker.analysis.dev.dependencygraphs.DotComponentsDependencyExportStage;
@@ -97,6 +100,8 @@ public class TraceAnalysisConfiguration extends Configuration {
 		// super.connectPorts(graphDistributor2.getNewOutputPort(), dotTraceGraphFileWriterStage2.getInputPort());
 
 		SoftwareSystemCreatorStage softwareSystemCreator = new SoftwareSystemCreatorStage();
+		Distributor<SoftwareSystem> softwareSystemDistributor = new Distributor<>(new CopyByReferenceStrategy());
+
 		OperationsStatisticsDecoratorStage operationsStatisticsDecorator = new OperationsStatisticsDecoratorStage();
 		Distributor<SoftwareSystem> x1SoftwareSystemDistributor = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required
 		ComponentStatisticsDecoratorStage componentsStatisticsDecorator = new ComponentStatisticsDecoratorStage();
@@ -109,8 +114,20 @@ public class TraceAnalysisConfiguration extends Configuration {
 		DeploymentDependencyGraphCreatorStage containerDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.CONTAINER);
 		DotContainersDependencyExportStage dotContainerDependencyExporter = new DotContainersDependencyExportStage(graphFilesOutputDir);
 
+		SoftwareSystemAggregatorStage softwareSystemAggregator = new SoftwareSystemAggregatorStage();
+		OperationsStatisticsDecoratorStage operationsStatisticsDecoratorAss = new OperationsStatisticsDecoratorStage();
+		Distributor<SoftwareSystem> x1SoftwareSystemDistributorAss = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required
+		ComponentStatisticsDecoratorStage componentsStatisticsDecoratorAss = new ComponentStatisticsDecoratorStage();
+		Distributor<SoftwareSystem> x2SoftwareSystemDistributorAss = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required
+		AssemblyDependencyGraphCreatorStage operationsDependencyGraphCreatorAss = new AssemblyDependencyGraphCreatorStage(AssemblyDependencyGraphLevel.OPERATION);
+		DotOperationsDependencyExportStage dotOperationsDependencyExporterAss = new DotOperationsDependencyExportStage(graphFilesOutputDir);
+		AssemblyDependencyGraphCreatorStage componentDependencyGraphCreatorAss = new AssemblyDependencyGraphCreatorStage(AssemblyDependencyGraphLevel.COMPONENT);
+		DotComponentsDependencyExportStage dotComponentDependencyExporterAss = new DotComponentsDependencyExportStage(graphFilesOutputDir);
+
 		super.connectPorts(aggregatedTraceDistributor.getNewOutputPort(), softwareSystemCreator.getInputPort());
-		super.connectPorts(softwareSystemCreator.getOutputPort(), operationsStatisticsDecorator.getInputPort());
+		super.connectPorts(softwareSystemCreator.getOutputPort(), softwareSystemDistributor.getInputPort());
+
+		super.connectPorts(softwareSystemDistributor.getNewOutputPort(), operationsStatisticsDecorator.getInputPort());
 		super.connectPorts(operationsStatisticsDecorator.getOutputPort(), x1SoftwareSystemDistributor.getInputPort());
 		super.connectPorts(x1SoftwareSystemDistributor.getNewOutputPort(), operationsDependencyGraphCreator.getInputPort());
 		super.connectPorts(operationsDependencyGraphCreator.getOutputPort(), dotOperationsDependencyExporter.getInputPort());
@@ -122,6 +139,17 @@ public class TraceAnalysisConfiguration extends Configuration {
 		super.connectPorts(x2SoftwareSystemDistributor.getNewOutputPort(), containerDependencyGraphCreator.getInputPort());
 		super.connectPorts(containerDependencyGraphCreator.getOutputPort(), dotContainerDependencyExporter.getInputPort());
 
+		super.connectPorts(softwareSystemDistributor.getNewOutputPort(), softwareSystemAggregator.getInputPort());
+		super.connectPorts(softwareSystemAggregator.getOutputPort(), operationsStatisticsDecoratorAss.getInputPort());
+		super.connectPorts(operationsStatisticsDecoratorAss.getOutputPort(), x1SoftwareSystemDistributorAss.getInputPort());
+		super.connectPorts(x1SoftwareSystemDistributorAss.getNewOutputPort(), operationsDependencyGraphCreatorAss.getInputPort());
+		super.connectPorts(operationsDependencyGraphCreatorAss.getOutputPort(), dotOperationsDependencyExporterAss.getInputPort());
+		// super.connectPorts(x1SoftwareSystemDistributorAss.getNewOutputPort(), componentsStatisticsDecoratorAss.getInputPort());
+		// super.connectPorts(componentsStatisticsDecoratorAss.getOutputPort(), x2SoftwareSystemDistributorAss.getInputPort());
+		super.connectPorts(x1SoftwareSystemDistributorAss.getNewOutputPort(), x2SoftwareSystemDistributorAss.getInputPort());
+		super.connectPorts(x2SoftwareSystemDistributorAss.getNewOutputPort(), componentDependencyGraphCreatorAss.getInputPort());
+		super.connectPorts(componentDependencyGraphCreatorAss.getOutputPort(), dotComponentDependencyExporterAss.getInputPort());
+
 		/*
 		 *
 		 *
diff --git a/src/main/java/kieker/analysis/dev/SoftwareSystemAggregatorStage.java b/src/main/java/kieker/analysis/dev/SoftwareSystemAggregatorStage.java
index 6baa77f9..3e85a721 100644
--- a/src/main/java/kieker/analysis/dev/SoftwareSystemAggregatorStage.java
+++ b/src/main/java/kieker/analysis/dev/SoftwareSystemAggregatorStage.java
@@ -1,12 +1,5 @@
 package kieker.analysis.dev;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import kieker.analysis.domain.systemdependency.Component;
-import kieker.analysis.domain.systemdependency.Container;
-import kieker.analysis.domain.systemdependency.Dependency;
-import kieker.analysis.domain.systemdependency.Operation;
 import kieker.analysis.domain.systemdependency.SoftwareSystem;
 
 import teetime.stage.basic.AbstractTransformation;
@@ -19,45 +12,50 @@ public class SoftwareSystemAggregatorStage extends AbstractTransformation<Softwa
 	@Override
 	protected void execute(final SoftwareSystem deploymentSoftwareSystem) {
 
-		Map<Component, Component> components = new HashMap<>(); // Old -> New
-		Map<Operation, Operation> operations = new HashMap<>(); // Old -> New
-
-		SoftwareSystem assemblySoftwareSystem = new SoftwareSystem();
-		Container newContainer = assemblySoftwareSystem.addContainer("DEFAULT");
-
-		for (Container container : deploymentSoftwareSystem.getContainers()) {
-			for (Component component : container.getComponents()) {
-				Component newComponent = newContainer.addComponent(component.getName());
-				components.put(component, newComponent);
-				for (Operation operation : component.getOperations()) {
-					Operation newOperation = newComponent.addOperation(operation.getName());
-					newOperation.getOperationCalls().addAll(operation.getOperationCalls());
-					operations.put(operation, newOperation);
-				}
-			}
-		}
-
-		for (Dependency<Component> componentDependency : deploymentSoftwareSystem.getComponentDependencies()) {
-			Component newCaller = components.get(componentDependency.getCaller());
-			Component newCallee = components.get(componentDependency.getCallee());
-
-			// Adds only if absent
-			Dependency<Component> dependency = assemblySoftwareSystem.addComponentDependency(newCaller, newCallee);
-			dependency.addCalls(componentDependency.getCalls());
-			dependency.addFailuredCalls(componentDependency.getFailuredCalls());
-		}
-
-		for (Dependency<Operation> operationDependency : deploymentSoftwareSystem.getOperationDependencies()) {
-			Operation newCaller = operations.get(operationDependency.getCaller());
-			Operation newCallee = operations.get(operationDependency.getCallee());
-
-			// Adds only if absent
-			Dependency<Operation> dependency = assemblySoftwareSystem.addOperationDependency(newCaller, newCallee);
-			dependency.addCalls(operationDependency.getCalls());
-			dependency.addFailuredCalls(operationDependency.getFailuredCalls());
-		}
-
-		this.outputPort.send(assemblySoftwareSystem);
+		this.getOutputPort().send(deploymentSoftwareSystem); // TODO temp
+
+		/*
+		 * 
+		 * Map<Component, Component> components = new HashMap<>(); // Old -> New
+		 * Map<Operation, Operation> operations = new HashMap<>(); // Old -> New
+		 * 
+		 * SoftwareSystem assemblySoftwareSystem = new SoftwareSystem();
+		 * Container newContainer = assemblySoftwareSystem.addContainer("DEFAULT");
+		 * 
+		 * for (Container container : deploymentSoftwareSystem.getContainers()) {
+		 * for (Component component : container.getComponents()) {
+		 * Component newComponent = newContainer.addComponent(component.getName());
+		 * components.put(component, newComponent);
+		 * for (Operation operation : component.getOperations()) {
+		 * Operation newOperation = newComponent.addOperation(operation.getName());
+		 * newOperation.getOperationCalls().addAll(operation.getOperationCalls());
+		 * operations.put(operation, newOperation);
+		 * }
+		 * }
+		 * }
+		 * 
+		 * for (Dependency<Component> componentDependency : deploymentSoftwareSystem.getComponentDependencies()) {
+		 * Component newCaller = components.get(componentDependency.getCaller());
+		 * Component newCallee = components.get(componentDependency.getCallee());
+		 * 
+		 * // Adds only if absent
+		 * Dependency<Component> dependency = assemblySoftwareSystem.addComponentDependency(newCaller, newCallee);
+		 * dependency.addCalls(componentDependency.getCalls());
+		 * dependency.addFailuredCalls(componentDependency.getFailuredCalls());
+		 * }
+		 * 
+		 * for (Dependency<Operation> operationDependency : deploymentSoftwareSystem.getOperationDependencies()) {
+		 * Operation newCaller = operations.get(operationDependency.getCaller());
+		 * Operation newCallee = operations.get(operationDependency.getCallee());
+		 * 
+		 * // Adds only if absent
+		 * Dependency<Operation> dependency = assemblySoftwareSystem.addOperationDependency(newCaller, newCallee);
+		 * dependency.addCalls(operationDependency.getCalls());
+		 * dependency.addFailuredCalls(operationDependency.getFailuredCalls());
+		 * }
+		 * 
+		 * this.getOutputPort().send(assemblySoftwareSystem);
+		 */
 	}
 
 }
diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java
index 89863f20..e6d0f02d 100644
--- a/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java
+++ b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java
@@ -34,10 +34,10 @@ public class AssemblyDependencyGraphCreator {
 		Graph graph = new GraphImpl();
 		switch (this.depth) {
 		case COMPONENT:
-			graph.setName("DeploymentComponentsDependencyGraph");
+			graph.setName("AssemblyComponentsDependencyGraph");
 			break;
 		case OPERATION:
-			graph.setName("DeploymentOperationsDependencyGraph");
+			graph.setName("AssemblyOperationsDependencyGraph");
 			break;
 		}
 
@@ -81,14 +81,11 @@ public class AssemblyDependencyGraphCreator {
 		if (this.relations.contains(AssemblyDependencyGraphLevel.COMPONENT)) {
 			for (Dependency<Component> dependency : softwareSystem.getComponentDependencies()) {
 
-				String callerContainerIdentifier = dependency.getCaller().getContainer().getIdentifier();
 				String callerComponentIdentifier = dependency.getCaller().getIdentifier();
-
-				String calleeContainerIdentifier = dependency.getCallee().getContainer().getIdentifier();
 				String calleeComponentIdentifier = dependency.getCallee().getIdentifier();
 
-				Vertex callerVertex = graph.getVertex(callerContainerIdentifier).getChildGraph().getVertex(callerComponentIdentifier);
-				Vertex calleeVertex = graph.getVertex(calleeContainerIdentifier).getChildGraph().getVertex(calleeComponentIdentifier);
+				Vertex callerVertex = graph.getVertex(callerComponentIdentifier);
+				Vertex calleeVertex = graph.getVertex(calleeComponentIdentifier);
 
 				Edge dependencyEdge = graph.addEdge(null, callerVertex, calleeVertex);
 				dependencyEdge.setProperty("calls", dependency.getCalls());
@@ -99,18 +96,14 @@ public class AssemblyDependencyGraphCreator {
 		if (this.relations.contains(AssemblyDependencyGraphLevel.OPERATION)) {
 			for (Dependency<Operation> dependency : softwareSystem.getOperationDependencies()) {
 
-				String callerContainerIdentifier = dependency.getCaller().getComponent().getContainer().getIdentifier();
 				String callerComponentIdentifier = dependency.getCaller().getComponent().getIdentifier();
 				String callerOperationIdentifier = dependency.getCaller().getIdentifier();
 
-				String calleeContainerIdentifier = dependency.getCallee().getComponent().getContainer().getIdentifier();
 				String calleeComponentIdentifier = dependency.getCallee().getComponent().getIdentifier();
 				String calleeOperationIdentifier = dependency.getCallee().getIdentifier();
 
-				Vertex callerVertex = graph.getVertex(callerContainerIdentifier).getChildGraph().getVertex(callerComponentIdentifier).getChildGraph()
-						.getVertex(callerOperationIdentifier);
-				Vertex calleeVertex = graph.getVertex(calleeContainerIdentifier).getChildGraph().getVertex(calleeComponentIdentifier).getChildGraph()
-						.getVertex(calleeOperationIdentifier);
+				Vertex callerVertex = graph.getVertex(callerComponentIdentifier).getChildGraph().getVertex(callerOperationIdentifier);
+				Vertex calleeVertex = graph.getVertex(calleeComponentIdentifier).getChildGraph().getVertex(calleeOperationIdentifier);
 
 				Edge dependencyEdge = graph.addEdge(null, callerVertex, calleeVertex);
 				dependencyEdge.setProperty("calls", dependency.getCalls());
-- 
GitLab