diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/DotComponentsDependencyExportStage.java b/src/main/java/kieker/analysis/dev/dependencygraphs/DotComponentsDependencyExportStage.java index e8f40c97d91ec600cc40fba1b85d47a8037dffc5..cde67826fc16fb4a2c1c5e2a36198e2dddd9ce29 100644 --- a/src/main/java/kieker/analysis/dev/dependencygraphs/DotComponentsDependencyExportStage.java +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/DotComponentsDependencyExportStage.java @@ -1,6 +1,9 @@ package kieker.analysis.dev.dependencygraphs; +import java.util.ArrayList; +import java.util.List; import java.util.function.Function; +import java.util.stream.Collectors; import kieker.analysis.util.graph.Vertex; import kieker.analysis.util.graph.export.dot.DotFileWriterStage; @@ -23,30 +26,47 @@ public class DotComponentsDependencyExportStage extends DotFileWriterStage { // this.exportConfiguration.addNodeAttribute(DotNodeAttribute.LABEL, new PropertyMapper("calls")); } - // TODO Consider if nested class is useful - + // TODO Make public and not nested, join with the other vertex mappers private class ComponentVertexMapper implements Function<Vertex, String> { @Override public String apply(final Vertex vertex) { - // TODO missing temporal unit final StringBuilder statistics = new StringBuilder(); statistics.append("<<deployment component>>\\n"); statistics.append(vertex.getProperty("Name").toString()); - statistics.append("\\n min: "); - statistics.append(vertex.getProperty("MinDuration").toString()); - statistics.append("xs, max: "); - statistics.append(vertex.getProperty("MaxDuration").toString()); - statistics.append("xs, total: "); - statistics.append(vertex.getProperty("TotalDuration").toString()); - statistics.append("xs, \\n avg: "); - statistics.append(vertex.getProperty("MeanDuration").toString()); - statistics.append("xs, median: "); - statistics.append(vertex.getProperty("MedianDuration").toString()); - statistics.append("xs"); + statistics.append("\\n"); + statistics.append(generateStatistics(vertex)); return statistics.toString(); } + private String generateStatistics(final Vertex vertex) { + final String temporalUnit = "xs"; // TODO temp + final List<String> statisticStrings = new ArrayList<>(5); + if (vertex.getProperty("MinDuration") != null) { + statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MaxDuration") != null) { + statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit); + } + if (vertex.getProperty("TotalDuration") != null) { + statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MeanDuration") != null) { + statisticStrings.add("avg: " + vertex.getProperty("MeanDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MedianDuration") != null) { + statisticStrings.add("med: " + vertex.getProperty("MedianDuration").toString() + temporalUnit); + } + + // If there are more than 3 statistics elements add a line break after the 3rd last + if (statisticStrings.size() > 3) { + final int thirdLast = statisticStrings.size() - 3; + statisticStrings.set(thirdLast, statisticStrings.get(thirdLast).concat("\\n")); + } + + return statisticStrings.stream().collect(Collectors.joining(", ")); + } + } private class ClusterMapper implements Function<Vertex, String> { diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/DotContainersDependencyExportStage.java b/src/main/java/kieker/analysis/dev/dependencygraphs/DotContainersDependencyExportStage.java index b7dd6439b42f89f10b4947dc6ccfbc2733bd1839..c64c1bc33f830f88e59596cb30d9f4d57b8b60c8 100644 --- a/src/main/java/kieker/analysis/dev/dependencygraphs/DotContainersDependencyExportStage.java +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/DotContainersDependencyExportStage.java @@ -1,6 +1,9 @@ package kieker.analysis.dev.dependencygraphs; +import java.util.ArrayList; +import java.util.List; import java.util.function.Function; +import java.util.stream.Collectors; import kieker.analysis.util.graph.Vertex; import kieker.analysis.util.graph.export.dot.DotFileWriterStage; @@ -23,30 +26,47 @@ public class DotContainersDependencyExportStage extends DotFileWriterStage { // this.exportConfiguration.addNodeAttribute(DotNodeAttribute.LABEL, new PropertyMapper("calls")); } - // TODO Consider if nested class is useful - + // TODO Make public and not nested, join with the other vertex mappers private class ContainerVertexMapper implements Function<Vertex, String> { @Override public String apply(final Vertex vertex) { - // TODO missing temporal unit final StringBuilder statistics = new StringBuilder(); statistics.append("<<execution container>>\\n"); statistics.append(vertex.getProperty("Name").toString()); - statistics.append("\\n min: "); - statistics.append(vertex.getProperty("MinDuration").toString()); - statistics.append("xs, max: "); - statistics.append(vertex.getProperty("MaxDuration").toString()); - statistics.append("xs, total: "); - statistics.append(vertex.getProperty("TotalDuration").toString()); - statistics.append("xs, \\n avg: "); - statistics.append(vertex.getProperty("MeanDuration").toString()); - statistics.append("xs, median: "); - statistics.append(vertex.getProperty("MedianDuration").toString()); - statistics.append("xs"); + statistics.append("\\n"); + statistics.append(generateStatistics(vertex)); return statistics.toString(); } + private String generateStatistics(final Vertex vertex) { + final String temporalUnit = "xs"; // TODO temp + final List<String> statisticStrings = new ArrayList<>(5); + if (vertex.getProperty("MinDuration") != null) { + statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MaxDuration") != null) { + statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit); + } + if (vertex.getProperty("TotalDuration") != null) { + statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MeanDuration") != null) { + statisticStrings.add("avg: " + vertex.getProperty("MeanDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MedianDuration") != null) { + statisticStrings.add("med: " + vertex.getProperty("MedianDuration").toString() + temporalUnit); + } + + // If there are more than 3 statistics elements add a line break after the 3rd last + if (statisticStrings.size() > 3) { + final int thirdLast = statisticStrings.size() - 3; + statisticStrings.set(thirdLast, statisticStrings.get(thirdLast).concat("\\n")); + } + + return statisticStrings.stream().collect(Collectors.joining(", ")); + } + } // Not used in this class diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/DotOperationsDependencyExportStage.java b/src/main/java/kieker/analysis/dev/dependencygraphs/DotOperationsDependencyExportStage.java index 323a8a45da4d6c51091617e0a9d16d44ddc553ef..b5b8ebc17d808b378471721c718d66b59dc694f5 100644 --- a/src/main/java/kieker/analysis/dev/dependencygraphs/DotOperationsDependencyExportStage.java +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/DotOperationsDependencyExportStage.java @@ -1,6 +1,9 @@ package kieker.analysis.dev.dependencygraphs; +import java.util.ArrayList; +import java.util.List; import java.util.function.Function; +import java.util.stream.Collectors; import kieker.analysis.util.graph.Vertex; import kieker.analysis.util.graph.export.dot.DotFileWriterStage; @@ -23,29 +26,46 @@ public class DotOperationsDependencyExportStage extends DotFileWriterStage { // this.exportConfiguration.addNodeAttribute(DotNodeAttribute.LABEL, new PropertyMapper("calls")); } - // TODO Consider if nested class is useful - + // TODO Make public and not nested, join with the other vertex mappers private class OperationVertexMapper implements Function<Vertex, String> { @Override public String apply(final Vertex vertex) { - // TODO missing temporal unit final StringBuilder statistics = new StringBuilder(); statistics.append(vertex.getProperty("Name").toString()); - statistics.append("\\n min: "); - statistics.append(vertex.getProperty("MinDuration").toString()); - statistics.append("xs, max: "); - statistics.append(vertex.getProperty("MaxDuration").toString()); - statistics.append("xs, total: "); - statistics.append(vertex.getProperty("TotalDuration").toString()); - statistics.append("xs, \\n avg: "); - statistics.append(vertex.getProperty("MeanDuration").toString()); - statistics.append("xs, median: "); - statistics.append(vertex.getProperty("MedianDuration").toString()); - statistics.append("xs"); + statistics.append("\\n"); + statistics.append(generateStatistics(vertex)); return statistics.toString(); } + private String generateStatistics(final Vertex vertex) { + final String temporalUnit = "xs"; // TODO temp + final List<String> statisticStrings = new ArrayList<>(5); + if (vertex.getProperty("MinDuration") != null) { + statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MaxDuration") != null) { + statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit); + } + if (vertex.getProperty("TotalDuration") != null) { + statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MeanDuration") != null) { + statisticStrings.add("avg: " + vertex.getProperty("MeanDuration").toString() + temporalUnit); + } + if (vertex.getProperty("MedianDuration") != null) { + statisticStrings.add("med: " + vertex.getProperty("MedianDuration").toString() + temporalUnit); + } + + // If there are more than 3 statistics elements add a line break after the 3rd last + if (statisticStrings.size() > 3) { + final int thirdLast = statisticStrings.size() - 3; + statisticStrings.set(thirdLast, statisticStrings.get(thirdLast).concat("\\n")); + } + + return statisticStrings.stream().collect(Collectors.joining(", ")); + } + } private class ClusterMapper implements Function<Vertex, String> {