annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadYearSelect.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5701
diff changeset
9 package org.dive4elements.river.artifacts.states.minfo;
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
11 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
12 import org.apache.logging.log4j.LogManager;
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5701
diff changeset
14 import org.dive4elements.artifacts.Artifact;
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
15
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
16 import org.dive4elements.river.artifacts.D4EArtifact;
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5701
diff changeset
18 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5701
diff changeset
19 import org.dive4elements.river.artifacts.states.DefaultState;
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21
5695
fd020ac6f6cd Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5694
diff changeset
22 /** State in which to fetch years for sedminent load calculation. */
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 public class SedimentLoadYearSelect
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 extends DefaultState
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6101
diff changeset
26 /** The log used in this class. */
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
27 private static Logger log = LogManager.getLogger(SedimentLoadYearSelect.class);
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 /**
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 * The default constructor that initializes an empty State object.
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 */
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 public SedimentLoadYearSelect() {
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 }
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35
5695
fd020ac6f6cd Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5694
diff changeset
36
fd020ac6f6cd Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5694
diff changeset
37 /** Year Select Widget. */
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 @Override
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 protected String getUIProvider() {
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 return "minfo.sedimentload_year_select";
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 }
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
43
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
44 @Override
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
45 public boolean validate(Artifact artifact)
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
46 throws IllegalArgumentException
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
47 {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8591
diff changeset
48 SedimentLoadAccess access =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8591
diff changeset
49 new SedimentLoadAccess((D4EArtifact)artifact);
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
50
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
51 // Second year should be later than first.
8591
9fa5c66073e7 Don't die if only one year is selected for SedimentLoad calculation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8532
diff changeset
52 if (access.getYears() == null || access.getYears().length == 0)
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
53 throw new IllegalArgumentException("error_years_wrong");
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
54
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
55 return true;
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
56 }
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 }
5695
fd020ac6f6cd Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5694
diff changeset
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org