From dae31a14c75522a7c0cf04063627cb3d400cb60c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <stu114708@informatik.uni-kiel.de>
Date: Fri, 22 Jan 2016 17:14:15 +0100
Subject: [PATCH] work on #19

---
 .../ComponentDependencyGraphCreatorStage.java |  2 +-
 .../kieker/analysis/domain/ComponentCall.java | 33 ++++++++++++++
 .../analysis/domain/ComponentDependency.java  | 45 +++++++++++++++++++
 .../domain/ComponentDependencyRelation.java   | 43 ++++++++++++++++++
 .../analysis/domain/OperationsDependency.java |  1 +
 5 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 src/main/java/kieker/analysis/domain/ComponentCall.java
 create mode 100644 src/main/java/kieker/analysis/domain/ComponentDependency.java
 create mode 100644 src/main/java/kieker/analysis/domain/ComponentDependencyRelation.java

diff --git a/src/main/java/kieker/analysis/dev/ComponentDependencyGraphCreatorStage.java b/src/main/java/kieker/analysis/dev/ComponentDependencyGraphCreatorStage.java
index c347c84e..0191c8e1 100644
--- a/src/main/java/kieker/analysis/dev/ComponentDependencyGraphCreatorStage.java
+++ b/src/main/java/kieker/analysis/dev/ComponentDependencyGraphCreatorStage.java
@@ -9,7 +9,7 @@ import teetime.stage.basic.AbstractTransformation;
 public class ComponentDependencyGraphCreatorStage extends AbstractTransformation<OperationsDependency, Graph> {
 
 	@Override
-	protected void execute(final OperationsDependency element) {
+	protected void execute(final OperationsDependency operationsDependency) {
 
 		// Loop trough nodes
 		// Loop trough edges
diff --git a/src/main/java/kieker/analysis/domain/ComponentCall.java b/src/main/java/kieker/analysis/domain/ComponentCall.java
new file mode 100644
index 00000000..a4f70068
--- /dev/null
+++ b/src/main/java/kieker/analysis/domain/ComponentCall.java
@@ -0,0 +1,33 @@
+package kieker.analysis.domain;
+
+public class ComponentCall {
+
+	private final String container;
+	private final String component;
+
+	private final String identifier;
+
+	public ComponentCall(final String container, final String component) {
+		this.container = container;
+		this.component = component;
+
+		this.identifier = container + ',' + component;
+	}
+
+	public ComponentCall(final AbstractOperationCall<?> operationCall) {
+		this(operationCall.getContainer(), operationCall.getComponent());
+	}
+
+	public String getContainer() {
+		return container;
+	}
+
+	public String getComponent() {
+		return component;
+	}
+
+	public String getIdentifier() {
+		return identifier;
+	}
+
+}
diff --git a/src/main/java/kieker/analysis/domain/ComponentDependency.java b/src/main/java/kieker/analysis/domain/ComponentDependency.java
new file mode 100644
index 00000000..fc51d2f1
--- /dev/null
+++ b/src/main/java/kieker/analysis/domain/ComponentDependency.java
@@ -0,0 +1,45 @@
+package kieker.analysis.domain;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ComponentDependency {
+
+	private final Map<String, ComponentCall> components = new HashMap<>();
+
+	private final Map<String, ComponentDependencyRelation> relations = new HashMap<>();
+
+	// TODO this should not be part of the model
+	public void addCall(final AggregatedOperationCall operationCall) {
+
+		ComponentCall componentCall = new ComponentCall(operationCall);
+
+		if (!components.containsKey(componentCall.getIdentifier())) {
+			components.put(componentCall.getIdentifier(), componentCall);
+		}
+
+	}
+
+	public void addRelation(final OperationsDependencyRelation relation) {
+
+		String id1 = new ComponentCall(relation.getCaller()).getIdentifier();
+		String id2 = new ComponentCall(relation.getCallee()).getIdentifier();
+
+		String id = id1 + ',' + id2;
+
+		if (!relations.containsKey(id)) {
+			// components.put(id, new ComponentDependencyRelation(caller, callee)
+		}
+
+	}
+
+	public Collection<ComponentCall> getComponents() {
+		return components.values();
+	}
+
+	public Collection<ComponentDependencyRelation> getRelations() {
+		return relations.values();
+	}
+
+}
diff --git a/src/main/java/kieker/analysis/domain/ComponentDependencyRelation.java b/src/main/java/kieker/analysis/domain/ComponentDependencyRelation.java
new file mode 100644
index 00000000..17d14742
--- /dev/null
+++ b/src/main/java/kieker/analysis/domain/ComponentDependencyRelation.java
@@ -0,0 +1,43 @@
+package kieker.analysis.domain;
+
+public class ComponentDependencyRelation {
+
+	private final ComponentCall caller;
+
+	private final ComponentCall callee;
+
+	private int calls;
+
+	private int failuredCalls;
+
+	public ComponentDependencyRelation(final ComponentCall caller, final ComponentCall callee) {
+		this.caller = caller;
+		this.callee = callee;
+	}
+
+	public ComponentCall getCaller() {
+		return caller;
+	}
+
+	public ComponentCall getCallee() {
+		return callee;
+	}
+
+	public void addCalls(final int calls) {
+		this.calls += calls;
+	}
+
+	public void addFailuredCalls(final int failuredCalls) {
+		addCalls(failuredCalls);
+		this.failuredCalls += failuredCalls;
+	}
+
+	public int getCalls() {
+		return calls;
+	}
+
+	public int getFailuredCalls() {
+		return failuredCalls;
+	}
+
+}
diff --git a/src/main/java/kieker/analysis/domain/OperationsDependency.java b/src/main/java/kieker/analysis/domain/OperationsDependency.java
index 19ff6261..41fd8758 100644
--- a/src/main/java/kieker/analysis/domain/OperationsDependency.java
+++ b/src/main/java/kieker/analysis/domain/OperationsDependency.java
@@ -27,6 +27,7 @@ public class OperationsDependency {
 		addRelation(call);
 	}
 
+	// TODO this should not be part of the model
 	private void addOperation(final AggregatedOperationCall call) {
 		String key = call.getIdentifier();
 
-- 
GitLab