Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java @ 3992:a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 30 Sep 2012 21:15:23 +0200 |
parents | a4930c43b806 |
children | ab3a4ad82ae1 |
comparison
equal
deleted
inserted
replaced
3991:3a1cac4bfe70 | 3992:a9c93b7c9da1 |
---|---|
1 package de.intevation.flys.artifacts.model.sq; | 1 package de.intevation.flys.artifacts.model.sq; |
2 | 2 |
3 import java.util.ArrayList; | |
3 import java.util.List; | 4 import java.util.List; |
4 | 5 |
5 import de.intevation.flys.artifacts.model.DateRange; | 6 import de.intevation.flys.artifacts.model.DateRange; |
6 | 7 |
7 import de.intevation.flys.backend.SedDBSessionHolder; | 8 import de.intevation.flys.backend.SedDBSessionHolder; |
33 "m.TSAND AS TSAND," + | 34 "m.TSAND AS TSAND," + |
34 "gp.MESSDAUER AS MESSDAUER," + | 35 "gp.MESSDAUER AS MESSDAUER," + |
35 "gp.MENGE AS MENGE," + | 36 "gp.MENGE AS MENGE," + |
36 "gp.GTRIEB AS GTRIEB," + | 37 "gp.GTRIEB AS GTRIEB," + |
37 "m.TGESCHIEBE AS TGESCHIEBE," + | 38 "m.TGESCHIEBE AS TGESCHIEBE," + |
39 "sie.SIEB01 AS SIEB01," + | |
40 "sie.SIEB02 AS SIEB02," + | |
41 "sie.SIEB03 AS SIEB03," + | |
42 "sie.SIEB04 AS SIEB04," + | |
43 "sie.SIEB05 AS SIEB05," + | |
44 "sie.SIEB06 AS SIEB06," + | |
45 "sie.SIEB07 AS SIEB07," + | |
46 "sie.SIEB08 AS SIEB08," + | |
47 "sie.SIEB09 AS SIEB09," + | |
48 "sie.SIEB10 AS SIEB10," + | |
49 "sie.SIEB11 AS SIEB11," + | |
50 "sie.SIEB12 AS SIEB12," + | |
51 "sie.SIEB13 AS SIEB13," + | |
52 "sie.SIEB14 AS SIEB14," + | |
53 "sie.SIEB15 AS SIEB15," + | |
54 "sie.SIEB16 AS SIEB16," + | |
55 "sie.SIEB17 AS SIEB17," + | |
56 "sie.SIEB18 AS SIEB18," + | |
57 "sie.SIEB19 AS SIEB19," + | |
58 "sie.SIEB20 AS SIEB20," + | |
59 "sie.SIEB21 AS SIEB21," + | |
38 "gs.RSIEB01 AS RSIEB01," + | 60 "gs.RSIEB01 AS RSIEB01," + |
39 "gs.RSIEB02 AS RSIEB02," + | 61 "gs.RSIEB02 AS RSIEB02," + |
40 "gs.RSIEB03 AS RSIEB03," + | 62 "gs.RSIEB03 AS RSIEB03," + |
41 "gs.RSIEB04 AS RSIEB04," + | 63 "gs.RSIEB04 AS RSIEB04," + |
42 "gs.RSIEB05 AS RSIEB05," + | 64 "gs.RSIEB05 AS RSIEB05," + |
54 "gs.RSIEB17 AS RSIEB17," + | 76 "gs.RSIEB17 AS RSIEB17," + |
55 "gs.RSIEB18 AS RSIEB18," + | 77 "gs.RSIEB18 AS RSIEB18," + |
56 "gs.RSIEB19 AS RSIEB19," + | 78 "gs.RSIEB19 AS RSIEB19," + |
57 "gs.RSIEB20 AS RSIEB20," + | 79 "gs.RSIEB20 AS RSIEB20," + |
58 "gs.RSIEB21 AS RSIEB21," + | 80 "gs.RSIEB21 AS RSIEB21," + |
59 "gs.REST AS REST, " + | 81 "gs.REST AS REST " + |
60 "COALESCE(sie.SIEB01, 0) AS SIEB01, " + | |
61 "COALESCE(sie.SIEB02, 0) AS SIEB02, " + | |
62 "COALESCE(sie.SIEB03, 0) AS SIEB03, " + | |
63 "COALESCE(sie.SIEB04, 0) AS SIEB04, " + | |
64 "COALESCE(sie.SIEB05, 0) AS SIEB05, " + | |
65 "COALESCE(sie.SIEB06, 0) AS SIEB06, " + | |
66 "COALESCE(sie.SIEB07, 0) AS SIEB07, " + | |
67 "COALESCE(sie.SIEB08, 0) AS SIEB08, " + | |
68 "COALESCE(sie.SIEB09, 0) AS SIEB09, " + | |
69 "COALESCE(sie.SIEB10, 0) AS SIEB10, " + | |
70 "COALESCE(sie.SIEB11, 0) AS SIEB11, " + | |
71 "COALESCE(sie.SIEB12, 0) AS SIEB12, " + | |
72 "COALESCE(sie.SIEB13, 0) AS SIEB13, " + | |
73 "COALESCE(sie.SIEB14, 0) AS SIEB14, " + | |
74 "COALESCE(sie.SIEB15, 0) AS SIEB15, " + | |
75 "COALESCE(sie.SIEB16, 0) AS SIEB16, " + | |
76 "COALESCE(sie.SIEB17, 0) AS SIEB17, " + | |
77 "COALESCE(sie.SIEB18, 0) AS SIEB18, " + | |
78 "COALESCE(sie.SIEB19, 0) AS SIEB19, " + | |
79 "COALESCE(sie.SIEB20, 0) AS SIEB20, " + | |
80 "COALESCE(sie.SIEB21, 0) AS SIEB21 " + | |
81 "FROM MESSUNG m " + | 82 "FROM MESSUNG m " + |
82 "JOIN STATION s ON m.STATIONID = s.STATIONID " + | 83 "JOIN STATION s ON m.STATIONID = s.STATIONID " + |
83 "JOIN glotrechte g ON m.MESSUNGID = g.MESSUNGID " + | 84 "JOIN glotrechte g ON m.MESSUNGID = g.MESSUNGID " + |
84 "JOIN gprobe gp ON g.GLOTRECHTEID = gp.GLOTRECHTEID " + | 85 "JOIN gprobe gp ON g.GLOTRECHTEID = gp.GLOTRECHTEID " + |
85 "JOIN GSIEBUNG gs ON g.GLOTRECHTEID = gs.GLOTRECHTEID " + | 86 "JOIN GSIEBUNG gs ON g.GLOTRECHTEID = gs.GLOTRECHTEID " + |
110 new MeasurementResultTransformer(); | 111 new MeasurementResultTransformer(); |
111 | 112 |
112 public MeasurementResultTransformer() { | 113 public MeasurementResultTransformer() { |
113 } | 114 } |
114 | 115 |
116 private static final int index(String s) { | |
117 return Integer.parseInt(s.substring(s.length()-2))-1; | |
118 } | |
119 | |
115 @Override | 120 @Override |
116 public Object transformTuple(Object [] tuple, String [] aliases) { | 121 public Object transformTuple(Object [] tuple, String [] aliases) { |
117 Map<String, Object> map = new HashMap<String, Object>(); | 122 Map<String, Object> map = new HashMap<String, Object>(); |
123 | |
124 Sieve [] sieves = new Sieve[20]; | |
125 | |
126 List<Sieve> validSieves = new ArrayList<Sieve>(20); | |
127 | |
118 for (int i = 0; i < tuple.length; ++i) { | 128 for (int i = 0; i < tuple.length; ++i) { |
119 if (tuple[i] != null) { | 129 Object value = tuple[i]; |
120 map.put(aliases[i], tuple[i]); | 130 if (value == null) { |
131 continue; | |
132 } | |
133 String alias = aliases[i]; | |
134 if (alias.startsWith("SIEB")) { | |
135 Sieve s = new Sieve((Double)value, 0d); | |
136 sieves[index(alias)] = s; | |
137 } | |
138 else if (alias.startsWith("RSIEB")) { | |
139 Sieve s = sieves[index(alias)]; | |
140 if (s != null) { | |
141 s.setLoad((Double)value); | |
142 validSieves.add(s); | |
143 } | |
144 } | |
145 else if (alias.equals("REST")) { | |
146 Sieve s = new Sieve(0d, (Double)value); | |
147 validSieves.add(s); | |
148 } | |
149 else { | |
150 map.put(alias, value); | |
121 } | 151 } |
122 } | 152 } |
123 return new Measurement(map); | 153 |
154 return new Measurement(map, validSieves); | |
124 } | 155 } |
125 } // class BasicTransformerAdapter | 156 } // class BasicTransformerAdapter |
126 | 157 |
127 private MeasurementFactory() { | 158 private MeasurementFactory() { |
128 } | 159 } |