Skip to content
Snippets Groups Projects
Commit 41da0b35 authored by Sören Henning's avatar Sören Henning
Browse files

added SystemEntitySet

parent 12879c34
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
Pipeline #
package kieker.analysis.dev;
import kieker.analysis.domain.AggregatedOperationCall;
import kieker.analysis.domain.OperationsDependency;
import kieker.analysis.domain.systemdependency.SoftwareSystem;
import kieker.analysis.trace.traversal.OperationCallVisitor;
public class DependencyCreator extends OperationCallVisitor<AggregatedOperationCall> {
private final OperationsDependency operationsDependency;
private final SoftwareSystem softwareSystem;
public DependencyCreator(final OperationsDependency operationsDependency) {
this.operationsDependency = operationsDependency;
public DependencyCreator(final SoftwareSystem softwareSystem) {
this.softwareSystem = softwareSystem;
}
@Override
public void visit(final AggregatedOperationCall operationCall) {
operationsDependency.addCall(operationCall);
// softwareSystem.getContainers().contains()
// ist container in software system?
// softwareSystem.getContainers().add(e)
// wenn nein -> hinzufügen
// getContainer
// ist component in container?
// wenn nein -> hinzufügen
// getComponent
// ist operation in component?
// wenn nein -> hinzufügen
// getOperation
// Jetzt die Dependencies eintragen
}
public OperationsDependency getOperationsDependency() {
return operationsDependency;
public SoftwareSystem getSoftwareSystem() {
return softwareSystem;
}
}
package kieker.analysis.domain.systemdependency;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class Component extends SystemEntity {
private final Container container;
private final Map<String, Operation> operations = new HashMap<>();
private final SystemEntitySet<Operation> operations = new SystemEntitySet<>();
public Component(final String name, final Container container) {
super(name, container.getIdentifier() + ',' + name);
this.container = container;
container.addComponent(this);
container.getComponents().add(this);
}
public Container getContainer() {
return container;
}
public Collection<Operation> getOperations() {
return operations.values();
}
protected void addOperation(final Operation operation) {
this.operations.put(operation.getName(), operation);
public SystemEntitySet<Operation> getOperations() {
return operations;
}
}
package kieker.analysis.domain.systemdependency;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class Container extends SystemEntity {
private final Map<String, Component> components = new HashMap<>();
private final SystemEntitySet<Component> components = new SystemEntitySet<>();
public Container(final String name) {
super(name, name);
}
public Collection<Component> getComponents() {
return components.values();
}
protected void addComponent(final Component component) {
this.components.put(component.getName(), component);
public SystemEntitySet<Component> getComponents() {
return components;
}
}
......@@ -7,7 +7,7 @@ public class Operation extends SystemEntity {
public Operation(final String name, final Component component) {
super(name, component.getIdentifier() + ',' + name);
this.component = component;
component.addOperation(this);
component.getOperations().add(this);
}
public Component getComponent() {
......
......@@ -2,12 +2,11 @@ package kieker.analysis.domain.systemdependency;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class SoftwareSystem {
private final Map<String, Container> containers = new HashMap<>();
private final SystemEntitySet<Container> containers = new SystemEntitySet<>();
private Collection<Dependency<Container>> containerDependencies = new ArrayList<>();
private Collection<Dependency<Component>> componentDependencies = new ArrayList<>();
......@@ -15,12 +14,8 @@ public class SoftwareSystem {
public SoftwareSystem() {}
public Collection<Container> getContainers() {
return containers.values();
}
public void addContainer(final Container container) {
containers.put(container.getName(), container);
public Set<Container> getContainers() {
return containers;
}
public Collection<Dependency<Container>> getContainerDependencies() {
......
package kieker.analysis.domain.systemdependency;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class SystemEntitySet<E extends SystemEntity> implements Set<E> {
private final Map<String, E> entries;
public SystemEntitySet() {
this.entries = new HashMap<>();
}
@Override
public int size() {
return entries.size();
}
@Override
public boolean isEmpty() {
return entries.isEmpty();
}
@Override
public boolean contains(final Object o) {
return this.entries.containsValue(o);
}
@Override
public Iterator<E> iterator() {
return this.entries.values().iterator();
}
@Override
public Object[] toArray() {
return this.entries.values().toArray();
}
@Override
public <T> T[] toArray(final T[] a) {
return this.entries.values().toArray(a);
}
@Override
public boolean add(final E e) {
if (this.entries.containsKey(e)) {
return false;
}
this.entries.put(e.getName(), e);
return true;
}
@Override
public boolean remove(final Object o) {
return this.entries.values().remove(o);
}
@Override
public boolean containsAll(final Collection<?> c) {
return this.entries.values().containsAll(c);
}
@Override
public boolean addAll(final Collection<? extends E> c) {
return c.stream().map(e -> add(e)).reduce(false, (r, s) -> r || s);
}
@Override
public boolean removeAll(final Collection<?> c) {
return this.entries.values().removeAll(c);
}
@Override
public boolean retainAll(final Collection<?> c) {
return this.entries.values().retainAll(c);
}
@Override
public void clear() {
this.entries.clear();
}
public E getByName(final String name) {
return this.entries.get(name);
}
public boolean containsByName(final Object o) {
return this.entries.containsKey(o);
}
public boolean removeByName(final Object o) {
return this.entries.keySet().remove(o);
}
public boolean containsAllByName(final Collection<?> c) {
return this.entries.keySet().containsAll(c);
}
public boolean removeAllByName(final Collection<?> c) {
return this.entries.keySet().removeAll(c);
}
public boolean retainAllByName(final Collection<?> c) {
return this.entries.keySet().retainAll(c);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment