Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java @ 1118:c01c220312d0
Made it compile again with an updated ArtifactDatabase.
gnv-artifacts/trunk@4137 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 12 Mar 2012 08:31:46 +0000 |
parents | f953c9a559d8 |
children |
rev | line source |
---|---|
1115
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
1 /* |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
3 * |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
7 */ |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
8 |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.gnv.utils; |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
11 import com.vividsolutions.jts.geom.Coordinate; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
12 import com.vividsolutions.jts.geom.GeometryFactory; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
13 import com.vividsolutions.jts.geom.Point; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
14 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
15 import com.vividsolutions.jts.io.ParseException; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
16 import com.vividsolutions.jts.io.WKTReader; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
17 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
18 import de.intevation.gnv.geobackend.util.DateUtils; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
19 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
20 import de.intevation.gnv.utils.exception.ValidationException; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
21 |
252
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
22 import java.util.Date; |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
23 |
116
820238357bab
Added Horizontal-Profile-Support for Meshes.
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
24 import org.apache.commons.validator.GenericValidator; |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
26 import org.apache.log4j.Logger; |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 /** |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
29 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
785
e764cab8c885
Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
31 * |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 */ |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 public class InputValidator { |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 /** |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 * the logger, used to log exceptions and additonaly information |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 */ |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 private static Logger log = Logger.getLogger(InputValidator.class); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
38 |
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
39 |
222
3e82b4f1c455
Removed some Compilation-Errors according to API-Changes in the ArtifactDatabase.
Tim Englich <tim.englich@intevation.de>
parents:
173
diff
changeset
|
40 public final static String NODATASELECTEDVALUE = "n/n"; |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 /** |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 * Constructor |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 */ |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
45 public InputValidator() { |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 super(); |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
48 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
49 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
50 * Validates the input of a range of double or date values. The input values |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
51 * need to be valid double or date values. <i>minInput</i> needs to be |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
52 * smaller or equal <i>maxInput</i>. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
53 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
54 * @param minInput The lower bound. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
55 * @param maxInput The upper bound. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
56 * @param type One of 'Date' or 'Double'. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
57 * @return true, if the input is valid, otherwise false. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
58 */ |
785
e764cab8c885
Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
59 public static boolean isInputValid(String minInput, String maxInput, String type) { |
252
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
60 log.debug("InputValidator.isInputValid " + minInput + " " + maxInput + " " +type); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
61 boolean returnValue = false; |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
62 if ("Date".equalsIgnoreCase(type)) { |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
63 try { |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
64 Date min = DateUtils.getDateFromString(minInput,DateUtils.DATE_PATTERN); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
65 Date max = DateUtils.getDateFromString(maxInput,DateUtils.DATE_PATTERN); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
66 int value = max.compareTo(min); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
67 returnValue = value >= 0; |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
68 } catch (Exception e) { |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
69 log.error(e,e); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
70 } |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
71 } else if ("Double".equalsIgnoreCase(type)) { |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
72 try { |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
73 double min = Double.parseDouble(minInput); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
74 double max = Double.parseDouble(maxInput); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
75 returnValue = max >= min; |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
76 } catch (Exception e) { |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
77 log.error(e,e); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
78 } |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
79 } |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
80 log.debug("Is valid? " + returnValue); |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
81 return returnValue; |
f1e7ddeef5bc
Added Validation if a given maxvalue is greater than a given minvalue issue19
Tim Englich <tim.englich@intevation.de>
parents:
222
diff
changeset
|
82 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
83 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
84 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
85 * Validates an input. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
86 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
87 * @param input The input value. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
88 * @param type The input value type. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
89 * @return true if the input is valid, otherwise false. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
90 */ |
785
e764cab8c885
Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
91 public static boolean isInputValid(String input, String type) { |
860
f94a95009423
Improved the input validator: empty strings are invalid (issue251).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
836
diff
changeset
|
92 if (input.length() == 0 || input.equals("")) { |
f94a95009423
Improved the input validator: empty strings are invalid (issue251).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
836
diff
changeset
|
93 return false; |
f94a95009423
Improved the input validator: empty strings are invalid (issue251).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
836
diff
changeset
|
94 } |
f94a95009423
Improved the input validator: empty strings are invalid (issue251).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
836
diff
changeset
|
95 |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
96 log.debug("InputValidator.isInputValid " + input + " " + type); |
787
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
97 |
803
feae2f9d6c6f
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
98 // Let's check polygons and linestrings first, because they might |
787
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
99 // contain comma. A splitting at comma characters wouldn't be good here. |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
100 if ("Polygon".equalsIgnoreCase(type) || "Linestring".equalsIgnoreCase(type)) |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
101 { |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
102 try { |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
103 WKTReader reader = new WKTReader(); |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
104 reader.read(input); |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
105 |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
106 return true; |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
107 } |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
108 catch (ParseException pe) { |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
109 log.warn(pe, pe); |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
110 return false; |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
111 } |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
112 } |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
113 |
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
114 // Check all the other input here |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
115 boolean returnValue = false; |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
116 String[] values = input.split(","); |
787
6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
785
diff
changeset
|
117 |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
118 for (int i = 0; i < values.length; i++) { |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
119 boolean valid; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
120 |
222
3e82b4f1c455
Removed some Compilation-Errors according to API-Changes in the ArtifactDatabase.
Tim Englich <tim.englich@intevation.de>
parents:
173
diff
changeset
|
121 if (NODATASELECTEDVALUE.equals(values[i].trim())){ |
3e82b4f1c455
Removed some Compilation-Errors according to API-Changes in the ArtifactDatabase.
Tim Englich <tim.englich@intevation.de>
parents:
173
diff
changeset
|
122 valid = true; |
3e82b4f1c455
Removed some Compilation-Errors according to API-Changes in the ArtifactDatabase.
Tim Englich <tim.englich@intevation.de>
parents:
173
diff
changeset
|
123 } else if ("Integer".equalsIgnoreCase(type)) { |
115
158e89c2263b
Removed needless imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
113
diff
changeset
|
124 valid = GenericValidator.isInt(values[i].trim()); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
125 } else if ("Double".equalsIgnoreCase(type)) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
126 valid = GenericValidator.isDouble(values[i].trim()); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
127 } else if ("String".equalsIgnoreCase(type)) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
128 valid = GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
129 // FIXME: |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
130 // VALIDATE |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
131 // REGEXP |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
132 } else if ("Date".equalsIgnoreCase(type)) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
133 valid = GenericValidator.isDate(values[i].trim(), |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
134 DateUtils.DATE_PATTERN, true); |
731
1efb6a66c7d9
Added Objecttype Geometry for the Validation of Inputdata.
Tim Englich <tim.englich@intevation.de>
parents:
461
diff
changeset
|
135 } else if ("Point".equalsIgnoreCase(type) || "Geometry".equals(type)) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
136 valid = GenericValidator.matchRegexp(values[i], "[0-9]"); // TODO: |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
137 // FIXME: |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
138 // VALIDATE |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
139 // REGEXP |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
140 } else if ("AttributeName".equalsIgnoreCase(type)) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
141 valid = org.apache.commons.validator.GenericValidator |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
142 .matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
143 // VALIDATE |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
144 // REGEXP |
173
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
145 } else if ("Coordinate".equalsIgnoreCase(type)) { |
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
146 try { |
785
e764cab8c885
Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
147 valid = getPointValue(values[i]) != null; |
173
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
148 } catch (ValidationException e) { |
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
149 log.debug(e.getMessage()); |
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
150 valid = false; |
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
151 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
152 } else { |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
153 valid = false; |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
154 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
155 if (!valid) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
156 returnValue = false; |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
157 break; |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
158 } else { |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
159 returnValue = true; |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
160 } |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
161 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
162 log.debug("Is valid? " + returnValue); |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
163 return returnValue; |
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
164 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
165 |
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
166 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
167 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
168 * Returns a point from wkt string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
169 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
170 * @param value The wkt string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
171 * @return a point. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
172 * @throws ValidationException if <i>value</i> is not valid. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
173 */ |
785
e764cab8c885
Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
174 public static Point getPointValue(String value) throws ValidationException{ |
173
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
175 log.debug("InputValidator.getPointValue " + value); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
176 |
746
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
177 if (value.toLowerCase().startsWith("point")){ |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
178 try { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
179 return (Point)new WKTReader().read(value); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
180 } catch (ParseException e) { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
181 log.error(e,e); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
182 throw new ValidationException(e); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
183 } |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
184 }else{ |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
185 String[] s, p; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
186 |
746
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
187 double x=0,y=0; |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
188 log.info("Position :"+value); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
189 s = value.split(" "); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
190 if (s.length != 2) { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
191 throw new ValidationException("Kein Blank separiert Breite und Länge"); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
192 } |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
193 p = s[0].split("[nNsS]"); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
194 try { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
195 if (p.length == 1) |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
196 y = new Double(p[0]); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
197 else |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
198 y = new Double(p[0]) + new Double(p[1]) / new Double(60.); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
199 if (s[0].toLowerCase().contains("s")) |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
200 y = -y; |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
201 } |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
202 catch (Exception e) { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
203 throw new ValidationException("Kein N|S oder nicht im ersten Substring, zB 56n42"); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
204 |
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
205 } |
746
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
206 p = s[1].split("[eEwW]"); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
207 try { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
208 if (p.length ==1) |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
209 x = new Double(p[0]); |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
210 else |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
211 x = new Double(p[0]) + new Double(p[1]) / new Double(60.) ; |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
212 if (s[1].toLowerCase().contains("w")) |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
213 x = -x; |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
214 } |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
215 catch (Exception e) { |
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
216 throw new ValidationException("Kein E|W oder nicht im zweiten Substring"); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
746
diff
changeset
|
217 } |
746
b81f6f896668
Integrated handling of WKT-Strings for Points to extract Points from a given Inputstring.
Tim Englich <tim.englich@intevation.de>
parents:
731
diff
changeset
|
218 return new GeometryFactory().createPoint(new Coordinate(x,y)); |
173
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
219 } |
1b2fc94766c9
Added real Coordinate-Query to TimeSeries-Mesh
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
220 } |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
221 |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
222 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
223 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
224 * Makes sure that <i>tmp</i> is between <i>lo</i> and <i>up</i>. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
225 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
226 * @param tmp The value to validate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
227 * @param lo The lower range bound. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
228 * @param up The upper range bound. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
229 * @return true, if tmp is valid, otherwise false. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
803
diff
changeset
|
230 */ |
785
e764cab8c885
Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
231 public static boolean isDateValid(Date tmp, Date lo, Date up) { |
1088
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
232 // take the time in seconds to compare |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
233 long tmpTime = tmp.getTime() / 1000; |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
234 long tmpLow = lo.getTime() / 1000; |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
235 long tmpUp = up.getTime() / 1000; |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
236 |
1088
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
237 if (log.isDebugEnabled()) { |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
238 log.debug("Date validation..."); |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
239 log.debug("-> lower bound [sec]: " + tmpLow); |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
240 log.debug("-> upper bound [sec]: " + tmpUp); |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
241 log.debug("-> input data [sec]: " + tmpTime); |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
242 } |
46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
243 |
1109
2b4d197a538c
Fixed the time range validation - introduced an epsilon of one second for valid time ranges (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1088
diff
changeset
|
244 // XXX There is a buffer of 1 second for the valid range of the time. |
2b4d197a538c
Fixed the time range validation - introduced an epsilon of one second for valid time ranges (issue286).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1088
diff
changeset
|
245 if (tmpTime < (tmpLow-1) || tmpTime > (tmpUp+1)) { |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
246 log.warn( |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
247 "Date [" + tmp.toString() + "] is out of range [" |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
248 + lo.toString() + " to "+ up.toString() + "]."); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
249 return false; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
250 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
251 |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
252 return true; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
253 } |
101
e01c163ea5b0
Inputvalidation for String, Integer and Date Values added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
254 } |
836
05bf8534a35a
Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
806
diff
changeset
|
255 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |