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

Refactored to accomondate AllocationTableProvider

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



Signed-off-by: default avatarEddie Groh <groh@fortiss.org>
parent d4b5501e
No related branches found
No related tags found
1 merge request!210Setting up Metric extraction plugin for AF3 : Issue 4310
...@@ -28,7 +28,9 @@ import static org.fortiss.tooling.kernel.ui.util.SelectionUtils.checkAndPickFirs ...@@ -28,7 +28,9 @@ import static org.fortiss.tooling.kernel.ui.util.SelectionUtils.checkAndPickFirs
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType; import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
...@@ -52,6 +54,7 @@ import org.fortiss.tooling.spiderchart.style.ChartStyle; ...@@ -52,6 +54,7 @@ import org.fortiss.tooling.spiderchart.style.ChartStyle;
import org.fortiss.tooling.spiderchart.style.DataSeriesStyle; import org.fortiss.tooling.spiderchart.style.DataSeriesStyle;
import org.fortiss.tooling.spiderchart.style.LegendStyle; import org.fortiss.tooling.spiderchart.style.LegendStyle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.chart.PieChart; import javafx.scene.chart.PieChart;
...@@ -171,6 +174,17 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan ...@@ -171,6 +174,17 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan
// topLabel.setText("Text"); // topLabel.setText("Text");
Set<MetricKey> validKeys = new HashSet<>();
validKeys.addAll(node.getStoredDoubles().keySet());
validKeys.addAll(node.getStoredIntegers().keySet());
ObservableList<MetricKey> choices = choiceBox.getItems();
choices.retainAll(validKeys);
for(MetricKey key : validKeys) {
if(!choices.contains(key)) {
choices.add(key);
}
}
if(!node.getChildren().isEmpty()) { if(!node.getChildren().isEmpty()) {
if(choiceBox.getValue() != null) { if(choiceBox.getValue() != null) {
......
...@@ -57,6 +57,11 @@ public enum MetricKey { ...@@ -57,6 +57,11 @@ public enum MetricKey {
/** How many constraints this element violates with severity warning */ /** How many constraints this element violates with severity warning */
CONSTRAINT_VIOLATIONS_WARNING(false), CONSTRAINT_VIOLATIONS_WARNING(false),
/** Number of allocated components to this task */
TASK_ALLOCATED_COMPONENTS(false),
/** How many constraints this element violates with severity warning */
HARDWARE_ALLOCATED_TASKS(false),
// //
// Metrics which are collected over all children nodes // Metrics which are collected over all children nodes
// //
......
...@@ -18,6 +18,7 @@ package org.fortiss.tooling.ext.quality.service; ...@@ -18,6 +18,7 @@ package org.fortiss.tooling.ext.quality.service;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -110,33 +111,42 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider ...@@ -110,33 +111,42 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
@Override @Override
public void performMetricAnalysis(ITopLevelElement topLvl) { public void performMetricAnalysis(ITopLevelElement topLvl) {
for(IProjectRootElement rootElement : EcoreUtils // Sort root elements, as some metrics are saved into trees from other root elements
.getChildrenWithType(topLvl.getRootModelElement(), IProjectRootElement.class)) { // To avoid these problems, the elements have to be processed in a certain order
if(rootElement instanceof IHierarchicElement) {
EList<IHierarchicElement> elements = // Currently the only element affected by this is the allocation table which
((IHierarchicElement)rootElement).getContainedElements(); List<IProjectRootElement> rootElements = new ArrayList<>();
if(elements.isEmpty()) { rootElements.addAll(EcoreUtils.getChildrenWithType(topLvl.getRootModelElement(),
continue; IProjectRootElement.class));
}
var root_nodes = metricDataManagerInstance.getRootNodes();
// Get first element, there should not be any other elements String allocationTableClassName =
IHierarchicElement firstElement = elements.get(0); "org.fortiss.af3.allocation.model.impl.AllocationTableCollectionImpl";
MetricTreeNode root_node = new MetricTreeNode();
recursivlyCollectMetrics(root_node, firstElement, 0);
root_nodes.put(rootElement, root_node);
} else {
var root_nodes = metricDataManagerInstance.getRootNodes(); Collections.sort(rootElements, (r1, r2) -> {
MetricTreeNode rootNode = new MetricTreeNode(); if(allocationTableClassName.equals(r1.getClass().getName())) {
return 1;
} else if(allocationTableClassName.equals(r2.getClass().getName())) {
return -1;
}
return 0;
});
for(IProjectRootElement rootElement : rootElements) {
var root_nodes = metricDataManagerInstance.getRootNodes();
MetricTreeNode rootNode = new MetricTreeNode();
if(rootElement instanceof IHierarchicElement) {
IHierarchicElement firstElement = (IHierarchicElement)rootElement;
recursivlyCollectMetrics(rootNode, firstElement, 0);
} else {
// Search for provider on ProjectRootElement // Search for provider on ProjectRootElement
collectMetrics(rootNode, rootElement); collectMetrics(rootNode, rootElement);
root_nodes.put(rootElement, rootNode);
metricDataManagerInstance.getTreeNodeLookupTable().put(rootElement, rootNode);
} }
root_nodes.put(rootElement, rootNode);
metricDataManagerInstance.getTreeNodeLookupTable().put(rootElement, rootNode);
} }
// Store all currently saved metrics to the csv // Store all currently saved metrics to the csv
CSVFileWriter.metricExtractionToCSV(metricDataManagerInstance.getRootNodes()); CSVFileWriter.metricExtractionToCSV(metricDataManagerInstance.getRootNodes());
...@@ -491,8 +501,8 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider ...@@ -491,8 +501,8 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
/** /**
* @param node * @param node
* to which the data is collected * to which the data is collected
* @param element * @param object
* element to collect the data from * object to collect the data from
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void collectMetrics(MetricTreeNode node, EObject object) { private void collectMetrics(MetricTreeNode node, EObject object) {
......
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