mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 21:48:22 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a37a84bd09 | ||
|
|
5100c668ab | ||
|
|
90bda028ec | ||
|
|
5e31f834ac | ||
|
|
d689423c61 | ||
|
|
9e8d71ca1d | ||
|
|
70855e614a | ||
| 4354afdf1d | |||
| 4002219dfe | |||
| 7723906935 | |||
| 5694273c51 | |||
| 04a54da798 | |||
| 6f635f5e75 | |||
| 742f129ea9 | |||
| 0c391e292e | |||
| cd0ca0ed11 | |||
| e799f0ac45 | |||
| 3664a4e8a7 | |||
| e87eec2162 | |||
| 3adfd566bc |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -74,3 +74,4 @@ crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
|
||||
|
||||
smartcsv.log
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SmartCSV.fx
|
||||
##Description
|
||||
A simple JavaFX application to load, save and edit a CSV file and provide a JSON configuration for columns to check the values in the columns.
|
||||
A simple JavaFX application to load, save and edit a CSV file and provide a [JSON Table Schema](http://specs.frictionlessdata.io/json-table-schema/) for columns to check the values in the columns.
|
||||
|
||||
##Motivation
|
||||
At work I have the need to fix wrong CSV files from customers. It is hard to find the errors and fix them in a texteditor,
|
||||
@@ -14,7 +14,7 @@ even in a "normal" CSV editor. So I decided to write this simple JavaFX applicat
|
||||
|
||||
[Wiki & Documentation](https://github.com/frosch95/SmartCSV.fx/wiki)
|
||||
|
||||
binary distribution of the [latest release (0.6)](https://github.com/frosch95/SmartCSV.fx/releases/download/0.6/SmartCSV.fx-0.6-SNAPSHOT.zip)
|
||||
binary distribution of the [latest release (0.8)](https://github.com/frosch95/SmartCSV.fx/releases/download/0.8/SmartCSV.fx-0.8-SNAPSHOT.zip)
|
||||
|
||||
##Talks
|
||||
[Introduction](http://javafx.ninja/talks/introduction/)
|
||||
@@ -23,7 +23,7 @@ binary distribution of the [latest release (0.6)](https://github.com/frosch95/Sm
|
||||
###The MIT License (MIT)
|
||||
|
||||
|
||||
Copyright (c) 2015 Andreas Billmann <andreas.billmann@javafx.ninja>
|
||||
Copyright (c) 2015-2016 Andreas Billmann <andreas.billmann@javafx.ninja>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
group 'ninja.javafx'
|
||||
version '0.7-SNAPSHOT'
|
||||
version '0.8-SNAPSHOT'
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'groovy'
|
||||
|
||||
2
license
2
license
@@ -1,7 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 Andreas Billmann <andreas.billmann@javafx.ninja>
|
||||
Copyright (c) 2015-2016 Andreas Billmann <andreas.billmann@javafx.ninja>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -51,13 +51,13 @@ public class ErrorExport extends Service {
|
||||
format(resourceBundle.getString("log.header.message"),
|
||||
csvFilename,
|
||||
Integer.toString(model.getValidationError().size()))).append("\n\n");
|
||||
for (ValidationError error:model.getValidationError()) {
|
||||
model.getValidationError().forEach(error ->
|
||||
log.append(
|
||||
format(resourceBundle.getString("log.message"),
|
||||
error.getLineNumber().toString(),
|
||||
error.getColumn(),
|
||||
getI18nValidatioMessage(resourceBundle, error))).append("\n");
|
||||
}
|
||||
getI18nValidatioMessage(resourceBundle, error))).append("\n")
|
||||
);
|
||||
Files.write(file.toPath(), log.toString().getBytes());
|
||||
|
||||
} catch (Throwable ex) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -56,7 +56,7 @@ import ninja.javafx.smartcsv.fx.util.SaveFileService;
|
||||
import ninja.javafx.smartcsv.fx.validation.ValidationEditorController;
|
||||
import ninja.javafx.smartcsv.preferences.PreferencesFileReader;
|
||||
import ninja.javafx.smartcsv.preferences.PreferencesFileWriter;
|
||||
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
import ninja.javafx.smartcsv.validation.ValidationFileReader;
|
||||
import ninja.javafx.smartcsv.validation.ValidationFileWriter;
|
||||
@@ -207,8 +207,10 @@ public class SmartCSVController extends FXMLController {
|
||||
private TableView<CSVRow> tableView;
|
||||
private ErrorSideBar errorSideBar;
|
||||
private ResourceBundle resourceBundle;
|
||||
private CSVFileReader csvFileReader = new CSVFileReader();
|
||||
private CSVFileWriter csvFileWriter = new CSVFileWriter();
|
||||
|
||||
private FileStorage<CSVModel> currentCsvFile = new FileStorage<>(new CSVFileReader(), new CSVFileWriter());
|
||||
private FileStorage<CSVModel> currentCsvFile = new FileStorage<>(csvFileReader, csvFileWriter);
|
||||
private FileStorage<ValidationConfiguration> currentConfigFile = new FileStorage<>(new ValidationFileReader(), new ValidationFileWriter());
|
||||
private FileStorage<CsvPreference> csvPreferenceFile = new FileStorage<>(new PreferencesFileReader(), new PreferencesFileWriter());
|
||||
|
||||
@@ -423,6 +425,7 @@ public class SmartCSVController extends FXMLController {
|
||||
|
||||
public void showValidationEditor(String column) {
|
||||
validationEditorController.setSelectedColumn(column);
|
||||
validationEditorController.updateForm();
|
||||
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
alert.setGraphic(null);
|
||||
@@ -520,6 +523,9 @@ public class SmartCSVController extends FXMLController {
|
||||
|
||||
private void setCsvPreference(CsvPreference csvPreference) {
|
||||
preferencesController.setCsvPreference(csvPreference);
|
||||
csvFileReader.setCsvPreference(csvPreference);
|
||||
csvFileWriter.setCsvPreference(csvPreference);
|
||||
|
||||
}
|
||||
|
||||
private void loadFile(String filterText,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -137,9 +137,7 @@ public class ErrorSideBar extends Region {
|
||||
|
||||
int rows = model.get().getRows().size();
|
||||
double space = (double)heightWithoutStatusBlock() / rows;
|
||||
for (ValidationError error : errorList) {
|
||||
errorMarkerList.add(generateErrorMarker(space, error));
|
||||
}
|
||||
errorList.forEach(error -> errorMarkerList.add(generateErrorMarker(space, error)));
|
||||
}
|
||||
}
|
||||
getChildren().setAll(errorMarkerList);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@ package ninja.javafx.smartcsv.fx.table.model;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import ninja.javafx.smartcsv.validation.RevalidationService;
|
||||
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
import ninja.javafx.smartcsv.validation.Validator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -43,9 +43,8 @@ public class I18nValidationUtil {
|
||||
public static String getI18nValidatioMessage(ResourceBundle resourceBundle, List<ValidationError> errors) {
|
||||
|
||||
StringWriter message = new StringWriter();
|
||||
for (ValidationError validationError: errors) {
|
||||
message.append(getI18nValidatioMessage(resourceBundle, validationError)).append("\n");
|
||||
}
|
||||
errors.forEach(error -> message.append(getI18nValidatioMessage(resourceBundle, error)).append("\n"));
|
||||
|
||||
|
||||
if (message.toString().length() != 0) {
|
||||
return cutOffLastLineBreak(message.toString());
|
||||
@@ -66,7 +65,7 @@ public class I18nValidationUtil {
|
||||
|
||||
List<ValidationMessage> validationMessages = error.getMessages();
|
||||
StringWriter message = new StringWriter();
|
||||
for (ValidationMessage validationMessage: validationMessages) {
|
||||
validationMessages.forEach(validationMessage -> {
|
||||
message.append(prefix);
|
||||
if (resourceBundle.containsKey(validationMessage.getKey())) {
|
||||
String resourceText = resourceBundle.getString(validationMessage.getKey());
|
||||
@@ -78,7 +77,7 @@ public class I18nValidationUtil {
|
||||
} else {
|
||||
message.append(validationMessage.getKey()).append("\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!validationMessages.isEmpty()) {
|
||||
return cutOffLastLineBreak(message.toString());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.fx.validation;
|
||||
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.util.Callback;
|
||||
import ninja.javafx.smartcsv.validation.configuration.StringFormat;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* cell factory for string formats
|
||||
*/
|
||||
public class StringFormatEditorCellFactory implements Callback<ListView<StringFormat>, ListCell<StringFormat>> {
|
||||
|
||||
private ResourceBundle resourceBundle;
|
||||
|
||||
public StringFormatEditorCellFactory(ResourceBundle resourceBundle) {
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListCell<StringFormat> call(ListView<StringFormat> param) {
|
||||
return new ListCell<StringFormat>(){
|
||||
@Override
|
||||
protected void updateItem(StringFormat item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item == null || empty) {
|
||||
setGraphic(null);
|
||||
} else {
|
||||
setText(resourceBundle.getString("format.type."+item));
|
||||
}
|
||||
}
|
||||
} ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.fx.validation;
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
import ninja.javafx.smartcsv.validation.configuration.StringFormat;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* converter for string formats
|
||||
*/
|
||||
public class StringFormatStringConverter extends StringConverter<StringFormat> {
|
||||
|
||||
private ResourceBundle resourceBundle;
|
||||
|
||||
public StringFormatStringConverter(ResourceBundle resourceBundle) {
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(StringFormat item) {
|
||||
return resourceBundle.getString("format.type."+item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringFormat fromString(String string) {
|
||||
return StringFormat.fromExternalValue(string);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,8 +30,9 @@ import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
|
||||
import ninja.javafx.smartcsv.fx.FXMLController;
|
||||
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
||||
import ninja.javafx.smartcsv.validation.configuration.*;
|
||||
import org.fxmisc.richtext.CodeArea;
|
||||
import org.fxmisc.richtext.LineNumberFactory;
|
||||
import org.fxmisc.richtext.StyleSpans;
|
||||
@@ -47,8 +48,11 @@ import java.util.ResourceBundle;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static javafx.beans.binding.Bindings.when;
|
||||
import static ninja.javafx.smartcsv.validation.configuration.Type.STRING;
|
||||
|
||||
/**
|
||||
* controller for editing column validations
|
||||
@@ -75,7 +79,7 @@ public class ValidationEditorController extends FXMLController {
|
||||
"transient", "true", "try", "void", "volatile", "while"
|
||||
};
|
||||
|
||||
private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b";
|
||||
private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", (CharSequence[]) KEYWORDS) + ")\\b";
|
||||
private static final String PAREN_PATTERN = "\\(|\\)";
|
||||
private static final String BRACE_PATTERN = "\\{|\\}";
|
||||
private static final String BRACKET_PATTERN = "\\[|\\]";
|
||||
@@ -96,19 +100,13 @@ public class ValidationEditorController extends FXMLController {
|
||||
);
|
||||
|
||||
@FXML
|
||||
private CheckBox notEmptyRuleCheckBox;
|
||||
private ComboBox<Type> typeComboBox;
|
||||
|
||||
@FXML
|
||||
private CheckBox integerRuleCheckBox;
|
||||
private ComboBox<StringFormat> formatComboBox;
|
||||
|
||||
@FXML
|
||||
private CheckBox doublerRuleCheckBox;
|
||||
|
||||
@FXML
|
||||
private CheckBox alphanumericRuleCheckBox;
|
||||
|
||||
@FXML
|
||||
private CheckBox uniqueRuleCheckBox;
|
||||
private TextField formatTextField;
|
||||
|
||||
@FXML
|
||||
private Spinner<Integer> minLengthSpinner;
|
||||
@@ -116,9 +114,6 @@ public class ValidationEditorController extends FXMLController {
|
||||
@FXML
|
||||
private Spinner<Integer> maxLengthSpinner;
|
||||
|
||||
@FXML
|
||||
private TextField dateformatRuleTextField;
|
||||
|
||||
@FXML
|
||||
private TextField regexpRuleTextField;
|
||||
|
||||
@@ -131,24 +126,12 @@ public class ValidationEditorController extends FXMLController {
|
||||
@FXML
|
||||
private CheckBox enableNotEmptyRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableIntegerRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableDoubleRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableAlphanumericRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableMinLengthRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableMaxLengthRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableDateRule;
|
||||
|
||||
@FXML
|
||||
private CheckBox enableRegexpRule;
|
||||
|
||||
@@ -170,25 +153,13 @@ public class ValidationEditorController extends FXMLController {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
minLengthSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0));
|
||||
maxLengthSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0));
|
||||
|
||||
initCheckBox(notEmptyRuleCheckBox, enableNotEmptyRule);
|
||||
initCheckBox(integerRuleCheckBox, enableIntegerRule);
|
||||
initCheckBox(doublerRuleCheckBox, enableDoubleRule);
|
||||
initCheckBox(alphanumericRuleCheckBox, enableAlphanumericRule);
|
||||
initCheckBox(uniqueRuleCheckBox, enableUniqueRule);
|
||||
initTypeAndFormatInput(resources);
|
||||
initMinMaxSpinner();
|
||||
initSpinner(minLengthSpinner, enableMinLengthRule);
|
||||
initSpinner(maxLengthSpinner, enableMaxLengthRule);
|
||||
initTextInputControl(dateformatRuleTextField, enableDateRule);
|
||||
initTextInputControl(regexpRuleTextField, enableRegexpRule);
|
||||
initTextInputControl(valueOfRuleTextField, enableValueOfRule);
|
||||
initCodeAreaControl(groovyRuleTextArea, enableGroovyRule);
|
||||
|
||||
selectedColumn.addListener(observable -> {
|
||||
updateForm();
|
||||
});
|
||||
}
|
||||
|
||||
public String getSelectedColumn() {
|
||||
@@ -207,152 +178,235 @@ public class ValidationEditorController extends FXMLController {
|
||||
this.validationConfiguration = validationConfiguration;
|
||||
}
|
||||
|
||||
public void updateConfiguration() {
|
||||
private void initTypeAndFormatInput(ResourceBundle resources) {
|
||||
typeComboBox.getItems().addAll(STRING,
|
||||
Type.INTEGER,
|
||||
Type.NUMBER,
|
||||
Type.DATE,
|
||||
Type.DATETIME,
|
||||
Type.TIME);
|
||||
formatComboBox.setCellFactory(new StringFormatEditorCellFactory(resources));
|
||||
formatComboBox.setConverter(new StringFormatStringConverter(resources));
|
||||
formatComboBox.getItems().addAll(
|
||||
StringFormat.DEFAULT,
|
||||
StringFormat.EMAIL,
|
||||
StringFormat.URI,
|
||||
StringFormat.BINARY,
|
||||
StringFormat.UUID
|
||||
);
|
||||
typeComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> changeFormat());
|
||||
}
|
||||
|
||||
if (enableIntegerRule.isSelected()) {
|
||||
validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), integerRuleCheckBox.isSelected());
|
||||
} else {
|
||||
validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), null);
|
||||
private void updateFormatTextField() {
|
||||
switch (typeComboBox.getValue()) {
|
||||
case DATE:
|
||||
case DATETIME:
|
||||
case TIME:
|
||||
formatTextField.setVisible(true);
|
||||
formatTextField.setText(getCurrentFieldConfig().getFormat());
|
||||
break;
|
||||
default:
|
||||
formatTextField.setVisible(false);
|
||||
formatTextField.setText(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (enableNotEmptyRule.isSelected()) {
|
||||
validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), notEmptyRuleCheckBox.isSelected());
|
||||
} else {
|
||||
validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), null);
|
||||
private void updateFormatComboBox() {
|
||||
switch (typeComboBox.getValue()) {
|
||||
case STRING:
|
||||
formatComboBox.setVisible(true);
|
||||
formatComboBox.getSelectionModel().select(StringFormat.fromExternalValue(getCurrentFieldConfig().getFormat()));
|
||||
break;
|
||||
default:
|
||||
formatComboBox.setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (enableUniqueRule.isSelected()) {
|
||||
validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), uniqueRuleCheckBox.isSelected());
|
||||
} else {
|
||||
validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), null);
|
||||
}
|
||||
|
||||
if (enableDoubleRule.isSelected()) {
|
||||
validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), doublerRuleCheckBox.isSelected());
|
||||
} else {
|
||||
validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), null);
|
||||
}
|
||||
|
||||
if (enableAlphanumericRule.isSelected()) {
|
||||
validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), alphanumericRuleCheckBox.isSelected());
|
||||
} else {
|
||||
validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), null);
|
||||
}
|
||||
|
||||
if (enableDateRule.isSelected()) {
|
||||
validationConfiguration.setDateRuleFor(selectedColumn.getValue(), dateformatRuleTextField.getText());
|
||||
} else {
|
||||
validationConfiguration.setDateRuleFor(selectedColumn.getValue(), null);
|
||||
}
|
||||
|
||||
if (enableGroovyRule.isSelected()) {
|
||||
validationConfiguration.setGroovyRuleFor(selectedColumn.getValue(), groovyRuleTextArea.getText());
|
||||
} else {
|
||||
validationConfiguration.setGroovyRuleFor(selectedColumn.getValue(), null);
|
||||
}
|
||||
|
||||
if (enableMinLengthRule.isSelected()) {
|
||||
validationConfiguration.setMinLengthRuleFor(selectedColumn.getValue(), minLengthSpinner.getValue());
|
||||
} else {
|
||||
validationConfiguration.setMinLengthRuleFor(selectedColumn.getValue(), null);
|
||||
}
|
||||
|
||||
if (enableMaxLengthRule.isSelected()) {
|
||||
validationConfiguration.setMaxLengthRuleFor(selectedColumn.getValue(), maxLengthSpinner.getValue());
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
private void initMinMaxSpinner() {
|
||||
IntegerSpinnerValueFactory minValueFactory = new IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0);
|
||||
minLengthSpinner.setValueFactory(minValueFactory);
|
||||
IntegerSpinnerValueFactory maxValueFactory = new IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0);
|
||||
maxLengthSpinner.setValueFactory(maxValueFactory);
|
||||
|
||||
minValueFactory.maxProperty().bind(
|
||||
when(enableMaxLengthRule.selectedProperty()).
|
||||
then(maxLengthSpinner.valueProperty()).
|
||||
otherwise(Integer.MAX_VALUE));
|
||||
maxValueFactory.minProperty().bind(
|
||||
when(enableMinLengthRule.selectedProperty()).
|
||||
then(minLengthSpinner.valueProperty()).
|
||||
otherwise(0));
|
||||
|
||||
}
|
||||
|
||||
private void updateForm() {
|
||||
|
||||
updateCheckBox(
|
||||
notEmptyRuleCheckBox,
|
||||
validationConfiguration.getNotEmptyRuleFor(getSelectedColumn()),
|
||||
enableNotEmptyRule
|
||||
private void changeFormat() {
|
||||
switch (typeComboBox.getValue()) {
|
||||
case STRING:
|
||||
updateFormatComboBox();
|
||||
break;
|
||||
case DATE:
|
||||
case DATETIME:
|
||||
case TIME:
|
||||
updateFormatTextField();
|
||||
break;
|
||||
case INTEGER:
|
||||
case NUMBER:
|
||||
default:
|
||||
// format: no options
|
||||
formatComboBox.setVisible(false);
|
||||
formatTextField.setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateConfiguration() {
|
||||
|
||||
Field config = getCurrentFieldConfig();
|
||||
config.setType(typeComboBox.getValue());
|
||||
|
||||
switch (typeComboBox.getValue()) {
|
||||
case STRING:
|
||||
config.setFormat(formatComboBox.getValue().getExternalValue());
|
||||
break;
|
||||
case DATE:
|
||||
case DATETIME:
|
||||
case TIME:
|
||||
if (formatTextField.getText().trim().isEmpty()) {
|
||||
config.setFormat(null);
|
||||
} else {
|
||||
// TODO: validate input
|
||||
config.setFormat(formatTextField.getText());
|
||||
}
|
||||
break;
|
||||
case INTEGER:
|
||||
case NUMBER:
|
||||
default:
|
||||
// format: no options
|
||||
config.setFormat(null);
|
||||
break;
|
||||
}
|
||||
|
||||
if (enableGroovyRule.isSelected()) {
|
||||
config.setGroovy(groovyRuleTextArea.getText());
|
||||
} else {
|
||||
config.setGroovy(null);
|
||||
}
|
||||
|
||||
Constraints constraints = config.getConstraints();
|
||||
if (constraints == null) {
|
||||
constraints = new Constraints();
|
||||
}
|
||||
|
||||
if (enableNotEmptyRule.isSelected()) {
|
||||
constraints.setRequired(enableNotEmptyRule.isSelected());
|
||||
} else {
|
||||
constraints.setRequired(null);
|
||||
}
|
||||
|
||||
if (enableUniqueRule.isSelected()) {
|
||||
constraints.setUnique(enableUniqueRule.isSelected());
|
||||
} else {
|
||||
constraints.setUnique(null);
|
||||
}
|
||||
|
||||
if (enableMinLengthRule.isSelected()) {
|
||||
constraints.setMinLength(minLengthSpinner.getValue());
|
||||
} else {
|
||||
constraints.setMinLength(null);
|
||||
}
|
||||
|
||||
if (enableMaxLengthRule.isSelected()) {
|
||||
constraints.setMaxLength(maxLengthSpinner.getValue());
|
||||
} else {
|
||||
constraints.setMaxLength(null);
|
||||
}
|
||||
|
||||
if (enableRegexpRule.isSelected()) {
|
||||
constraints.setPattern(regexpRuleTextField.getText());
|
||||
} else {
|
||||
constraints.setPattern(null);
|
||||
}
|
||||
|
||||
if (enableValueOfRule.isSelected()) {
|
||||
constraints.setEnumeration(asList(valueOfRuleTextField.getText().split(", ")));
|
||||
} else {
|
||||
constraints.setEnumeration(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Field getCurrentFieldConfig() {
|
||||
return validationConfiguration.getFieldConfiguration(getSelectedColumn());
|
||||
}
|
||||
|
||||
private void addDependencyListener(CheckBox rule, CheckBox... dependentRules) {
|
||||
rule.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue) {
|
||||
for (CheckBox dependentRule: dependentRules) {
|
||||
dependentRule.selectedProperty().setValue(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateForm() {
|
||||
|
||||
Field config = getCurrentFieldConfig();
|
||||
|
||||
if (config.getType() != null) {
|
||||
typeComboBox.setValue(config.getType());
|
||||
} else {
|
||||
typeComboBox.setValue(STRING);
|
||||
}
|
||||
|
||||
updateFormatComboBox();
|
||||
updateFormatTextField();
|
||||
|
||||
updateCodeAreaControl(
|
||||
groovyRuleTextArea,
|
||||
config.getGroovy(),
|
||||
enableGroovyRule
|
||||
);
|
||||
|
||||
updateCheckBox(
|
||||
integerRuleCheckBox,
|
||||
validationConfiguration.getIntegerRuleFor(getSelectedColumn()),
|
||||
enableIntegerRule
|
||||
);
|
||||
|
||||
updateCheckBox(
|
||||
doublerRuleCheckBox,
|
||||
validationConfiguration.getDoubleRuleFor(getSelectedColumn()),
|
||||
enableDoubleRule
|
||||
);
|
||||
|
||||
updateCheckBox(
|
||||
alphanumericRuleCheckBox,
|
||||
validationConfiguration.getAlphanumericRuleFor(getSelectedColumn()),
|
||||
enableAlphanumericRule
|
||||
);
|
||||
|
||||
updateCheckBox(
|
||||
uniqueRuleCheckBox,
|
||||
validationConfiguration.getUniqueRuleFor(getSelectedColumn()),
|
||||
enableUniqueRule
|
||||
);
|
||||
Constraints constraints = config.getConstraints();
|
||||
updateCheckBox(constraints != null ? constraints.getRequired() : FALSE, enableNotEmptyRule);
|
||||
updateCheckBox(constraints != null ? constraints.getUnique() : FALSE, enableUniqueRule);
|
||||
|
||||
updateSpinner(
|
||||
minLengthSpinner,
|
||||
validationConfiguration.getMinLengthRuleFor(getSelectedColumn()),
|
||||
constraints != null ? constraints.getMinLength() : null,
|
||||
enableMinLengthRule
|
||||
);
|
||||
|
||||
updateSpinner(
|
||||
maxLengthSpinner,
|
||||
validationConfiguration.getMaxLengthRuleFor(getSelectedColumn()),
|
||||
constraints != null ? constraints.getMaxLength() : null,
|
||||
enableMaxLengthRule
|
||||
);
|
||||
|
||||
updateTextInputControl(
|
||||
dateformatRuleTextField,
|
||||
validationConfiguration.getDateRuleFor(getSelectedColumn()),
|
||||
enableDateRule
|
||||
);
|
||||
|
||||
updateTextInputControl(
|
||||
regexpRuleTextField,
|
||||
validationConfiguration.getRegexpRuleFor(getSelectedColumn()),
|
||||
constraints != null ? constraints.getPattern() : null,
|
||||
enableRegexpRule
|
||||
);
|
||||
|
||||
updateTextInputControl(
|
||||
valueOfRuleTextField,
|
||||
validationConfiguration.getValueOfRuleFor(getSelectedColumn()),
|
||||
constraints != null ? constraints.getEnumeration() : null,
|
||||
enableValueOfRule
|
||||
);
|
||||
|
||||
updateCodeAreaControl(
|
||||
groovyRuleTextArea,
|
||||
validationConfiguration.getGroovyRuleFor(getSelectedColumn()),
|
||||
enableGroovyRule
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private void updateCheckBox(CheckBox rule, Boolean value, CheckBox ruleEnabled) {
|
||||
private void updateCheckBox(Boolean value, CheckBox ruleEnabled) {
|
||||
if (value == null) {
|
||||
ruleEnabled.setSelected(false);
|
||||
} else {
|
||||
rule.setSelected(value);
|
||||
ruleEnabled.setSelected(true);
|
||||
ruleEnabled.setSelected(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,15 +446,6 @@ public class ValidationEditorController extends FXMLController {
|
||||
}
|
||||
}
|
||||
|
||||
private void initCheckBox(CheckBox rule, CheckBox ruleEnabled) {
|
||||
rule.disableProperty().bind(ruleEnabled.selectedProperty().not());
|
||||
ruleEnabled.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue) {
|
||||
rule.setSelected(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initSpinner(Spinner rule, CheckBox ruleEnabled) {
|
||||
rule.disableProperty().bind(ruleEnabled.selectedProperty().not());
|
||||
ruleEnabled.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* validation configuration
|
||||
*/
|
||||
public class ValidationConfiguration {
|
||||
|
||||
@SerializedName("headers")
|
||||
private HeaderConfiguration headerConfiguration = new HeaderConfiguration();
|
||||
|
||||
@SerializedName("columns")
|
||||
private Map<String, Map<String, Object>> columnConfigurations = new HashMap<>();
|
||||
|
||||
public String[] headerNames() {
|
||||
if (noHeader()) return null;
|
||||
return headerConfiguration.getNames();
|
||||
}
|
||||
|
||||
public void setHeaderNames(String[] headerNames) {
|
||||
headerConfiguration.setNames(headerNames);
|
||||
}
|
||||
|
||||
public Boolean getUniqueRuleFor(String column) {
|
||||
return (Boolean)getValue(column, "unique");
|
||||
}
|
||||
|
||||
public Boolean getIntegerRuleFor(String column) {
|
||||
return (Boolean)getValue(column, "integer");
|
||||
}
|
||||
|
||||
public Boolean getDoubleRuleFor(String column) {
|
||||
return (Boolean)getValue(column, "double");
|
||||
}
|
||||
|
||||
public Boolean getNotEmptyRuleFor(String column) {
|
||||
return (Boolean)getValue(column, "not empty");
|
||||
}
|
||||
|
||||
public Integer getMinLengthRuleFor(String column) {
|
||||
return doubleToInteger((Double)getValue(column, "minlength"));
|
||||
}
|
||||
|
||||
public Integer getMaxLengthRuleFor(String column) {
|
||||
Double value = (Double)getValue(column, "maxlength");
|
||||
return value != null ? doubleToInteger(value) : null;
|
||||
}
|
||||
|
||||
public String getDateRuleFor(String column) {
|
||||
return (String)getValue(column, "date");
|
||||
}
|
||||
|
||||
public Boolean getAlphanumericRuleFor(String column) {
|
||||
return (Boolean)getValue(column, "alphanumeric");
|
||||
}
|
||||
|
||||
public String getRegexpRuleFor(String column) {
|
||||
return (String)getValue(column, "regexp");
|
||||
}
|
||||
|
||||
public List<String> getValueOfRuleFor(String column) {
|
||||
return (List<String>)getValue(column, "value of");
|
||||
}
|
||||
|
||||
public String getGroovyRuleFor(String column) {
|
||||
return (String)getValue(column, "groovy");
|
||||
}
|
||||
|
||||
public void setIntegerRuleFor(String column, Boolean value) {
|
||||
setValue(column, value, "integer");
|
||||
}
|
||||
|
||||
public void setDoubleRuleFor(String column, Boolean value) {
|
||||
setValue(column, value, "double");
|
||||
}
|
||||
|
||||
public void setNotEmptyRuleFor(String column, Boolean value) {
|
||||
setValue(column, value, "not empty");
|
||||
}
|
||||
|
||||
public void setUniqueRuleFor(String column, Boolean value) {
|
||||
setValue(column, value, "unique");
|
||||
}
|
||||
|
||||
|
||||
public void setMinLengthRuleFor(String column, Integer value) {
|
||||
setValue(column, value == null ? null : value.doubleValue(), "minlength");
|
||||
}
|
||||
|
||||
public void setMaxLengthRuleFor(String column, Integer value) {
|
||||
setValue(column, value == null ? null : value.doubleValue(), "maxlength");
|
||||
}
|
||||
|
||||
public void setDateRuleFor(String column, String value) {
|
||||
setValue(column, value, "date");
|
||||
}
|
||||
|
||||
public void setAlphanumericRuleFor(String column, Boolean value) {
|
||||
setValue(column, value, "alphanumeric");
|
||||
}
|
||||
|
||||
public void setRegexpRuleFor(String column, String value) {
|
||||
setValue(column, value, "regexp");
|
||||
}
|
||||
|
||||
public void setValueOfRuleFor(String column, List<String> value) {
|
||||
setValue(column, value, "value of");
|
||||
}
|
||||
|
||||
public void setGroovyRuleFor(String column, String value) {
|
||||
setValue(column, value, "groovy");
|
||||
}
|
||||
|
||||
private void setValue(String column, Object value, String key) {
|
||||
if (!columnConfigurations.containsKey(column)) {
|
||||
columnConfigurations.put(column, new HashMap<>());
|
||||
}
|
||||
|
||||
if (value == null && columnConfigurations.get(column).containsKey(key)) {
|
||||
columnConfigurations.get(column).remove(key);
|
||||
} else {
|
||||
columnConfigurations.get(column).put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private Object getValue(String column, String key) {
|
||||
if (columnConfigurations != null) {
|
||||
Map rulesForColumn = columnConfigurations.get(column);
|
||||
if (rulesForColumn != null) {
|
||||
return columnConfigurations.get(column).get(key);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean noHeader() {
|
||||
return headerConfiguration == null;
|
||||
}
|
||||
|
||||
private Integer doubleToInteger(Double value) {
|
||||
if (value == null) return null;
|
||||
return (int)Math.round(value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,10 +28,14 @@ package ninja.javafx.smartcsv.validation;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ninja.javafx.smartcsv.FileReader;
|
||||
import ninja.javafx.smartcsv.validation.configuration.Field;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static ninja.javafx.smartcsv.validation.configuration.Type.*;
|
||||
|
||||
/**
|
||||
* This class loads the constraints as json config
|
||||
*/
|
||||
@@ -42,6 +46,30 @@ public class ValidationFileReader implements FileReader<ValidationConfiguration>
|
||||
@Override
|
||||
public void read(File file) throws IOException {
|
||||
config = new GsonBuilder().create().fromJson(new java.io.FileReader(file), ValidationConfiguration.class);
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
for (Field field : config.getFields()) {
|
||||
if (field.getType() == null) {
|
||||
field.setType(STRING);
|
||||
}
|
||||
if (field.getType() == DATE) {
|
||||
if (field.getFormat() == null) {
|
||||
field.setFormat("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
if (field.getType() == DATETIME) {
|
||||
if (field.getFormat() == null) {
|
||||
field.setFormat("yyyy-MM-ddThh:mm:ssZ");
|
||||
}
|
||||
}
|
||||
if (field.getType() == TIME) {
|
||||
if (field.getFormat() == null) {
|
||||
field.setFormat("hh:mm:ss");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationConfiguration getContent() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,6 +29,7 @@ package ninja.javafx.smartcsv.validation;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ninja.javafx.smartcsv.FileWriter;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
|
||||
/**
|
||||
* @author abi
|
||||
*/
|
||||
public class ValidationFormatHelper {
|
||||
|
||||
|
||||
public static String dateFormat(String format, String defaultFormat) {
|
||||
|
||||
if (format != null && !format.trim().isEmpty()) {
|
||||
format = format.trim();
|
||||
if (format.startsWith("fmt:")) {
|
||||
format = format.substring(4);
|
||||
format = format.replace("%Y", "yyyy");
|
||||
format = format.replace("%y", "yy");
|
||||
format = format.replace("%m", "MM");
|
||||
format = format.replace("%d", "dd");
|
||||
format = format.replace("%a", "E");
|
||||
format = format.replace("%A", "EEEE");
|
||||
format = format.replace("%w", "F");
|
||||
format = format.replace("%b", "MMM");
|
||||
format = format.replace("%B", "MMMMM");
|
||||
format = format.replace("%H", "HH");
|
||||
format = format.replace("%I", "hh");
|
||||
format = format.replace("%p", "a");
|
||||
format = format.replace("%M", "mm");
|
||||
format = format.replace("%S", "ss");
|
||||
format = format.replace("%z", "Z");
|
||||
format = format.replace("%Z", "z");
|
||||
format = format.replace("%j", "DDD");
|
||||
format = format.replace("%U", "ww");
|
||||
return format;
|
||||
}
|
||||
}
|
||||
return defaultFormat;
|
||||
}
|
||||
|
||||
public static Integer doubleToInteger(Double value) {
|
||||
if (value == null) return null;
|
||||
return (int)Math.round(value);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,11 +27,19 @@
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
|
||||
import ninja.javafx.smartcsv.fx.table.model.ColumnValueProvider;
|
||||
import ninja.javafx.smartcsv.validation.checker.*;
|
||||
import ninja.javafx.smartcsv.validation.configuration.Constraints;
|
||||
import ninja.javafx.smartcsv.validation.configuration.Field;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static ninja.javafx.smartcsv.validation.ValidationFormatHelper.dateFormat;
|
||||
import static ninja.javafx.smartcsv.validation.configuration.StringFormat.*;
|
||||
import static ninja.javafx.smartcsv.validation.configuration.Type.*;
|
||||
|
||||
/**
|
||||
* This class checks all the validations defined in the
|
||||
* Config against a given value
|
||||
@@ -134,70 +142,115 @@ public class Validator {
|
||||
|
||||
private void initColumnValidations() {
|
||||
if (hasConfig()) {
|
||||
String[] columns = validationConfig.headerNames();
|
||||
for (String column : columns) {
|
||||
for (Field column : validationConfig.getFields()) {
|
||||
initializeColumnWithRules(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeColumnWithRules(String column) {
|
||||
Boolean alphaNumeric = validationConfig.getAlphanumericRuleFor(column);
|
||||
if (alphaNumeric != null && alphaNumeric) {
|
||||
add(column, new AlphaNumericValidation());
|
||||
private void initializeColumnWithRules(String columnName) {
|
||||
if (hasConfig()) {
|
||||
for (Field column : validationConfig.getFields()) {
|
||||
if (column.getName().equals(columnName)) {
|
||||
initializeColumnWithRules(column);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Boolean doubleRule = validationConfig.getDoubleRuleFor(column);
|
||||
if (doubleRule != null && doubleRule) {
|
||||
add(column, new DoubleValidation());
|
||||
}
|
||||
|
||||
private void initializeColumnWithRules(Field column) {
|
||||
|
||||
if (column.getType() != null) {
|
||||
if (column.getType() == NUMBER) {
|
||||
add(column.getName(), new DoubleValidation());
|
||||
}
|
||||
|
||||
if (column.getType() == INTEGER) {
|
||||
add(column.getName(), new IntegerValidation());
|
||||
}
|
||||
|
||||
if (column.getType() == DATE) {
|
||||
String format = dateFormat(column.getFormat(), "YYYY-MM-DD");
|
||||
add(column.getName(), new DateValidation(format));
|
||||
}
|
||||
|
||||
if (column.getType() == DATETIME) {
|
||||
String format = dateFormat(column.getFormat(), "YYYY-MM-DDThh:mm:ssZ");
|
||||
add(column.getName(), new DateValidation(format));
|
||||
}
|
||||
|
||||
if (column.getType() == TIME) {
|
||||
String format = dateFormat(column.getFormat(), "hh:mm:ss");
|
||||
add(column.getName(), new DateValidation(format));
|
||||
}
|
||||
|
||||
if (column.getType() == STRING && column.getFormat().equalsIgnoreCase(EMAIL.getExternalValue())) {
|
||||
add(column.getName(), new EmailValidation());
|
||||
}
|
||||
|
||||
if (column.getType() == STRING && column.getFormat().equalsIgnoreCase(URI.getExternalValue())) {
|
||||
add(column.getName(), new UriValidation());
|
||||
}
|
||||
|
||||
if (column.getType() == STRING && column.getFormat().equalsIgnoreCase(UUID.getExternalValue())) {
|
||||
add(column.getName(), new UuidValidation());
|
||||
}
|
||||
|
||||
if (column.getType() == STRING && column.getFormat().equalsIgnoreCase(BINARY.getExternalValue())) {
|
||||
add(column.getName(), new BinaryValidation());
|
||||
}
|
||||
|
||||
if (column.getType() == STRING && column.getFormat() == null) {
|
||||
columnValidationMap.get(column).remove(Validation.Type.STRING);
|
||||
}
|
||||
}
|
||||
|
||||
Boolean integerRule = validationConfig.getIntegerRuleFor(column);
|
||||
if (integerRule != null && integerRule) {
|
||||
add(column, new IntegerValidation());
|
||||
}
|
||||
|
||||
Boolean notEmptyRule = validationConfig.getNotEmptyRuleFor(column);
|
||||
if (notEmptyRule != null && notEmptyRule) {
|
||||
add(column, new NotEmptyValidation());
|
||||
}
|
||||
|
||||
Boolean uniqueRule = validationConfig.getUniqueRuleFor(column);
|
||||
if (uniqueRule != null && uniqueRule) {
|
||||
add(column, new UniqueValidation(columnValueProvider, column));
|
||||
}
|
||||
|
||||
String dateRule = validationConfig.getDateRuleFor(column);
|
||||
if (dateRule != null && !dateRule.trim().isEmpty()) {
|
||||
add(column, new DateValidation(dateRule));
|
||||
}
|
||||
|
||||
Integer minLength = validationConfig.getMinLengthRuleFor(column);
|
||||
if (minLength != null) {
|
||||
add(column, new MinLengthValidation(minLength));
|
||||
}
|
||||
|
||||
Integer maxLength = validationConfig.getMaxLengthRuleFor(column);
|
||||
if (maxLength != null) {
|
||||
add(column, new MaxLengthValidation(maxLength));
|
||||
}
|
||||
|
||||
String regexp = validationConfig.getRegexpRuleFor(column);
|
||||
if (regexp != null && !regexp.trim().isEmpty()) {
|
||||
add(column, new RegExpValidation(regexp));
|
||||
}
|
||||
|
||||
String groovy = validationConfig.getGroovyRuleFor(column);
|
||||
String groovy = column.getGroovy();
|
||||
if (groovy != null && !groovy.trim().isEmpty()) {
|
||||
add(column, new GroovyValidation(groovy));
|
||||
add(column.getName(), new GroovyValidation(groovy));
|
||||
}
|
||||
List<String> valueOfRule = validationConfig.getValueOfRuleFor(column);
|
||||
if (valueOfRule != null && !valueOfRule.isEmpty()) {
|
||||
add(column, new ValueOfValidation(valueOfRule));
|
||||
|
||||
Constraints constraints = column.getConstraints();
|
||||
if (constraints != null) {
|
||||
Boolean notEmptyRule = constraints.getRequired();
|
||||
if (notEmptyRule != null && notEmptyRule) {
|
||||
add(column.getName(), new NotEmptyValidation());
|
||||
}
|
||||
|
||||
Boolean uniqueRule = constraints.getUnique();
|
||||
if (uniqueRule != null && uniqueRule) {
|
||||
add(column.getName(), new UniqueValidation(columnValueProvider, column.getName()));
|
||||
}
|
||||
|
||||
Integer minLength = constraints.getMinLength();
|
||||
if (minLength != null) {
|
||||
add(column.getName(), new MinLengthValidation(minLength));
|
||||
}
|
||||
|
||||
Integer maxLength = constraints.getMaxLength();
|
||||
if (maxLength != null) {
|
||||
add(column.getName(), new MaxLengthValidation(maxLength));
|
||||
}
|
||||
|
||||
String regexp = constraints.getPattern();
|
||||
if (regexp != null && !regexp.trim().isEmpty()) {
|
||||
add(column.getName(), new RegExpValidation(regexp));
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<String> valueOfRule = constraints.getEnumeration();
|
||||
if (valueOfRule != null && !valueOfRule.isEmpty()) {
|
||||
add(column.getName(), new ValueOfValidation(valueOfRule));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ValidationError isHeaderValid(String[] headerNames) {
|
||||
ValidationError result = null;
|
||||
if (validationConfig != null) {
|
||||
@@ -227,4 +280,6 @@ public class Validator {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* checks if the value is a base64 encoded string representing binary data
|
||||
*/
|
||||
public class BinaryValidation extends EmptyValueIsValid {
|
||||
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
try {
|
||||
Base64.getDecoder().decode(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
error.add("validation.message.binary");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.STRING;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.isDate;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.isDouble;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,24 +23,25 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
import org.apache.commons.validator.routines.EmailValidator;
|
||||
|
||||
/**
|
||||
* header configuration for the validation
|
||||
* checks if the value is a valid email address
|
||||
*/
|
||||
public class HeaderConfiguration {
|
||||
public class EmailValidation extends EmptyValueIsValid {
|
||||
|
||||
@SerializedName("list")
|
||||
private String[] names ;
|
||||
|
||||
public String[] getNames() {
|
||||
return names;
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
if (!EmailValidator.getInstance().isValid(value)) {
|
||||
error.add("validation.message.email");
|
||||
}
|
||||
}
|
||||
|
||||
public void setNames(String[] names) {
|
||||
this.names = names;
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.STRING;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
/**
|
||||
* validations based on this are not validated when the value is null or empty
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,11 +23,12 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import groovy.lang.Binding;
|
||||
import groovy.lang.GroovyShell;
|
||||
import groovy.lang.Script;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
|
||||
/**
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.isInt;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.maxLength;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.minLength;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.isBlankOrNull;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.matchRegexp;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,10 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.fx.table.model.ColumnValueProvider;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
* checks if the value is a valid uri address
|
||||
*/
|
||||
public class UriValidation extends EmptyValueIsValid {
|
||||
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
try {
|
||||
new URI(value);
|
||||
} catch (URISyntaxException e) {
|
||||
error.add("validation.message.uri");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.STRING;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,25 +23,28 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import static org.apache.commons.validator.GenericValidator.matchRegexp;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Checks if the value is alpha numeric
|
||||
* checks if the value is a valid uuid
|
||||
*/
|
||||
public class AlphaNumericValidation extends EmptyValueIsValid {
|
||||
public class UuidValidation extends EmptyValueIsValid {
|
||||
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
if (!matchRegexp(value, "[0-9a-zA-Z]*")) {
|
||||
error.add("validation.message.alphanumeric");
|
||||
try {
|
||||
UUID.fromString(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
error.add("validation.message.uuid");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.ALPHANUMERIC;
|
||||
return Type.STRING;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,14 +23,16 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
/**
|
||||
* Interface for all validations
|
||||
*/
|
||||
public interface Validation {
|
||||
|
||||
enum Type { NOT_EMPTY, UNIQUE, DOUBLE, INTEGER, MIN_LENGTH, MAX_LENGTH, DATE, ALPHANUMERIC, REGEXP, VALUE_OF, GROOVY }
|
||||
enum Type { NOT_EMPTY, UNIQUE, DOUBLE, INTEGER, MIN_LENGTH, MAX_LENGTH, DATE, REGEXP, VALUE_OF, STRING, GROOVY }
|
||||
void check(int row, String value, ValidationError error);
|
||||
Type getType();
|
||||
boolean canBeChecked(String value);
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
package ninja.javafx.smartcsv.validation.checker;
|
||||
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.validation.configuration;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* contraints defined in JSON Table Schema
|
||||
* @see <a href="http://specs.frictionlessdata.io/json-table-schema/">JSON Table Schema</a>
|
||||
*/
|
||||
public class Constraints {
|
||||
private Boolean required;
|
||||
private Boolean unique;
|
||||
private Integer minLength;
|
||||
private Integer maxLength;
|
||||
|
||||
private String pattern;
|
||||
|
||||
@SerializedName("enum")
|
||||
private List<String> enumeration;
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public Boolean getUnique() {
|
||||
return unique;
|
||||
}
|
||||
|
||||
public void setUnique(Boolean unique) {
|
||||
this.unique = unique;
|
||||
}
|
||||
|
||||
public Integer getMinLength() {
|
||||
return minLength;
|
||||
}
|
||||
|
||||
public void setMinLength(Integer minLength) {
|
||||
this.minLength = minLength;
|
||||
}
|
||||
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
public void setMaxLength(Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
public String getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public List<String> getEnumeration() {
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
public void setEnumeration(List<String> enumeration) {
|
||||
this.enumeration = enumeration;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.validation.configuration;
|
||||
|
||||
/**
|
||||
* this class represents a field in the configuration
|
||||
* @see <a href="http://specs.frictionlessdata.io/json-table-schema/">JSON Table Schema</a>
|
||||
*/
|
||||
public class Field {
|
||||
|
||||
private String name;
|
||||
private String title;
|
||||
private Type type;
|
||||
private String description;
|
||||
private String format;
|
||||
private Object missingValue;
|
||||
private Constraints constraints;
|
||||
private String groovy;
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public Object getMissingValue() {
|
||||
return missingValue;
|
||||
}
|
||||
|
||||
public void setMissingValue(Object missingValue) {
|
||||
this.missingValue = missingValue;
|
||||
}
|
||||
|
||||
public Constraints getConstraints() {
|
||||
return constraints;
|
||||
}
|
||||
|
||||
public void setConstraints(Constraints constraints) {
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
public String getGroovy() {
|
||||
return groovy;
|
||||
}
|
||||
|
||||
public void setGroovy(String groovy) {
|
||||
this.groovy = groovy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.validation.configuration;
|
||||
|
||||
/**
|
||||
* Enumeration for format values for type string in JSON Table Schema
|
||||
* @see <a href="http://specs.frictionlessdata.io/json-table-schema/">JSON Table Schema</a>
|
||||
*/
|
||||
public enum StringFormat {
|
||||
DEFAULT(null),
|
||||
EMAIL("email"),
|
||||
URI("uri"),
|
||||
BINARY("binary"),
|
||||
UUID("uuid");
|
||||
|
||||
private String externalValue;
|
||||
|
||||
StringFormat(String externalValue) {
|
||||
this.externalValue = externalValue;
|
||||
}
|
||||
|
||||
public String getExternalValue() {
|
||||
return externalValue;
|
||||
}
|
||||
|
||||
public static StringFormat fromExternalValue(String externalValue) {
|
||||
if (externalValue != null) {
|
||||
for (StringFormat value : StringFormat.values()) {
|
||||
if (externalValue.equals(value.getExternalValue())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.validation.configuration;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Types of JSON Table Schema
|
||||
* @see <a href="http://specs.frictionlessdata.io/json-table-schema/">JSON Table Schema</a>
|
||||
*/
|
||||
public enum Type {
|
||||
@SerializedName("string")STRING,
|
||||
@SerializedName("integer")INTEGER,
|
||||
@SerializedName("number")NUMBER,
|
||||
@SerializedName("date")DATE,
|
||||
@SerializedName("datetime")DATETIME,
|
||||
@SerializedName("time")TIME
|
||||
// TODO: currently not supported
|
||||
// @SerializedName("object") OBJECT,
|
||||
// @SerializedName("array") ARRAY,
|
||||
// @SerializedName("duration") DURATION,
|
||||
// @SerializedName("geopoint") GEOPOINT,
|
||||
// @SerializedName("geojson") GEOJSON
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.validation.configuration;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Configuration based on JSON Table Schema
|
||||
* @see <a href="http://specs.frictionlessdata.io/json-table-schema/">JSON Table Schema</a>
|
||||
*/
|
||||
public class ValidationConfiguration {
|
||||
|
||||
@SerializedName("fields")
|
||||
private Field[] fields;
|
||||
|
||||
public Field[] getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(Field[] fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public Field getFieldConfiguration(String column) {
|
||||
for (Field field : fields) {
|
||||
if (field.getName().equals(column)) {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] headerNames() {
|
||||
if (fields != null) {
|
||||
List<String> headerNames = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
headerNames.add(field.getName());
|
||||
}
|
||||
return headerNames.toArray(new String[headerNames.size()]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setHeaderNames(String[] header) {
|
||||
fields = new Field[header.length];
|
||||
int i = 0;
|
||||
for (String headerName: header) {
|
||||
fields[i] = new Field();
|
||||
fields[i].setName(headerName);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextArea editable="false" prefHeight="200.0" prefWidth="200.0" text="Copyright (c) 2015 Andreas Billmann <andreas.billmann@javafx.ninja> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." wrapText="true" />
|
||||
<TextArea editable="false" prefHeight="200.0" prefWidth="200.0" text="Copyright (c) 2015-2016 Andreas Billmann <andreas.billmann@javafx.ninja> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." wrapText="true" />
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
application.name = SmartCSV.fx
|
||||
application.version = 0.7
|
||||
application.version = 0.8
|
||||
|
||||
# fxml views
|
||||
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
.list-view {
|
||||
.table-view .list-view {
|
||||
-fx-background-color: -fx-background;
|
||||
-fx-padding: 1;
|
||||
}
|
||||
|
||||
.list-cell {
|
||||
.table-view .list-cell {
|
||||
-fx-padding: 1.0em 1.0em 1.0em 1.0em;
|
||||
}
|
||||
.list-cell:odd {
|
||||
.table-view .list-cell:odd {
|
||||
-fx-background: -fx-control-inner-background-alt;
|
||||
}
|
||||
|
||||
.list-cell:even {
|
||||
.table-view .list-cell:even {
|
||||
-fx-background: -fx-control-inner-background;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ preferences.quoteMode = Quote mode:
|
||||
validation.message.not.empty = should not be empty
|
||||
validation.message.integer = should be an integer
|
||||
validation.message.double = should be a double
|
||||
validation.message.email = should be an email address
|
||||
validation.message.alphanumeric = should be alphanumeric
|
||||
validation.message.groovy.exception = groovy script '{0}' throws exception: {1}
|
||||
validation.message.groovy.return.null = groovy script '{0}' returns null
|
||||
@@ -55,25 +56,30 @@ validation.message.date.format = is not a date of format {0}
|
||||
validation.message.regexp = does not match {0}
|
||||
validation.message.uniqueness.multiple = value {0} is not unique (found in rows {1})
|
||||
validation.message.uniqueness.single = value {0} is not unique (found in row {1})
|
||||
validation.message.uri = should be an uri
|
||||
validation.message.uuid = should be an uuid
|
||||
validation.message.binary = should be a base64 encoded string representing binary data
|
||||
|
||||
validation.message.header.length = number of headers is not correct! there are {0} but there should be {1}
|
||||
validation.message.header.match = header number {0} does not match "{1}" should be "{2}"
|
||||
validation.message.value.of = Value {0} is not part of this list {1}
|
||||
|
||||
validation.rule.label.not_empty = not empty:
|
||||
validation.rule.label.integer = integer:
|
||||
validation.rule.label.double = double:
|
||||
validation.rule.label.not_empty = not empty
|
||||
validation.rule.label.integer = integer
|
||||
validation.rule.label.double = double
|
||||
validation.rule.label.minlength = minimum length:
|
||||
validation.rule.label.maxlength = maximum length:
|
||||
validation.rule.label.dateformat = date format:
|
||||
validation.rule.label.alphanumeric = alphanumeric:
|
||||
validation.rule.label.alphanumeric = alphanumeric
|
||||
validation.rule.label.regexp = regular expression:
|
||||
validation.rule.label.value_of = value in list:
|
||||
validation.rule.label.groovy = groovy:
|
||||
validation.rules.active = active
|
||||
validation.rules.name = rule
|
||||
validation.rules.value = value
|
||||
validation.rule.label.unique = Unique in column:
|
||||
validation.rule.label.unique = Unique in column
|
||||
validation.rule.format = Format:
|
||||
validation.rule.type = Type:
|
||||
|
||||
dialog.validation.rules.title = Validation rules
|
||||
dialog.validation.rules.header = Validation rules of column "{0}"
|
||||
@@ -85,3 +91,9 @@ log.header.message = {0} has {1} errors
|
||||
log.message = row {0} column {1} : {2}
|
||||
|
||||
column = column
|
||||
|
||||
format.type.DEFAULT = default
|
||||
format.type.EMAIL = email
|
||||
format.type.URI = uri
|
||||
format.type.BINARY = binary
|
||||
format.type.UUID = uuid
|
||||
|
||||
@@ -55,6 +55,7 @@ preferences.quoteMode = Einfassungsmodus:
|
||||
validation.message.not.empty = Darf nicht leer sein.
|
||||
validation.message.integer = Muss eine Zahl sein.
|
||||
validation.message.double = Muss eine Gleitkommazahl sein
|
||||
validation.message.email = Muss eine Email-Adresse sein
|
||||
validation.message.alphanumeric = Darf nur Zahlen und Buchstaben enthalten.
|
||||
validation.message.groovy.exception = groovy script '{0}' wirft folgenden Fehler: {1}
|
||||
validation.message.groovy.return.null = groovy script '{0}' meldet "null"
|
||||
@@ -64,14 +65,17 @@ validation.message.date.format = Das Datumsformat entspricht nicht {0}
|
||||
validation.message.regexp = entspricht nicht dem regul\u00e4ren Ausdruck {0}
|
||||
validation.message.uniqueness.multiple = Wert {0} ist nicht einmalig (gefunden in den Zeilen {1})
|
||||
validation.message.uniqueness.single = Wert {0} ist nicht einmalig (gefunden in Zeile {1})
|
||||
validation.message.uri = Muss eine URI sein
|
||||
validation.message.uuid = Muss eine UUID sein
|
||||
validation.message.binary = Muss ein base64 encoded Text sein, der bin\u00e4re Daten enth\u00e4lt
|
||||
|
||||
validation.message.header.length = Anzahl der \u00dcberschriften ist nicht korrekt! Es sind {0} aber es sollten {1} sein
|
||||
validation.message.header.match = \u00dcberschrift in Spalte {0} stimmt nicht. "{1}" sollte "{3}" sein
|
||||
validation.message.value.of = Der Wert {0} ist nicht in der Liste {1} enthalten
|
||||
|
||||
validation.rule.label.not_empty = Nicht leer:
|
||||
validation.rule.label.integer = Zahl:
|
||||
validation.rule.label.double = Gleitkommazahl:
|
||||
validation.rule.label.not_empty = Nicht leer
|
||||
validation.rule.label.integer = Zahl
|
||||
validation.rule.label.double = Gleitkommazahl
|
||||
validation.rule.label.minlength = Minimale L\u00e4nge:
|
||||
validation.rule.label.maxlength = Maximale L\u00e4nge:
|
||||
validation.rule.label.dateformat = Datumsformat:
|
||||
@@ -82,7 +86,9 @@ validation.rule.label.groovy = groovy:
|
||||
validation.rules.active = Aktiv
|
||||
validation.rules.name = Regel
|
||||
validation.rules.value = Wert
|
||||
validation.rule.label.unique = Einmalig in Spalte:
|
||||
validation.rule.label.unique = Einmalig in Spalte
|
||||
validation.rule.format = Format:
|
||||
validation.rule.type = Typ:
|
||||
|
||||
dialog.validation.rules.title = Pr\u00fcfregeln
|
||||
dialog.validation.rules.header = Pr\u00fcfregeln f\u00fcr die Spalte "{0}"
|
||||
@@ -95,3 +101,9 @@ log.header.message = {0} hat {1} Fehler
|
||||
log.message = Zeile {0} Spalte {1} : {2}
|
||||
|
||||
column = Spalte
|
||||
|
||||
format.type.DEFAULT = Standard
|
||||
format.type.EMAIL = Email
|
||||
format.type.URI = URI
|
||||
format.type.BINARY = Bin\u00e4r
|
||||
format.type.UUID = UUID
|
||||
|
||||
@@ -1,73 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?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">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="50.0" prefWidth="50.0" />
|
||||
<ColumnConstraints hgrow="NEVER" />
|
||||
<ColumnConstraints hgrow="ALWAYS" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<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 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>
|
||||
<children>
|
||||
<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.double" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<Label text="%validation.rule.label.minlength" 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="8" />
|
||||
<Label text="%validation.rule.label.alphanumeric" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<Label text="%validation.rule.label.regexp" 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="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="enableIntegerRule" mnemonicParsing="false" 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="enableAlphanumericRule" mnemonicParsing="false" GridPane.rowIndex="4" />
|
||||
<CheckBox fx:id="alphanumericRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||
<CheckBox fx:id="enableUniqueRule" mnemonicParsing="false" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="uniqueRuleCheckBox" mnemonicParsing="false" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="enableMinLengthRule" mnemonicParsing="false" GridPane.rowIndex="6" />
|
||||
<Spinner fx:id="minLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
||||
<CheckBox fx:id="enableMaxLengthRule" mnemonicParsing="false" GridPane.rowIndex="7" />
|
||||
<Spinner fx:id="maxLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="7" />
|
||||
<CheckBox fx:id="enableDateRule" mnemonicParsing="false" GridPane.rowIndex="8" />
|
||||
<TextField fx:id="dateformatRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="8" />
|
||||
<CheckBox fx:id="enableRegexpRule" mnemonicParsing="false" GridPane.rowIndex="9" />
|
||||
<TextField fx:id="regexpRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="9" />
|
||||
<CheckBox fx:id="enableValueOfRule" mnemonicParsing="false" GridPane.rowIndex="10" />
|
||||
<TextField fx:id="valueOfRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="10" />
|
||||
<CheckBox fx:id="enableGroovyRule" mnemonicParsing="false" GridPane.rowIndex="11" />
|
||||
<CodeArea fx:id="groovyRuleTextArea" prefHeight="300.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="11" GridPane.rowSpan="2" />
|
||||
<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.value" GridPane.columnIndex="2" />
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Separator?>
|
||||
<?import javafx.scene.control.Spinner?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import org.fxmisc.richtext.CodeArea?>
|
||||
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
<GridPane hgap="20.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="800.0" vgap="6.0" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="LEFT" hgrow="NEVER" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="NEVER" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<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" valignment="CENTER" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" valignment="TOP" vgrow="ALWAYS" />
|
||||
<RowConstraints />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="%validation.rule.type" GridPane.columnSpan="2" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" />
|
||||
<Label text="%validation.rule.format" GridPane.columnSpan="2" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" />
|
||||
<ComboBox fx:id="typeComboBox" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" />
|
||||
<ComboBox fx:id="formatComboBox" prefWidth="150.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1" visible="false" />
|
||||
<TextField fx:id="formatTextField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1" visible="false" />
|
||||
<CheckBox fx:id="enableNotEmptyRule" mnemonicParsing="false" text="%validation.rule.label.not_empty" GridPane.rowIndex="3" />
|
||||
<CheckBox fx:id="enableUniqueRule" mnemonicParsing="false" text="%validation.rule.label.unique" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||
<CheckBox fx:id="enableMinLengthRule" mnemonicParsing="false" text="%validation.rule.label.minlength" GridPane.rowIndex="4" />
|
||||
<Spinner fx:id="minLengthSpinner" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<CheckBox fx:id="enableMaxLengthRule" mnemonicParsing="false" text="%validation.rule.label.maxlength" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||
<Spinner fx:id="maxLengthSpinner" GridPane.columnIndex="3" GridPane.rowIndex="4" />
|
||||
<CheckBox fx:id="enableRegexpRule" mnemonicParsing="false" text="%validation.rule.label.regexp" GridPane.rowIndex="5" />
|
||||
<TextField fx:id="regexpRuleTextField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="enableValueOfRule" mnemonicParsing="false" text="%validation.rule.label.value_of" GridPane.rowIndex="6" />
|
||||
<TextField fx:id="valueOfRuleTextField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="6" />
|
||||
<CheckBox fx:id="enableGroovyRule" mnemonicParsing="false" text="%validation.rule.label.groovy" GridPane.rowIndex="7">
|
||||
<GridPane.margin>
|
||||
<Insets top="8.0" />
|
||||
</GridPane.margin>
|
||||
</CheckBox>
|
||||
<CodeArea fx:id="groovyRuleTextArea" minHeight="-Infinity" minWidth="-Infinity" prefHeight="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="7">
|
||||
<GridPane.margin>
|
||||
<Insets top="8.0" />
|
||||
</GridPane.margin>
|
||||
</CodeArea>
|
||||
<Separator prefWidth="200.0" GridPane.columnSpan="4" GridPane.rowIndex="2" />
|
||||
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
<stylesheets>
|
||||
<URL value="@/ninja/javafx/smartcsv/fx/smartcsv.css" />
|
||||
</stylesheets>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2016 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,6 +28,7 @@ package ninja.javafx.smartcsv.validation;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -2,6 +2,7 @@ package ninja.javafx.smartcsv.validation;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
Reference in New Issue
Block a user