Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java @ 5251:8fa0c522bef3
Improve make_release script to optinally handle tagging and be more generic.
It can now be used to prepare a fully configured version of flys.
There are still some variables to set in the script or to be overwritten by
environment variables.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 12 Mar 2013 16:52:55 +0100 |
parents | 37112235a946 |
children |
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 |
4847
37112235a946
BedQualityAccess: whitespace, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4824
diff
changeset
|
15 /** Access data of artifact used in BedQuality calculations. */ |
37112235a946
BedQualityAccess: whitespace, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4824
diff
changeset
|
16 public class BedQualityAccess |
37112235a946
BedQualityAccess: whitespace, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4824
diff
changeset
|
17 extends RangeAccess { |
3750
e560a9a10eb1
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3749
diff
changeset
|
18 |
3768
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
19 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
|
20 .getLogger(BedQualityAccess.class); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
21 |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
22 private List<String> bedDiameter; |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
23 private List<String> bedloadDiameter; |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
24 private List<DateRange> ranges; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
25 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
26 |
4824
d5d2faf14522
BedHeightQualityAccess, RangeAccess: Refactored, moved getFrom/To to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3780
diff
changeset
|
27 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
|
28 super(artifact, context); |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
29 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
30 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
31 public List<DateRange> getDateRanges() { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
32 if (ranges == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
33 ranges = extractRanges(getString("periods")); |
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 return ranges; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
36 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
37 |
3768
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 bedDiameter = extractDiameter(value); |
3768
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 return bedDiameter; |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
44 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
45 |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 bedloadDiameter = extractDiameter(value); |
3768
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 return bedloadDiameter; |
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 |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
54 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
|
55 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
|
56 String[] dates = dateString.split(";"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
57 for (String s : dates) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
58 String[] pair = s.split(","); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
59 try { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
60 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
|
61 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
|
62 Date first = new Date(l1); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
63 Date second = new Date(l2); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
64 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
|
65 list.add(dr); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
66 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
67 catch (NumberFormatException nfe) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
68 continue; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
69 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
70 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
71 return list; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3750
diff
changeset
|
72 } |
3768
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
73 |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
74 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
|
75 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
|
76 String[] diameter = value.split(";"); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
77 for (String v : diameter) { |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
78 logger.debug("diameter: " + v); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
79 String[] parts = v.split("\\."); |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
80 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
|
81 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
|
82 } |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
83 return result; |
00aafe1fedd7
Added getter for characteristic diameter in bed quality access.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
84 } |
3749
3dcc4feff243
Created the initial structure for MINFO bed quality chart generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 } |
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
|
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |