mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
write values back to config
This commit is contained in:
@@ -50,6 +50,7 @@ import java.util.ResourceBundle;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static javafx.beans.binding.Bindings.when;
|
import static javafx.beans.binding.Bindings.when;
|
||||||
|
|
||||||
@@ -203,73 +204,129 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
this.validationConfiguration = validationConfiguration;
|
this.validationConfiguration = validationConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void changeFormatInput() {
|
||||||
|
switch (typeComboBox.getValue()) {
|
||||||
|
case STRING:
|
||||||
|
/*
|
||||||
|
default: any valid string.
|
||||||
|
email: A valid email address.
|
||||||
|
uri: A valid URI.
|
||||||
|
binary: A base64 encoded string representing binary data.
|
||||||
|
uuid: A string that is a uuid
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case NUMBER:
|
||||||
|
/*
|
||||||
|
decimalChar: A string whose value is used to represent a decimal point within the number. The default value is ".".
|
||||||
|
groupChar: A string whose value is used to group digits within the number. The default value is null. A common value is "," e.g. "100,000".
|
||||||
|
currency
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case DATE:
|
||||||
|
/*
|
||||||
|
default: An ISO8601 format string.
|
||||||
|
This MUST be in ISO8601 format YYYY-MM-DD
|
||||||
|
any: Any parsable representation of the type. The implementing library can attempt to parse the datetime via a range of strategies.
|
||||||
|
An example is dateutil.parser.parse from the python-dateutils library.
|
||||||
|
fmt:PATTERN: date/time values in this field conform to PATTERN where [PATTERN] follows the syntax of standard Python / C strptime.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case DATETIME:
|
||||||
|
/*
|
||||||
|
default: An ISO8601 format string.
|
||||||
|
datetime: a date-time. This MUST be in ISO 8601 format of YYYY-MM-DDThhssZ in UTC time
|
||||||
|
any: Any parsable representation of the type. The implementing library can attempt to parse the datetime via a range of strategies.
|
||||||
|
An example is dateutil.parser.parse from the python-dateutils library.
|
||||||
|
fmt:PATTERN: date/time values in this field conform to PATTERN where [PATTERN] follows the syntax of standard Python / C strptime.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case TIME:
|
||||||
|
/*
|
||||||
|
default: An ISO8601 format string.
|
||||||
|
time: a time without a date
|
||||||
|
any: Any parsable representation of the type. The implementing library can attempt to parse the datetime via a range of strategies.
|
||||||
|
An example is dateutil.parser.parse from the python-dateutils library.
|
||||||
|
fmt:PATTERN: date/time values in this field conform to PATTERN where [PATTERN] follows the syntax of standard Python / C strptime.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
// case GEOPOINT:
|
||||||
|
// /*
|
||||||
|
// default: A string of the pattern "lon, lat", where lon is the longitude and lat is the latitude.
|
||||||
|
// array: An array of exactly two items, where each item is either a number, or a string parsable as a number, and the first item is lon and the second item is lat.
|
||||||
|
// object: A JSON object with exactly two keys, lat and lon
|
||||||
|
// */
|
||||||
|
// break;
|
||||||
|
// case GEOJSON:
|
||||||
|
// /*
|
||||||
|
// default: A geojson object as per the GeoJSON spec.
|
||||||
|
// topojson: A topojson object as per the TopoJSON spec
|
||||||
|
// */
|
||||||
|
// case DURATION:
|
||||||
|
// case OBJECT:
|
||||||
|
// case ARRAY:
|
||||||
|
case INTEGER:
|
||||||
|
default:
|
||||||
|
// format: no options
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void updateConfiguration() {
|
public void updateConfiguration() {
|
||||||
|
|
||||||
// if (enableIntegerRule.isSelected()) {
|
FieldConfiguration config = validationConfiguration.getFieldConfiguration(getSelectedColumn());
|
||||||
// validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), enableIntegerRule.isSelected());
|
config.setType(typeComboBox.getValue());
|
||||||
// } else {
|
|
||||||
// validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), null);
|
if (enableGroovyRule.isSelected()) {
|
||||||
// }
|
config.setGroovy(groovyRuleTextArea.getText());
|
||||||
//
|
} else {
|
||||||
// if (enableNotEmptyRule.isSelected()) {
|
config.setGroovy(null);
|
||||||
// validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), enableNotEmptyRule.isSelected());
|
}
|
||||||
// } else {
|
|
||||||
// validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), null);
|
ConstraintsConfiguration constraints = config.getConstraints();
|
||||||
// }
|
if (constraints == null) {
|
||||||
//
|
constraints = new ConstraintsConfiguration();
|
||||||
// if (enableUniqueRule.isSelected()) {
|
}
|
||||||
// validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), enableUniqueRule.isSelected());
|
|
||||||
// } else {
|
|
||||||
// validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), null);
|
|
||||||
// }
|
|
||||||
//
|
if (enableNotEmptyRule.isSelected()) {
|
||||||
// if (enableDoubleRule.isSelected()) {
|
constraints.setRequired(enableNotEmptyRule.isSelected());
|
||||||
// validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), enableDoubleRule.isSelected());
|
} else {
|
||||||
// } else {
|
constraints.setRequired(null);
|
||||||
// validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), null);
|
}
|
||||||
// }
|
|
||||||
//
|
if (enableUniqueRule.isSelected()) {
|
||||||
// if (enableAlphanumericRule.isSelected()) {
|
constraints.setUnique(enableUniqueRule.isSelected());
|
||||||
// validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), enableAlphanumericRule.isSelected());
|
} else {
|
||||||
// } else {
|
constraints.setUnique(null);
|
||||||
// validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), null);
|
}
|
||||||
// }
|
|
||||||
//
|
if (enableMinLengthRule.isSelected()) {
|
||||||
// if (enableDateRule.isSelected()) {
|
constraints.setMinLength(minLengthSpinner.getValue());
|
||||||
// validationConfiguration.setDateRuleFor(selectedColumn.getValue(), dateformatRuleTextField.getText());
|
} else {
|
||||||
// } else {
|
constraints.setMinLength(null);
|
||||||
// validationConfiguration.setDateRuleFor(selectedColumn.getValue(), null);
|
}
|
||||||
// }
|
|
||||||
//
|
if (enableMaxLengthRule.isSelected()) {
|
||||||
// if (enableGroovyRule.isSelected()) {
|
constraints.setMaxLength(maxLengthSpinner.getValue());
|
||||||
// validationConfiguration.setGroovyRuleFor(selectedColumn.getValue(), groovyRuleTextArea.getText());
|
} else {
|
||||||
// } else {
|
constraints.setMaxLength(null);
|
||||||
// validationConfiguration.setGroovyRuleFor(selectedColumn.getValue(), null);
|
}
|
||||||
// }
|
|
||||||
//
|
if (enableRegexpRule.isSelected()) {
|
||||||
// if (enableMinLengthRule.isSelected()) {
|
constraints.setPattern(regexpRuleTextField.getText());
|
||||||
// validationConfiguration.setMinLengthRuleFor(selectedColumn.getValue(), minLengthSpinner.getValue());
|
} else {
|
||||||
// } else {
|
constraints.setPattern(null);
|
||||||
// validationConfiguration.setMinLengthRuleFor(selectedColumn.getValue(), null);
|
}
|
||||||
// }
|
|
||||||
//
|
if (enableValueOfRule.isSelected()) {
|
||||||
// if (enableMaxLengthRule.isSelected()) {
|
constraints.setEnumeration(asList(valueOfRuleTextField.getText().split(", ")));
|
||||||
// validationConfiguration.setMaxLengthRuleFor(selectedColumn.getValue(), maxLengthSpinner.getValue());
|
} else {
|
||||||
// } else {
|
constraints.setEnumeration(null);
|
||||||
// validationConfiguration.setMaxLengthRuleFor(selectedColumn.getValue(), null);
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (enableRegexpRule.isSelected()) {
|
|
||||||
// validationConfiguration.setRegexpRuleFor(selectedColumn.getValue(), regexpRuleTextField.getText());
|
|
||||||
// } else {
|
|
||||||
// validationConfiguration.setRegexpRuleFor(selectedColumn.getValue(), null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (enableValueOfRule.isSelected()) {
|
|
||||||
// validationConfiguration.setValueOfRuleFor(selectedColumn.getValue(), asList(valueOfRuleTextField.getText().split(", ")));
|
|
||||||
// } else {
|
|
||||||
// validationConfiguration.setValueOfRuleFor(selectedColumn.getValue(), null);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ public class FieldConfiguration {
|
|||||||
@SerializedName("date") DATE,
|
@SerializedName("date") DATE,
|
||||||
@SerializedName("datetime") DATETIME,
|
@SerializedName("datetime") DATETIME,
|
||||||
@SerializedName("time") TIME
|
@SerializedName("time") TIME
|
||||||
|
// TODO: currently not supported
|
||||||
|
// @SerializedName("object") OBJECT,
|
||||||
|
// @SerializedName("array") ARRAY,
|
||||||
|
// @SerializedName("duration") DURATION,
|
||||||
|
// @SerializedName("geopoint") GEOPOINT,
|
||||||
|
// @SerializedName("geojson") GEOJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
Reference in New Issue
Block a user