Search in sources :

Example 1 with QualityCategory

use of au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory in project constellation by constellation-app.

the class QualityControlViewPane method showRuleDialog.

/**
 * Display a dialog containing all Rule objects registered with the Quality
 * Control View and which matched for a given identifier.
 *
 * @param owner The owner Node
 * @param identifier The identifier of the graph node being displayed.
 * @param rules The list of rules measured against this graph node.
 */
private static void showRuleDialog(final String identifier, final List<Pair<QualityCategory, String>> rules) {
    final ScrollPane sp = new ScrollPane();
    sp.setPrefHeight(512);
    sp.setPrefWidth(512);
    sp.setFitToWidth(true);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    final VBox vbox = new VBox();
    vbox.prefWidthProperty().bind(sp.widthProperty());
    vbox.setPadding(Insets.EMPTY);
    for (final Pair<QualityCategory, String> rule : rules) {
        final String[] t = rule.getValue().split("§");
        final String quality = rule.getKey().name();
        final String title = String.format("%s - %s", quality, t[0]);
        final Text content = new Text(t[1]);
        // Subtract a random number to avoid the vertical scrollbar.
        content.wrappingWidthProperty().bind(sp.widthProperty().subtract(16));
        final TitledPane tp = new TitledPane(title, content);
        tp.prefWidthProperty().bind(vbox.widthProperty());
        tp.setExpanded(false);
        tp.setWrapText(true);
        vbox.getChildren().add(tp);
    }
    if (CollectionUtils.isEmpty(rules)) {
        final Label noEntriesLabel = new Label(Bundle.MSG_NoEntries());
        vbox.getChildren().add(noEntriesLabel);
    }
    sp.setContent(vbox);
    final Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setHeaderText(String.format(Bundle.MSG_QualtyControlRules(), identifier));
    alert.getDialogPane().setContent(sp);
    alert.setResizable(true);
    alert.show();
}
Also used : TitledPane(javafx.scene.control.TitledPane) ScrollPane(javafx.scene.control.ScrollPane) QualityCategory(au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text) Alert(javafx.scene.control.Alert) VBox(javafx.scene.layout.VBox)

Example 2 with QualityCategory

use of au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory in project constellation by constellation-app.

the class QualityControlViewPane method showRuleDialog.

/**
 * Display a dialog containing all Rule objects registered with the Quality
 * Control View and which matched for a given QualityControlEvent.
 *
 * @param owner
 * @param qcevent
 */
private static void showRuleDialog(final TableCell<QualityControlEvent, QualityControlEvent> qcevent) {
    if (qcevent.getItem() != null) {
        final int vxId = qcevent.getItem().getVertex();
        final String identifier = qcevent.getItem().getIdentifier();
        final List<Pair<QualityCategory, String>> rules = new ArrayList<>();
        for (final QualityControlRule rule : qcevent.getItem().getRules()) {
            // Hack the name and explanation together to obviate the need for another data structure.
            final String ruleName = rule.getName() + "§" + rule.getDescription();
            final QualityCategory quality = rule.getResults().contains(vxId) ? getPriorities().get(rule) : null;
            if (quality != null) {
                rules.add(new Pair<>(quality, ruleName));
            }
        }
        Collections.sort(rules, (p1, p2) -> {
            final int compare = QualityControlRule.testPriority(p1.getKey(), p2.getKey());
            return compare == 0 ? p1.getValue().compareTo(p2.getValue()) : compare;
        });
        showRuleDialog(identifier, rules);
    }
}
Also used : QualityControlRule(au.gov.asd.tac.constellation.views.qualitycontrol.rules.QualityControlRule) QualityCategory(au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory) ArrayList(java.util.ArrayList) Pair(javafx.util.Pair)

Example 3 with QualityCategory

use of au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory in project constellation by constellation-app.

the class QualityControlViewPaneNGTest method testGetPriorities.

/**
 * Test of getPriorities method, of class QualityControlViewPane.
 */
@Test
public void testGetPriorities() {
    System.out.println("getPriorities");
    final Map<QualityControlRule, QualityCategory> result = QualityControlViewPane.getPriorities();
    assertEquals(result.size(), rules.size());
    for (final QualityControlRule rule : result.keySet()) {
        rule.clearResults();
    }
    final IdentifierInconsistentWithTypeRule iiRule = new IdentifierInconsistentWithTypeRule();
    final MissingTypeRule mRule = new MissingTypeRule();
    final UnknownTypeRule uRule = new UnknownTypeRule();
    assertEquals(result.get(iiRule), QualityCategory.MEDIUM);
    assertEquals(result.get(mRule), QualityCategory.SEVERE);
    assertEquals(result.get(uRule), QualityCategory.MINOR);
}
Also used : QualityControlRule(au.gov.asd.tac.constellation.views.qualitycontrol.rules.QualityControlRule) MissingTypeRule(au.gov.asd.tac.constellation.views.qualitycontrol.rules.MissingTypeRule) QualityCategory(au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory) IdentifierInconsistentWithTypeRule(au.gov.asd.tac.constellation.views.qualitycontrol.rules.IdentifierInconsistentWithTypeRule) UnknownTypeRule(au.gov.asd.tac.constellation.views.qualitycontrol.rules.UnknownTypeRule) Test(org.testng.annotations.Test)

Aggregations

QualityCategory (au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent.QualityCategory)3 QualityControlRule (au.gov.asd.tac.constellation.views.qualitycontrol.rules.QualityControlRule)2 IdentifierInconsistentWithTypeRule (au.gov.asd.tac.constellation.views.qualitycontrol.rules.IdentifierInconsistentWithTypeRule)1 MissingTypeRule (au.gov.asd.tac.constellation.views.qualitycontrol.rules.MissingTypeRule)1 UnknownTypeRule (au.gov.asd.tac.constellation.views.qualitycontrol.rules.UnknownTypeRule)1 ArrayList (java.util.ArrayList)1 Alert (javafx.scene.control.Alert)1 Label (javafx.scene.control.Label)1 ScrollPane (javafx.scene.control.ScrollPane)1 TitledPane (javafx.scene.control.TitledPane)1 VBox (javafx.scene.layout.VBox)1 Text (javafx.scene.text.Text)1 Pair (javafx.util.Pair)1 Test (org.testng.annotations.Test)1