annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java @ 4842:97a0fa4dff8e

Use isDebugEnabled() in S/Q Measurement factory.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 23 Jan 2013 17:36:18 +0100
parents d5d2faf14522
children 37112235a946
rev   line source
3749
3dcc4feff243 Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.access;
3dcc4feff243 Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
3760
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
3 import java.util.Date;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
4 import java.util.LinkedList;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
5 import java.util.List;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
6
3768
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
7 import org.apache.log4j.Logger;
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
8
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3780
diff changeset
9 import de.intevation.artifacts.CallContext;
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3780
diff changeset
10
3749
3dcc4feff243 Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.flys.artifacts.FLYSArtifact;
3760
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
12 import de.intevation.flys.artifacts.model.DateRange;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
13
3749
3dcc4feff243 Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3780
diff changeset
15 public class BedQualityAccess extends RangeAccess {
3750
e560a9a10eb1 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3749
diff changeset
16
3768
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
17 private static final Logger logger = Logger
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
18 .getLogger(BedQualityAccess.class);
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
19
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
20 private List<String> bedDiameter;
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
21 private List<String> bedloadDiameter;
3760
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
22 private List<DateRange> ranges;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
23
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
24
4824
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3780
diff changeset
25 public BedQualityAccess(FLYSArtifact artifact, CallContext context) {
d5d2faf14522 BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3780
diff changeset
26 super(artifact, context);
3760
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
27 }
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
28
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
29 public List<DateRange> getDateRanges() {
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
30 if (ranges == null) {
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
31 ranges = extractRanges(getString("periods"));
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
32 }
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
33 return ranges;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
34 }
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
35
3768
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
36 public List<String> getBedDiameter() {
3780
7fa38f8bcd8d Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3777
diff changeset
37 String value = getString("bed_diameter");
7fa38f8bcd8d Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3777
diff changeset
38 if (bedDiameter == null && value != null) {
7fa38f8bcd8d Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3777
diff changeset
39 bedDiameter = extractDiameter(value);
3768
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
40 }
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
41 return bedDiameter;
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
42 }
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
43
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
44 public List<String> getBedloadDiameter() {
3780
7fa38f8bcd8d Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3777
diff changeset
45 String value = getString("load_diameter");
7fa38f8bcd8d Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3777
diff changeset
46 if (bedloadDiameter == null && value != null) {
7fa38f8bcd8d Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3777
diff changeset
47 bedloadDiameter = extractDiameter(value);
3768
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
48 }
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
49 return bedloadDiameter;
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
50 }
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
51
3760
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
52 private List<DateRange> extractRanges(String dateString) {
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
53 List<DateRange> list = new LinkedList<DateRange>();
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
54 String[] dates = dateString.split(";");
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
55 for (String s : dates) {
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
56 String[] pair = s.split(",");
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
57 try {
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
58 long l1 = Long.parseLong(pair[0]);
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
59 long l2 = Long.parseLong(pair[1]);
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
60 Date first = new Date(l1);
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
61 Date second = new Date(l2);
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
62 DateRange dr = new DateRange(first, second);
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
63 list.add(dr);
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
64 }
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
65 catch (NumberFormatException nfe) {
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
66 continue;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
67 }
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
68 }
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
69 return list;
312870fded7e Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3750
diff changeset
70 }
3768
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
71
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
72 private List<String> extractDiameter(String value) {
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
73 List<String> result = new LinkedList<String>();
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
74 String[] diameter = value.split(";");
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
75 for (String v : diameter) {
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
76 logger.debug("diameter: " + v);
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
77 String[] parts = v.split("\\.");
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
78 result.add(parts[parts.length - 1]);
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
79 logger.debug(parts[parts.length-1]);
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
80 }
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
81 return result;
00aafe1fedd7 Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3760
diff changeset
82 }
3749
3dcc4feff243 Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3768
diff changeset
84 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org