Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java @ 3778:35a6c9a49a76
Fixed wrong assigned loggers.
flys-artifacts/trunk@5485 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 16 Sep 2012 20:11:37 +0000 |
parents | 048a02e29808 |
children | 7fa38f8bcd8d |
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 |
3749
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 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
|
10 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
|
11 |
3749
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
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
|
13 public class BedQualityAccess extends RiverAccess { |
3750
e560a9a10eb1
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3749
diff
changeset
|
14 |
3768
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
15 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
|
16 .getLogger(BedQualityAccess.class); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
17 |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
18 private Double from; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
19 private Double to; |
3768
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 |
3749
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 public BedQualityAccess(FLYSArtifact artifact) { |
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 super(artifact); |
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 } |
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 public double getFrom() { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
29 if (from == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
30 from = getDouble("ld_from"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
31 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
32 return from.doubleValue(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
33 } |
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 public double getTo() { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
36 if (to == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
37 to = getDouble("ld_to"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
38 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
39 return to.doubleValue(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
40 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
41 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
42 public List<DateRange> getDateRanges() { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
43 if (ranges == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
44 ranges = extractRanges(getString("periods")); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
45 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
46 return ranges; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
47 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
48 |
3768
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
49 public List<String> getBedDiameter() { |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
50 if (bedDiameter == null) { |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
51 bedDiameter = extractDiameter(getString("bed_diameter")); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
52 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
53 return bedDiameter; |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
54 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
55 |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
56 public List<String> getBedloadDiameter() { |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
57 if (bedloadDiameter == null) { |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
58 bedloadDiameter = extractDiameter(getString("load_diameter")); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
59 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
60 return bedloadDiameter; |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
61 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
62 |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
63 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
|
64 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
|
65 String[] dates = dateString.split(";"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
66 for (String s : dates) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
67 String[] pair = s.split(","); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
68 try { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
69 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
|
70 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
|
71 Date first = new Date(l1); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
72 Date second = new Date(l2); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
73 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
|
74 list.add(dr); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
75 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
76 catch (NumberFormatException nfe) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
77 continue; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
78 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
79 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
80 return list; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
81 } |
3768
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
82 |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
83 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
|
84 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
|
85 String[] diameter = value.split(";"); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
86 for (String v : diameter) { |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
87 logger.debug("diameter: " + v); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
88 String[] parts = v.split("\\."); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
89 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
|
90 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
|
91 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
92 return result; |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
93 } |
3749
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 } |
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
|
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |