change editor to the new config

The editor should handle the new configuration
This commit is contained in:
2016-09-01 08:12:26 +02:00
committed by Andreas Billmann
parent 0c391e292e
commit 742f129ea9
5 changed files with 43 additions and 52 deletions

View File

@@ -1,5 +1,7 @@
package ninja.javafx.smartcsv.validation;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Map;
@@ -8,9 +10,18 @@ import java.util.Map;
*/
public class FieldConfiguration {
public enum Type {
@SerializedName("string") STRING,
@SerializedName("integer") INTEGER,
@SerializedName("number") NUMBER,
@SerializedName("date") DATE,
@SerializedName("datetime") DATETIME,
@SerializedName("time") TIME
}
private String name;
private String title;
private String type;
private Type type;
private String description;
private String format;
private Object missingValue;
@@ -32,11 +43,11 @@ public class FieldConfiguration {
this.title = title;
}
public String getType() {
public Type getType() {
return type;
}
public void setType(String type) {
public void setType(Type type) {
this.type = type;
}

View File

@@ -30,7 +30,7 @@ package ninja.javafx.smartcsv.validation;
*/
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, GROOVY }
void check(int row, String value, ValidationError error);
Type getType();
boolean canBeChecked(String value);

View File

@@ -157,25 +157,25 @@ public class Validator {
private void initializeColumnWithRules(FieldConfiguration column) {
if (column.getType() != null) {
if (column.getType().equals("number")) {
if (column.getType() == FieldConfiguration.Type.NUMBER) {
add(column.getName(), new DoubleValidation());
}
if (column.getType().equals("integer")) {
if (column.getType() == FieldConfiguration.Type.INTEGER) {
add(column.getName(), new IntegerValidation());
}
if (column.getType().equals("date")) {
if (column.getType() == FieldConfiguration.Type.DATE) {
String format = dateFormat(column.getFormat(), "YYYY-MM-DD");
add(column.getName(), new DateValidation(format));
}
if (column.getType().equals("datetime")) {
if (column.getType() == FieldConfiguration.Type.DATETIME) {
String format = dateFormat(column.getFormat(), "YYYY-MM-DDThh:mm:ssZ");
add(column.getName(), new DateValidation(format));
}
if (column.getType().equals("time")) {
if (column.getType() == FieldConfiguration.Type.TIME) {
String format = dateFormat(column.getFormat(), "hh:mm:ss");
add(column.getName(), new DateValidation(format));
}