diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java index 47cd2a388e187f1332b60d596d0351448eefbfc1..4ffec83f3992bf5e19d770c67fe42d284ef2617c 100644 --- a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java +++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java @@ -28,7 +28,9 @@ import static org.fortiss.tooling.kernel.ui.util.SelectionUtils.checkAndPickFirs import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType; import java.text.DecimalFormat; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.viewers.ISelection; @@ -52,6 +54,7 @@ import org.fortiss.tooling.spiderchart.style.ChartStyle; import org.fortiss.tooling.spiderchart.style.DataSeriesStyle; import org.fortiss.tooling.spiderchart.style.LegendStyle; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.chart.PieChart; @@ -171,6 +174,17 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan // 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(choiceBox.getValue() != null) { diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java index ce669af353a930e4d1268ac889dbe2665b218915..827082829868ecd3554d0dc1b7ee4e60a4acd126 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java @@ -57,6 +57,11 @@ public enum MetricKey { /** How many constraints this element violates with severity warning */ 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 // diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java index 76b0927b066860f7486dcc1c154671870761b617..9ecfd81790ca08b68355903418fa1f136d35cef7 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java @@ -18,6 +18,7 @@ package org.fortiss.tooling.ext.quality.service; import static java.util.Collections.emptyList; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -110,33 +111,42 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider @Override public void performMetricAnalysis(ITopLevelElement topLvl) { - for(IProjectRootElement rootElement : EcoreUtils - .getChildrenWithType(topLvl.getRootModelElement(), IProjectRootElement.class)) { - if(rootElement instanceof IHierarchicElement) { + // Sort root elements, as some metrics are saved into trees from other root elements + // To avoid these problems, the elements have to be processed in a certain order - EList<IHierarchicElement> elements = - ((IHierarchicElement)rootElement).getContainedElements(); - if(elements.isEmpty()) { - continue; - } - var root_nodes = metricDataManagerInstance.getRootNodes(); + // Currently the only element affected by this is the allocation table which + List<IProjectRootElement> rootElements = new ArrayList<>(); + rootElements.addAll(EcoreUtils.getChildrenWithType(topLvl.getRootModelElement(), + IProjectRootElement.class)); - // Get first element, there should not be any other elements - IHierarchicElement firstElement = elements.get(0); - MetricTreeNode root_node = new MetricTreeNode(); - recursivlyCollectMetrics(root_node, firstElement, 0); - root_nodes.put(rootElement, root_node); - } else { + String allocationTableClassName = + "org.fortiss.af3.allocation.model.impl.AllocationTableCollectionImpl"; - var root_nodes = metricDataManagerInstance.getRootNodes(); - MetricTreeNode rootNode = new MetricTreeNode(); + Collections.sort(rootElements, (r1, r2) -> { + 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 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 CSVFileWriter.metricExtractionToCSV(metricDataManagerInstance.getRootNodes()); @@ -491,8 +501,8 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider /** * @param node * to which the data is collected - * @param element - * element to collect the data from + * @param object + * object to collect the data from */ @SuppressWarnings("unchecked") private void collectMetrics(MetricTreeNode node, EObject object) {