Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/importer/laf/LafWriter.java @ 1028:1c41c7b8f7c2 schema-update
Updated server application to new database model. THIS IS STILL WIP!!!
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 08 Jul 2016 15:32:36 +0200 |
parents | fa922101a462 |
children |
comparison
equal
deleted
inserted
replaced
1027:9971471d562c | 1028:1c41c7b8f7c2 |
---|---|
13 | 13 |
14 import javax.inject.Inject; | 14 import javax.inject.Inject; |
15 import javax.persistence.PersistenceException; | 15 import javax.persistence.PersistenceException; |
16 | 16 |
17 import de.intevation.lada.importer.ReportItem; | 17 import de.intevation.lada.importer.ReportItem; |
18 import de.intevation.lada.model.land.LKommentarM; | 18 import de.intevation.lada.model.land.KommentarM; |
19 import de.intevation.lada.model.land.LKommentarP; | 19 import de.intevation.lada.model.land.KommentarP; |
20 import de.intevation.lada.model.land.LMessung; | 20 import de.intevation.lada.model.land.Messung; |
21 import de.intevation.lada.model.land.LMesswert; | 21 import de.intevation.lada.model.land.Messwert; |
22 import de.intevation.lada.model.land.LOrtszuordnung; | 22 import de.intevation.lada.model.land.Ortszuordnung; |
23 import de.intevation.lada.model.land.LProbe; | 23 import de.intevation.lada.model.land.Probe; |
24 import de.intevation.lada.model.land.MessungTranslation; | 24 import de.intevation.lada.model.stammdaten.Ort; |
25 import de.intevation.lada.model.land.ProbeTranslation; | |
26 import de.intevation.lada.model.stamm.Ort; | |
27 import de.intevation.lada.util.annotation.AuthorizationConfig; | 25 import de.intevation.lada.util.annotation.AuthorizationConfig; |
28 import de.intevation.lada.util.annotation.RepositoryConfig; | 26 import de.intevation.lada.util.annotation.RepositoryConfig; |
29 import de.intevation.lada.util.auth.Authorization; | 27 import de.intevation.lada.util.auth.Authorization; |
30 import de.intevation.lada.util.auth.AuthorizationType; | 28 import de.intevation.lada.util.auth.AuthorizationType; |
31 import de.intevation.lada.util.auth.UserInfo; | 29 import de.intevation.lada.util.auth.UserInfo; |
82 * | 80 * |
83 * @param auth The authentication information. | 81 * @param auth The authentication information. |
84 * @param probe The new {@link LProbe} object. | 82 * @param probe The new {@link LProbe} object. |
85 * @return success | 83 * @return success |
86 */ | 84 */ |
87 public boolean writeProbe(UserInfo userInfo, LProbe probe, ProbeTranslation probeTranslation) { | 85 public boolean writeProbe(UserInfo userInfo, Probe probe) { |
88 if (!authorization.isAuthorized(userInfo, probe, LProbe.class)) { | 86 if (!authorization.isAuthorized(userInfo, probe, Probe.class)) { |
89 errors.add(new ReportItem("auth", "not authorized", 699)); | 87 errors.add(new ReportItem("auth", "not authorized", 699)); |
90 return false; | 88 return false; |
91 } | 89 } |
92 if (probeTranslation.getProbeIdAlt() == null) { | 90 if (probe.getIdAlt() == null) { |
93 errors.add(new ReportItem("probeId", "missing", 673)); | 91 errors.add(new ReportItem("probeId", "missing", 673)); |
94 return false; | 92 return false; |
95 } | 93 } |
96 try { | 94 try { |
97 repository.create(probe, "land"); | 95 repository.create(probe, "land"); |
98 probeTranslation.setProbeId(probe); | |
99 this.currentProbeId = probe.getId(); | 96 this.currentProbeId = probe.getId(); |
100 repository.create(probeTranslation, "land"); | |
101 } | 97 } |
102 catch (PersistenceException e) { | 98 catch (PersistenceException e) { |
103 errors.add(new ReportItem("probe", "writing", 670)); | 99 errors.add(new ReportItem("probe", "writing", 670)); |
104 return false; | 100 return false; |
105 } | 101 } |
114 * @param messungen The new {@link LMessung} objects. | 110 * @param messungen The new {@link LMessung} objects. |
115 * @return success | 111 * @return success |
116 */ | 112 */ |
117 public boolean writeMessungen( | 113 public boolean writeMessungen( |
118 UserInfo userInfo, | 114 UserInfo userInfo, |
119 LMessung messung, | 115 Messung messung |
120 MessungTranslation messungTranslation | |
121 ) { | 116 ) { |
122 messung.setProbeId(this.currentProbeId); | 117 messung.setProbeId(this.currentProbeId); |
123 repository.create(messung, "land"); | 118 repository.create(messung, "land"); |
124 messungTranslation.setMessungsId(messung); | |
125 repository.create(messungTranslation, "land"); | |
126 return true; | 119 return true; |
127 } | 120 } |
128 | 121 |
129 /** | 122 /** |
130 * Write new {@link SOrt} objects to the database. | 123 * Write new {@link SOrt} objects to the database. |
142 * | 135 * |
143 * @param auth The authentication information. | 136 * @param auth The authentication information. |
144 * @param orte List of {@link LOrt} objects. | 137 * @param orte List of {@link LOrt} objects. |
145 * @return success | 138 * @return success |
146 */ | 139 */ |
147 public boolean writeLOrte(UserInfo userInfo, LOrtszuordnung ort) { | 140 public boolean writeOrtszuordung(UserInfo userInfo, Ortszuordnung ort) { |
148 ort.setProbeId(this.currentProbeId); | 141 ort.setProbeId(this.currentProbeId); |
149 repository.create(ort, "land"); | 142 repository.create(ort, "land"); |
150 return true; | 143 return true; |
151 } | 144 } |
152 | 145 |
157 * @param kommentare List of {@link LKommentarP} objects. | 150 * @param kommentare List of {@link LKommentarP} objects. |
158 * @return success | 151 * @return success |
159 */ | 152 */ |
160 public boolean writeProbenKommentare( | 153 public boolean writeProbenKommentare( |
161 UserInfo userInfo, | 154 UserInfo userInfo, |
162 List<LKommentarP> kommentare | 155 List<KommentarP> kommentare |
163 ) { | 156 ) { |
164 for(LKommentarP kommentar: kommentare) { | 157 for(KommentarP kommentar: kommentare) { |
165 kommentar.setProbeId(this.currentProbeId); | 158 kommentar.setProbeId(this.currentProbeId); |
166 repository.create(kommentar, "land"); | 159 repository.create(kommentar, "land"); |
167 } | 160 } |
168 return true; | 161 return true; |
169 } | 162 } |
175 * @param kommentare List of {@link LKommentarM} objects. | 168 * @param kommentare List of {@link LKommentarM} objects. |
176 * @return success | 169 * @return success |
177 */ | 170 */ |
178 public boolean writeMessungKommentare( | 171 public boolean writeMessungKommentare( |
179 UserInfo userInfo, | 172 UserInfo userInfo, |
180 Map<LMessung, List<LKommentarM>> kommentare | 173 Map<Messung, List<KommentarM>> kommentare |
181 ) { | 174 ) { |
182 for (LMessung messung : kommentare.keySet()) { | 175 for (Messung messung : kommentare.keySet()) { |
183 for (LKommentarM kommentar: kommentare.get(messung)) { | 176 for (KommentarM kommentar: kommentare.get(messung)) { |
184 kommentar.setMessungsId(messung.getId()); | 177 kommentar.setMessungsId(messung.getId()); |
185 repository.create(kommentar, "land"); | 178 repository.create(kommentar, "land"); |
186 } | 179 } |
187 } | 180 } |
188 return true; | 181 return true; |
195 * @param werte List of {@link LMesswert} objects. | 188 * @param werte List of {@link LMesswert} objects. |
196 * @return success | 189 * @return success |
197 */ | 190 */ |
198 public boolean writeMesswerte( | 191 public boolean writeMesswerte( |
199 UserInfo userInfo, | 192 UserInfo userInfo, |
200 Map<LMessung, List<LMesswert>> werte | 193 Map<Messung, List<Messwert>> werte |
201 ) { | 194 ) { |
202 for (LMessung messung : werte.keySet()) { | 195 for (Messung messung : werte.keySet()) { |
203 for(LMesswert messwert: werte.get(messung)) { | 196 for (Messwert messwert: werte.get(messung)) { |
204 messwert.setMessungsId(messung.getId()); | 197 messwert.setMessungsId(messung.getId()); |
205 repository.create(messwert, "land"); | 198 repository.create(messwert, "land"); |
206 } | 199 } |
207 } | 200 } |
208 return true; | 201 return true; |