Revize b07f6ea7
Přidáno uživatelem Michal Linha před téměř 4 roky(ů)
src/main/java/vldc/aswi/validators/ConfigurationValidator.java | ||
---|---|---|
29 | 29 |
return Configuration.class.isAssignableFrom(aClass); |
30 | 30 |
} |
31 | 31 |
|
32 |
/** |
|
33 |
* Validates the given configuration object. |
|
34 |
* @param obj Configuration object to be validated. |
|
35 |
* @param errors Errors variable where errors are stored. |
|
36 |
*/ |
|
32 | 37 |
@Override |
33 | 38 |
public void validate(Object obj, Errors errors) { |
34 | 39 |
Configuration configuration = (Configuration) obj; |
... | ... | |
56 | 61 |
|
57 | 62 |
} |
58 | 63 |
|
64 |
/** |
|
65 |
* Validates BETWEEN and NOT BETWEEN operator. |
|
66 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
67 |
* @param errors Errors variable where errors are stored. |
|
68 |
* @param i Index of the parameter. |
|
69 |
* @param operator Operator of the parameter in configuration. |
|
70 |
*/ |
|
59 | 71 |
private void validateBETWEEN(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
60 | 72 |
if (!parameterInConfiguration.getOperatorValue().matches("\\w+;\\w+")) { |
61 | 73 |
errors.rejectValue("parametersInConfiguration[" + i + "].operatorValue", "Nesprávně oddělené hodnoty" + |
... | ... | |
66 | 78 |
} |
67 | 79 |
} |
68 | 80 |
|
81 |
/** |
|
82 |
* Validates values in list. |
|
83 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
84 |
* @param errors Errors variable where errors are stored. |
|
85 |
* @param i Index of the parameter. |
|
86 |
* @param operator Operator of the parameter in configuration. |
|
87 |
*/ |
|
69 | 88 |
private void validateValuesInList(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
70 | 89 |
String[] values = parameterInConfiguration.getOperatorValue().split(";"); |
71 | 90 |
for (String value : values) { |
... | ... | |
78 | 97 |
} |
79 | 98 |
} |
80 | 99 |
|
100 |
/** |
|
101 |
* Validates IN and NOT IN operator. |
|
102 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
103 |
* @param errors Errors variable where errors are stored. |
|
104 |
* @param i Index of the parameter. |
|
105 |
* @param operator Operator of the parameter in configuration. |
|
106 |
*/ |
|
81 | 107 |
private void validateIN(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
82 | 108 |
if (!parameterInConfiguration.getOperatorValue().matches("\\w+(;\\w+)*$")) { |
83 | 109 |
errors.rejectValue("parametersInConfiguration[" + i + "].operatorValue", "Špatně zadaná hodnota" + |
... | ... | |
88 | 114 |
} |
89 | 115 |
} |
90 | 116 |
|
117 |
/** |
|
118 |
* Validates other operators. |
|
119 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
120 |
* @param errors Errors variable where errors are stored. |
|
121 |
* @param i Index of the parameter. |
|
122 |
* @param operator Operator of the parameter in configuration. |
|
123 |
*/ |
|
91 | 124 |
private void validateOthersExceptLIKE(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
92 | 125 |
if (parameterInConfiguration.getParameter().getParameterType().getName().equals("Datum")) { |
93 | 126 |
validateDate(parameterInConfiguration.getOperatorValue(), errors, i, operator); |
... | ... | |
97 | 130 |
} |
98 | 131 |
} |
99 | 132 |
|
133 |
/** |
|
134 |
* Validates numeric value. |
|
135 |
* @param value Value to be validated. |
|
136 |
* @param errors Errors variable where errors are stored. |
|
137 |
* @param i Index of hte parameter. |
|
138 |
* @param operator operator Operator of the parameter in configuration. |
|
139 |
*/ |
|
100 | 140 |
private void validateNumber(String value, Errors errors, int i, String operator) { |
101 | 141 |
if (!value.matches("-?\\d+(\\.\\d+)?")) { |
102 | 142 |
errors.rejectValue("parametersInConfiguration[" + i + "].operatorValue", "Špatně zadaná hodnota" + |
... | ... | |
104 | 144 |
} |
105 | 145 |
} |
106 | 146 |
|
147 |
/** |
|
148 |
* Validates date value. |
|
149 |
* @param value Value to be validated. |
|
150 |
* @param errors Errors variable where errors are stored. |
|
151 |
* @param i Index of hte parameter. |
|
152 |
* @param operator operator Operator of the parameter in configuration. |
|
153 |
*/ |
|
107 | 154 |
private void validateDate(String value, Errors errors, int i, String operator) { |
108 | 155 |
try { |
109 | 156 |
new SimpleDateFormat("yyyy-MM-dd").parse(value); |
Také k dispozici: Unified diff
re #7885 #8134re #8154 re #8136 added comments and connected switch to allow user to set if he wants to see empty rows or columns in the final table