mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
uniqueness validation is now also supported by the validation rules editor
This commit is contained in:
@@ -107,6 +107,9 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
@FXML
|
@FXML
|
||||||
private CheckBox alphanumericRuleCheckBox;
|
private CheckBox alphanumericRuleCheckBox;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox uniqueRuleCheckBox;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Spinner<Integer> minLengthSpinner;
|
private Spinner<Integer> minLengthSpinner;
|
||||||
|
|
||||||
@@ -155,6 +158,9 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
@FXML
|
@FXML
|
||||||
private CheckBox enableGroovyRule;
|
private CheckBox enableGroovyRule;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox enableUniqueRule;
|
||||||
|
|
||||||
|
|
||||||
@Value("${fxml.smartcvs.validation.editor.view}")
|
@Value("${fxml.smartcvs.validation.editor.view}")
|
||||||
@Override
|
@Override
|
||||||
@@ -172,6 +178,7 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
initCheckBox(integerRuleCheckBox, enableIntegerRule);
|
initCheckBox(integerRuleCheckBox, enableIntegerRule);
|
||||||
initCheckBox(doublerRuleCheckBox, enableDoubleRule);
|
initCheckBox(doublerRuleCheckBox, enableDoubleRule);
|
||||||
initCheckBox(alphanumericRuleCheckBox, enableAlphanumericRule);
|
initCheckBox(alphanumericRuleCheckBox, enableAlphanumericRule);
|
||||||
|
initCheckBox(uniqueRuleCheckBox, enableUniqueRule);
|
||||||
initSpinner(minLengthSpinner, enableMinLengthRule);
|
initSpinner(minLengthSpinner, enableMinLengthRule);
|
||||||
initSpinner(maxLengthSpinner, enableMaxLengthRule);
|
initSpinner(maxLengthSpinner, enableMaxLengthRule);
|
||||||
initTextInputControl(dateformatRuleTextField, enableDateRule);
|
initTextInputControl(dateformatRuleTextField, enableDateRule);
|
||||||
@@ -214,6 +221,12 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), null);
|
validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableUniqueRule.isSelected()) {
|
||||||
|
validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), uniqueRuleCheckBox.isSelected());
|
||||||
|
} else {
|
||||||
|
validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), null);
|
||||||
|
}
|
||||||
|
|
||||||
if (enableDoubleRule.isSelected()) {
|
if (enableDoubleRule.isSelected()) {
|
||||||
validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), doublerRuleCheckBox.isSelected());
|
validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), doublerRuleCheckBox.isSelected());
|
||||||
} else {
|
} else {
|
||||||
@@ -289,6 +302,12 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
enableAlphanumericRule
|
enableAlphanumericRule
|
||||||
);
|
);
|
||||||
|
|
||||||
|
updateCheckBox(
|
||||||
|
uniqueRuleCheckBox,
|
||||||
|
validationConfiguration.getUniqueRuleFor(getSelectedColumn()),
|
||||||
|
enableUniqueRule
|
||||||
|
);
|
||||||
|
|
||||||
updateSpinner(
|
updateSpinner(
|
||||||
minLengthSpinner,
|
minLengthSpinner,
|
||||||
validationConfiguration.getMinLengthRuleFor(getSelectedColumn()),
|
validationConfiguration.getMinLengthRuleFor(getSelectedColumn()),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class ValidationConfiguration {
|
|||||||
headerConfiguration.setNames(headerNames);
|
headerConfiguration.setNames(headerNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getUniquenessRuleFor(String column) {
|
public Boolean getUniqueRuleFor(String column) {
|
||||||
return (Boolean)getValue(column, "unique");
|
return (Boolean)getValue(column, "unique");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +114,11 @@ public class ValidationConfiguration {
|
|||||||
setValue(column, value, "not empty");
|
setValue(column, value, "not empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUniqueRuleFor(String column, Boolean value) {
|
||||||
|
setValue(column, value, "unique");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setMinLengthRuleFor(String column, Integer value) {
|
public void setMinLengthRuleFor(String column, Integer value) {
|
||||||
setValue(column, value == null ? null : value.doubleValue(), "minlength");
|
setValue(column, value == null ? null : value.doubleValue(), "minlength");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import groovy.lang.Script;
|
|||||||
import org.codehaus.groovy.control.CompilationFailedException;
|
import org.codehaus.groovy.control.CompilationFailedException;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -112,7 +111,7 @@ public class Validator {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void checkUniqueness(String column, String value, Integer lineNumber, ValidationError error) {
|
private void checkUniqueness(String column, String value, Integer lineNumber, ValidationError error) {
|
||||||
if (validationConfig.getUniquenessRuleFor(column) != null && validationConfig.getUniquenessRuleFor(column)) {
|
if (validationConfig.getUniqueRuleFor(column) != null && validationConfig.getUniqueRuleFor(column)) {
|
||||||
HashMap<String, Integer> columnValueMap = uniquenessLookupTable.get(column);
|
HashMap<String, Integer> columnValueMap = uniquenessLookupTable.get(column);
|
||||||
columnValueMap = getColumnValueMap(column, columnValueMap);
|
columnValueMap = getColumnValueMap(column, columnValueMap);
|
||||||
Integer valueInLineNumber = columnValueMap.get(value);
|
Integer valueInLineNumber = columnValueMap.get(value);
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ validation.rule.label.groovy = groovy:
|
|||||||
validation.rules.active = active
|
validation.rules.active = active
|
||||||
validation.rules.name = rule
|
validation.rules.name = rule
|
||||||
validation.rules.value = value
|
validation.rules.value = value
|
||||||
|
validation.rule.label.unique = Unique in column:
|
||||||
|
|
||||||
dialog.validation.rules.title = Validation rules
|
dialog.validation.rules.title = Validation rules
|
||||||
dialog.validation.rules.header = Validation rules of column "{0}"
|
dialog.validation.rules.header = Validation rules of column "{0}"
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ validation.rule.label.groovy = groovy:
|
|||||||
validation.rules.active = Aktiv
|
validation.rules.active = Aktiv
|
||||||
validation.rules.name = Regel
|
validation.rules.name = Regel
|
||||||
validation.rules.value = Wert
|
validation.rules.value = Wert
|
||||||
|
validation.rule.label.unique = Einmalig in Spalte:
|
||||||
|
|
||||||
dialog.validation.rules.title = Pr\u00fcfregeln
|
dialog.validation.rules.title = Pr\u00fcfregeln
|
||||||
dialog.validation.rules.header = Pr\u00fcfregeln f\u00fcr die Spalte "{0}"
|
dialog.validation.rules.header = Pr\u00fcfregeln f\u00fcr die Spalte "{0}"
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.net.URL?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.CheckBox?>
|
<?import javafx.scene.control.CheckBox?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.Spinner?>
|
<?import javafx.scene.control.Spinner?>
|
||||||
<?import javafx.scene.control.TextArea?>
|
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
|
||||||
<?import org.fxmisc.richtext.CodeArea?>
|
<?import org.fxmisc.richtext.CodeArea?>
|
||||||
<?import java.net.URL?>
|
|
||||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.101" xmlns:fx="http://javafx.com/fxml/1">
|
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.101" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="50.0" prefWidth="50.0" />
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="50.0" prefWidth="50.0" />
|
||||||
@@ -31,41 +30,46 @@
|
|||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label text="%validation.rule.label.not_empty" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
<Label text="%validation.rule.label.not_empty" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
<Label text="%validation.rule.label.integer" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
<Label text="%validation.rule.label.integer" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
<Label text="%validation.rule.label.double" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
<Label text="%validation.rule.label.double" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
<Label text="%validation.rule.label.minlength" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
<Label text="%validation.rule.label.minlength" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||||
<Label text="%validation.rule.label.maxlength" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
<Label text="%validation.rule.label.maxlength" GridPane.columnIndex="1" GridPane.rowIndex="7" />
|
||||||
<Label text="%validation.rule.label.dateformat" GridPane.columnIndex="1" GridPane.rowIndex="7" />
|
<Label text="%validation.rule.label.dateformat" GridPane.columnIndex="1" GridPane.rowIndex="8" />
|
||||||
<Label text="%validation.rule.label.alphanumeric" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
<Label text="%validation.rule.label.alphanumeric" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
<Label text="%validation.rule.label.regexp" GridPane.columnIndex="1" GridPane.rowIndex="8" />
|
<Label text="%validation.rule.label.regexp" GridPane.columnIndex="1" GridPane.rowIndex="9" />
|
||||||
<Label text="%validation.rule.label.value_of" GridPane.columnIndex="1" GridPane.rowIndex="9" />
|
<Label text="%validation.rule.label.value_of" GridPane.columnIndex="1" GridPane.rowIndex="10" />
|
||||||
<Label text="%validation.rule.label.groovy" GridPane.columnIndex="1" GridPane.rowIndex="10" />
|
<Label text="%validation.rule.label.groovy" GridPane.columnIndex="1" GridPane.rowIndex="11" />
|
||||||
|
<Label text="%validation.rule.label.unique" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||||
|
<CheckBox fx:id="enableNotEmptyRule" mnemonicParsing="false" GridPane.rowIndex="1" />
|
||||||
<CheckBox fx:id="notEmptyRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
<CheckBox fx:id="notEmptyRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||||
|
<CheckBox fx:id="enableIntegerRule" mnemonicParsing="false" GridPane.rowIndex="2" />
|
||||||
<CheckBox fx:id="integerRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
<CheckBox fx:id="integerRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||||
|
<CheckBox fx:id="enableDoubleRule" mnemonicParsing="false" GridPane.rowIndex="3" />
|
||||||
<CheckBox fx:id="doublerRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
<CheckBox fx:id="doublerRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||||
|
<CheckBox fx:id="enableAlphanumericRule" mnemonicParsing="false" GridPane.rowIndex="4" />
|
||||||
<CheckBox fx:id="alphanumericRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
<CheckBox fx:id="alphanumericRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||||
<Spinner fx:id="minLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
<CheckBox fx:id="enableUniqueRule" mnemonicParsing="false" GridPane.rowIndex="5" />
|
||||||
<Spinner fx:id="maxLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
<CheckBox fx:id="uniqueRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||||
<TextField fx:id="dateformatRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="7" />
|
<CheckBox fx:id="enableMinLengthRule" mnemonicParsing="false" GridPane.rowIndex="6" />
|
||||||
<TextField fx:id="regexpRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="8" />
|
<Spinner fx:id="minLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
||||||
<TextField fx:id="valueOfRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="9" />
|
<CheckBox fx:id="enableMaxLengthRule" mnemonicParsing="false" GridPane.rowIndex="7" />
|
||||||
<CodeArea fx:id="groovyRuleTextArea" prefHeight="300.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="10" GridPane.rowSpan="2" />
|
<Spinner fx:id="maxLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="7" />
|
||||||
<CheckBox fx:id="enableNotEmptyRule" mnemonicParsing="false" GridPane.rowIndex="1" />
|
<CheckBox fx:id="enableDateRule" mnemonicParsing="false" GridPane.rowIndex="8" />
|
||||||
<CheckBox fx:id="enableIntegerRule" mnemonicParsing="false" GridPane.rowIndex="2" />
|
<TextField fx:id="dateformatRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="8" />
|
||||||
<CheckBox fx:id="enableDoubleRule" mnemonicParsing="false" GridPane.rowIndex="3" />
|
<CheckBox fx:id="enableRegexpRule" mnemonicParsing="false" GridPane.rowIndex="9" />
|
||||||
<CheckBox fx:id="enableAlphanumericRule" mnemonicParsing="false" GridPane.rowIndex="4" />
|
<TextField fx:id="regexpRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="9" />
|
||||||
<CheckBox fx:id="enableMinLengthRule" mnemonicParsing="false" GridPane.rowIndex="5" />
|
<CheckBox fx:id="enableValueOfRule" mnemonicParsing="false" GridPane.rowIndex="10" />
|
||||||
<CheckBox fx:id="enableMaxLengthRule" mnemonicParsing="false" GridPane.rowIndex="6" />
|
<TextField fx:id="valueOfRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="10" />
|
||||||
<CheckBox fx:id="enableDateRule" mnemonicParsing="false" GridPane.rowIndex="7" />
|
<CheckBox fx:id="enableGroovyRule" mnemonicParsing="false" GridPane.rowIndex="11" />
|
||||||
<CheckBox fx:id="enableRegexpRule" mnemonicParsing="false" GridPane.rowIndex="8" />
|
<CodeArea fx:id="groovyRuleTextArea" prefHeight="300.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="11" GridPane.rowSpan="2" />
|
||||||
<CheckBox fx:id="enableValueOfRule" mnemonicParsing="false" GridPane.rowIndex="9" />
|
|
||||||
<CheckBox fx:id="enableGroovyRule" mnemonicParsing="false" GridPane.rowIndex="10" />
|
|
||||||
<Label style="-fx-font-weight: bold;" text="%validation.rules.active" />
|
<Label style="-fx-font-weight: bold;" text="%validation.rules.active" />
|
||||||
<Label style="-fx-font-weight: bold;" text="%validation.rules.name" GridPane.columnIndex="1" />
|
<Label style="-fx-font-weight: bold;" text="%validation.rules.name" GridPane.columnIndex="1" />
|
||||||
<Label style="-fx-font-weight: bold;" text="%validation.rules.value" GridPane.columnIndex="2" />
|
<Label style="-fx-font-weight: bold;" text="%validation.rules.value" GridPane.columnIndex="2" />
|
||||||
|
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user