Skip to content
Snippets Groups Projects
Commit c4d52e97 authored by Eddie Groh's avatar Eddie Groh
Browse files

Added metrics for Entry and Exit Connectors

Issue-Ref: 4310
Issue-Url: af3#4310



Signed-off-by: default avatarEddie Groh <groh@fortiss.org>
parent c11f5484
No related branches found
No related tags found
1 merge request!210Setting up Metric extraction plugin for AF3 : Issue 4310
...@@ -166,8 +166,9 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No ...@@ -166,8 +166,9 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No
pieChart.getData().clear(); pieChart.getData().clear();
for(var child : node.getChildren()) { for(var child : node.getChildren()) {
PieChart.Data slice = new PieChart.Data(child.getName(), PieChart.Data slice =
child.getStoredMetrics().get(MetricKey.NUMBER_OF_TOTAL_PORTS)); new PieChart.Data(child.getName(), child.getStoredMetrics()
.get(MetricKey.NUMBER_OF_TOTAL_ENTRY_CONNECTORS));
pieChart.getData().add(slice); pieChart.getData().add(slice);
pieChart.setLegendVisible(false); pieChart.setLegendVisible(false);
pieChart.setTitle(""); pieChart.setTitle("");
...@@ -213,8 +214,9 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No ...@@ -213,8 +214,9 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No
} }
double maxval = children.stream() double maxval = children.stream()
.mapToDouble(p -> p.getStoredMetrics().get(MetricKey.NUMBER_OF_TOTAL_PORTS)).max() .mapToDouble(
.getAsDouble(); p -> p.getStoredMetrics().get(MetricKey.NUMBER_OF_TOTAL_EXIT_CONNECTORS))
.max().getAsDouble();
chartStyle.setUseIndividualAxisSegments(false); chartStyle.setUseIndividualAxisSegments(false);
chartStyle.setTitleStyle(new FontStyle("Verdana", 14, BLUE.brighter())); chartStyle.setTitleStyle(new FontStyle("Verdana", 14, BLUE.brighter()));
...@@ -229,7 +231,7 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No ...@@ -229,7 +231,7 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No
spiderChart.addAxis(testing); spiderChart.addAxis(testing);
elementData.setPoint(testing, elementData.setPoint(testing,
child.getStoredMetrics().get(MetricKey.NUMBER_OF_TOTAL_PORTS)); child.getStoredMetrics().get(MetricKey.NUMBER_OF_TOTAL_EXIT_CONNECTORS));
} }
spiderChart.addData(elementData); spiderChart.addData(elementData);
......
...@@ -18,12 +18,15 @@ package org.fortiss.tooling.ext.quality; ...@@ -18,12 +18,15 @@ package org.fortiss.tooling.ext.quality;
import java.util.Optional; import java.util.Optional;
import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EList;
import org.fortiss.tooling.base.model.base.EntryConnectorBase;
import org.fortiss.tooling.base.model.base.ExitConnectorBase;
import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.ext.quality.data.MetricDataManager; import org.fortiss.tooling.ext.quality.data.MetricDataManager;
import org.fortiss.tooling.ext.quality.data.MetricKey; import org.fortiss.tooling.ext.quality.data.MetricKey;
import org.fortiss.tooling.ext.quality.data.MetricTreeNode; import org.fortiss.tooling.ext.quality.data.MetricTreeNode;
import org.fortiss.tooling.kernel.model.IIdLabeled; import org.fortiss.tooling.kernel.model.IIdLabeled;
import org.fortiss.tooling.kernel.model.INamedCommentedElement; import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/** /**
* {@link IModelQualityProvider} to count the ratio of filled out comments of * {@link IModelQualityProvider} to count the ratio of filled out comments of
...@@ -107,21 +110,24 @@ public class HierarchicElementProvider implements IModelQualityProvider<IHierarc ...@@ -107,21 +110,24 @@ public class HierarchicElementProvider implements IModelQualityProvider<IHierarc
private void applyMetrics(MetricDataManager manager, MetricTreeNode node, private void applyMetrics(MetricDataManager manager, MetricTreeNode node,
IHierarchicElement currentElement) { IHierarchicElement currentElement) {
// TODO input ports number
// TODO output ports number
// EcoreUtils.pickInstanceOf(target, srcList)
var metrics = node.getStoredMetrics(); var metrics = node.getStoredMetrics();
metrics.put(MetricKey.UNQIUE_ID, (currentElement instanceof IIdLabeled) metrics.put(MetricKey.UNQIUE_ID, (currentElement instanceof IIdLabeled)
? ((IIdLabeled)currentElement).getId() : -1.0); ? ((IIdLabeled)currentElement).getId() : -1.0);
metrics.put(MetricKey.NUMBER_OF_PORTS, (double)currentElement.getConnectors().size());
var connectors = currentElement.getConnectors();
metrics.put(MetricKey.NUMBER_OF_CONNECTORS, (double)connectors.size());
metrics.put(MetricKey.NUMBER_OF_CONTAINED_ELEMENTS, metrics.put(MetricKey.NUMBER_OF_CONTAINED_ELEMENTS,
(double)currentElement.getContainedElements().size()); (double)currentElement.getContainedElements().size());
metrics.put(MetricKey.NUMBER_OF_CHANNELS, (double)currentElement.getConnections().size()); metrics.put(MetricKey.NUMBER_OF_CHANNELS, (double)currentElement.getConnections().size());
// depth metrics // depth metrics
metrics.put(MetricKey.NUMBER_OF_TOTAL_PORTS, (double)currentElement.getConnectors().size()); metrics.put(MetricKey.NUMBER_OF_TOTAL_CONNECTORS, (double)connectors.size());
var entry_connectors = EcoreUtils.pickInstanceOf(EntryConnectorBase.class, connectors);
var exit_connectors = EcoreUtils.pickInstanceOf(ExitConnectorBase.class, connectors);
metrics.put(MetricKey.NUMBER_OF_TOTAL_ENTRY_CONNECTORS, (double)entry_connectors.size());
metrics.put(MetricKey.NUMBER_OF_TOTAL_EXIT_CONNECTORS, (double)exit_connectors.size());
metrics.put(MetricKey.NUMBER_OF_TOTAL_ELEMENTS, 1.0); metrics.put(MetricKey.NUMBER_OF_TOTAL_ELEMENTS, 1.0);
metrics.put(MetricKey.NUMBER_OF_TOTAL_LEAF_ELEMENTS, metrics.put(MetricKey.NUMBER_OF_TOTAL_LEAF_ELEMENTS,
...@@ -132,8 +138,9 @@ public class HierarchicElementProvider implements IModelQualityProvider<IHierarc ...@@ -132,8 +138,9 @@ public class HierarchicElementProvider implements IModelQualityProvider<IHierarc
node.getChildren().add(child); node.getChildren().add(child);
apply(manager, child, containedElement); apply(manager, child, containedElement);
for(MetricKey key : new MetricKey[] {MetricKey.NUMBER_OF_TOTAL_PORTS, for(MetricKey key : new MetricKey[] {MetricKey.NUMBER_OF_TOTAL_CONNECTORS,
MetricKey.NUMBER_OF_TOTAL_ELEMENTS, MetricKey.NUMBER_OF_TOTAL_ENTRY_CONNECTORS,
MetricKey.NUMBER_OF_TOTAL_EXIT_CONNECTORS, MetricKey.NUMBER_OF_TOTAL_ELEMENTS,
MetricKey.NUMBER_OF_TOTAL_COMMENTABLE_ELEMENTS, MetricKey.NUMBER_OF_TOTAL_COMMENTABLE_ELEMENTS,
MetricKey.NUMBER_OF_TOTAL_COMMENTED_ELEMENTS, MetricKey.NUMBER_OF_TOTAL_COMMENTED_ELEMENTS,
MetricKey.NUMBER_OF_TOTAL_LEAF_ELEMENTS}) { MetricKey.NUMBER_OF_TOTAL_LEAF_ELEMENTS}) {
......
...@@ -28,7 +28,7 @@ public enum MetricKey { ...@@ -28,7 +28,7 @@ public enum MetricKey {
UNQIUE_ID, UNQIUE_ID,
/** Key for the metric counting ports */ /** Key for the metric counting ports */
NUMBER_OF_PORTS, NUMBER_OF_CONNECTORS,
/** Key for the metric counting elements */ /** Key for the metric counting elements */
NUMBER_OF_CONTAINED_ELEMENTS, NUMBER_OF_CONTAINED_ELEMENTS,
/** Key for the metric counting channels */ /** Key for the metric counting channels */
...@@ -36,7 +36,11 @@ public enum MetricKey { ...@@ -36,7 +36,11 @@ public enum MetricKey {
// Metrics which are collected over all children nodes // Metrics which are collected over all children nodes
/** Key for the metric counting the total amount of ports contained */ /** Key for the metric counting the total amount of ports contained */
NUMBER_OF_TOTAL_PORTS, NUMBER_OF_TOTAL_CONNECTORS,
/** Key for the metric counting the total amount of input ports contained */
NUMBER_OF_TOTAL_ENTRY_CONNECTORS,
/** Key for the metric counting the total amount of output ports contained */
NUMBER_OF_TOTAL_EXIT_CONNECTORS,
/** Key for the metric counting the total amount of elements contained */ /** Key for the metric counting the total amount of elements contained */
NUMBER_OF_TOTAL_ELEMENTS, NUMBER_OF_TOTAL_ELEMENTS,
/** Key for the metric counting the total amount of elements which can be commented */ /** Key for the metric counting the total amount of elements which can be commented */
......
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