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();
}
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);
}
}
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);
}
Aggregations