Mercurial > lada > lada-server
annotate src/main/java/de/intevation/lada/factory/ProbeFactory.java @ 897:67c3d22372e4
Add the initial status to generated messung objects.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 14 Mar 2016 10:15:43 +0100 |
parents | c94a07959060 |
children | 54e83373bfae |
rev | line source |
---|---|
691
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
2 * Software engineering by Intevation GmbH |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
3 * |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
7 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.lada.factory; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import java.sql.Timestamp; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import java.util.Calendar; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import java.util.Date; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import java.util.List; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import javax.inject.Inject; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.lada.model.land.LKommentarP; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.lada.model.land.LMessung; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.lada.model.land.LMesswert; |
810
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
21 import de.intevation.lada.model.land.LOrtszuordnung; |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.lada.model.land.LProbe; |
897
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
23 import de.intevation.lada.model.land.LStatusProtokoll; |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.lada.model.land.Messprogramm; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.lada.model.land.MessprogrammMmt; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.lada.model.land.MessungTranslation; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.lada.model.land.ProbeTranslation; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
28 import de.intevation.lada.model.stamm.DeskriptorUmwelt; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
29 import de.intevation.lada.model.stamm.Deskriptoren; |
810
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
30 import de.intevation.lada.model.stamm.Ort; |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.lada.util.annotation.RepositoryConfig; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.lada.util.data.QueryBuilder; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.lada.util.data.Repository; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 import de.intevation.lada.util.data.RepositoryType; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 import de.intevation.lada.util.rest.Response; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 |
691
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
37 /** |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
38 * This factory creates probe objects and its children using a messprogramm |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
39 * as template. |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
40 * |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
41 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
42 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 public class ProbeFactory { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 |
691
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
45 /** |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
46 * The data repository |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
47 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 @Inject |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 @RepositoryConfig(type = RepositoryType.RW) |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 private Repository repository; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 |
691
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
52 /** |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
53 * Create a list of probe objects |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
54 * |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
55 * @param id Messprogramm id |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
56 * @param from The start date |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
57 * @param to The end date |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
58 * |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
59 * @return List of probe objects. |
46bb231ff9b9
Documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
685
diff
changeset
|
60 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 public List<LProbe> create(String id, Long from, Long to) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 QueryBuilder<Messprogramm> builder = |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 new QueryBuilder<Messprogramm>( |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 repository.entityManager("land"), |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 Messprogramm.class); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 builder.and("id", id); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 Response response = repository.filter(builder.getQuery(), "land"); |
685
3118fbbe6292
Fixed or supressed warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
684
diff
changeset
|
68 @SuppressWarnings("unchecked") |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 List<Messprogramm> messprogramme = |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 (List<Messprogramm>)response.getData(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 if (messprogramme == null || messprogramme.isEmpty()) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 return null; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 Messprogramm messprogramm = messprogramme.get(0); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 Calendar start = Calendar.getInstance(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 start.setTime(new Date(from)); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 Calendar end = Calendar.getInstance(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 end.setTime(new Date (to)); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 Date[][] intervals = calculateIntervals(start, end, messprogramm); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 List<LProbe> proben = new ArrayList<LProbe>(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 for (Date[] interval : intervals) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 createProben(interval, messprogramm, proben); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 return proben; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
87 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
88 * Create LProbe objects using the interval and messprogramm details. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
89 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
90 * @param interval The time interval for probe objects. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
91 * @param messprogramm The messprogramm containing details. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
92 * @param proben An (empty) list for probe objects filled by this |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
93 * method |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
94 * @return |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
95 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 private void createProben( |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 Date[] interval, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 Messprogramm messprogramm, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 List<LProbe> proben |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 Calendar start = Calendar.getInstance(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 start.setTime(interval[0]); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 int startDay = start.get(Calendar.DAY_OF_YEAR); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 Calendar end = Calendar.getInstance(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 end.setTime(interval[1]); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 int endDay = end.get(Calendar.DAY_OF_YEAR); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 if ("J".equals(messprogramm.getProbenintervall()) && |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 messprogramm.getTeilintervallVon() >= startDay + messprogramm.getIntervallOffset() && |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 messprogramm.getTeilintervallBis() <= endDay + messprogramm.getIntervallOffset()) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 start.add(Calendar.DATE, messprogramm.getTeilintervallVon() - startDay + messprogramm.getIntervallOffset()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 Date startDate = start.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 end.add(Calendar.DATE, messprogramm.getTeilintervallBis() - endDay + messprogramm.getIntervallOffset()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 Date endDate = end.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 LProbe probe = createObjects(messprogramm, startDate, endDate); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 proben.add(probe); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 return; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 int intervalDays = parseInterval(messprogramm.getProbenintervall()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 int teilStart = messprogramm.getTeilintervallVon() + startDay; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 int teilEnd = messprogramm.getTeilintervallBis() + startDay; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 int offset = messprogramm.getIntervallOffset() == null ? 0 : messprogramm.getIntervallOffset(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
123 for (;teilStart >= startDay + offset && teilEnd <= endDay + offset;) { |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 start.add(Calendar.DATE, teilStart - startDay + offset); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 Date startDate = start.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 end.add(Calendar.DATE, teilEnd - endDay + offset); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 Date endDate = end.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 LProbe probe = createObjects(messprogramm, startDate, endDate); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 proben.add(probe); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 teilStart += intervalDays; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 teilEnd += intervalDays; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 end.setTime(interval[1]); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 start.setTime(interval[0]); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 return; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
138 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
139 * Create a single probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
140 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
141 * @param messprogramm The messprogramm containing probe details |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
142 * @param startDate The date for 'solldatumbeginn' |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
143 * @param endDate The date for 'solldatumende' |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
144 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
145 * @return The new probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
146 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 private LProbe createObjects( |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 Messprogramm messprogramm, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 Date startDate, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 Date endDate |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 LProbe probe = new LProbe(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 probe.setBaId(messprogramm.getBaId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 probe.setDatenbasisId(messprogramm.getDatenbasisId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 probe.setMediaDesk(messprogramm.getMediaDesk()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 probe.setMstId(messprogramm.getMstId()); |
896
c94a07959060
Use the laborMstId in generated probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
810
diff
changeset
|
157 probe.setLaborMstId(messprogramm.getLaborMstId()); |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 probe.setNetzbetreiberId(messprogramm.getNetzbetreiberId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 probe.setProbenartId(messprogramm.getProbenartId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 probe.setProbeNehmerId(messprogramm.getProbeNehmerId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 probe.setSolldatumBeginn(new Timestamp(startDate.getTime())); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 probe.setSolldatumEnde(new Timestamp(endDate.getTime())); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 probe.setTest(messprogramm.getTest()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 probe.setUmwId(messprogramm.getUmwId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 repository.create(probe, "land"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 ProbeTranslation translation = new ProbeTranslation(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 translation.setProbeId(probe); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 repository.create(translation, "land"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 if (messprogramm.getProbeKommentar() != null && |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 !messprogramm.getProbeKommentar().equals("")) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 LKommentarP kommentar = new LKommentarP(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 kommentar.setDatum(new Timestamp(new Date().getTime())); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 kommentar.setProbeId(probe.getId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 kommentar.setText(messprogramm.getProbeKommentar()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 kommentar.setErzeuger(messprogramm.getMstId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 repository.create(kommentar, "land"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 QueryBuilder<MessprogrammMmt> builder = |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 new QueryBuilder<MessprogrammMmt>( |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 repository.entityManager("land"), |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 MessprogrammMmt.class); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 builder.and("messprogrammId", messprogramm.getId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 Response response = repository.filter(builder.getQuery(), "land"); |
685
3118fbbe6292
Fixed or supressed warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
684
diff
changeset
|
187 @SuppressWarnings("unchecked") |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 List<MessprogrammMmt> mmts = (List<MessprogrammMmt>)response.getData(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 for (MessprogrammMmt mmt : mmts) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 LMessung messung = new LMessung(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 messung.setFertig(false); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 messung.setGeplant(true); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 messung.setMmtId(mmt.getMmtId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 messung.setNebenprobenNr( |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 messprogramm.getNetzbetreiberId() + mmt.getMmtId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 messung.setProbeId(probe.getId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 repository.create(messung, "land"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 MessungTranslation mTranslation = new MessungTranslation(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 mTranslation.setMessungsId(messung); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 repository.create(mTranslation, "land"); |
897
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
201 |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
202 LStatusProtokoll status = new LStatusProtokoll(); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
203 status.setDatum(new Timestamp(new Date().getTime())); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
204 status.setMessungsId(messung.getId()); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
205 status.setErzeuger(probe.getMstId()); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
206 status.setStatusStufe(1); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
207 status.setStatusWert(0); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
208 repository.create(status, "land"); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
209 messung.setStatus(status.getId()); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
210 repository.update(messung, "land"); |
67c3d22372e4
Add the initial status to generated messung objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
896
diff
changeset
|
211 |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 for (int mw : mmt.getMessgroessen()) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 LMesswert wert = new LMesswert(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 wert.setMessgroesseId(mw); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 wert.setMessungsId(messung.getId()); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 wert.setMesswert(0f); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
217 wert.setMehId(1); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 repository.create(wert, "land"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 } |
698
cd22674b4673
Fixed ort generation from messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
697
diff
changeset
|
221 if (messprogramm.getOrtId() != null && |
cd22674b4673
Fixed ort generation from messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
697
diff
changeset
|
222 !messprogramm.getOrtId().equals("")) { |
810
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
223 LOrtszuordnung ort = new LOrtszuordnung(); |
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
224 ort.setOrtszuordnungTyp("E"); |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
225 ort.setProbeId(probe.getId()); |
810
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
226 QueryBuilder<Ort> ortBuilder = new QueryBuilder<Ort>( |
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
227 repository.entityManager("stamm"), Ort.class); |
698
cd22674b4673
Fixed ort generation from messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
697
diff
changeset
|
228 ortBuilder.and("id", messprogramm.getOrtId()); |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
229 Response ortResponse = repository.filter(ortBuilder.getQuery(), "stamm"); |
685
3118fbbe6292
Fixed or supressed warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
684
diff
changeset
|
230 @SuppressWarnings("unchecked") |
810
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
231 List<Ort> orte = (List<Ort>) ortResponse.getData(); |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
232 if (orte != null && !orte.isEmpty()) { |
810
092e673cbb8d
Added and updated model, services, etc for to fit the new db schema.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
735
diff
changeset
|
233 ort.setOrtId(Long.valueOf(orte.get(0).getId())); |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
234 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
235 repository.create(ort, "land"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
236 } |
680
a5e6580e8016
Reload the created probe object to have the 'probeIdAlt' field available.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
656
diff
changeset
|
237 // Reolad the probe to have the old id |
a5e6580e8016
Reload the created probe object to have the 'probeIdAlt' field available.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
656
diff
changeset
|
238 probe = |
a5e6580e8016
Reload the created probe object to have the 'probeIdAlt' field available.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
656
diff
changeset
|
239 (LProbe)repository.getById(LProbe.class, probe.getId(), "land").getData(); |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
240 return probe; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
241 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
242 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
243 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
244 * Determine the interval for probe generation using a start date, end date |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
245 * and the messprogramm. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
246 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
247 * @param start Calendar object defining the start of the first interval |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
248 * @param end Calendar object defining the end of the last interval. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
249 * @param messprogramm The messprogramm |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
250 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
251 * @return An array of start/end pairs. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
252 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
253 private Date[][] calculateIntervals( |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
254 Calendar start, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
255 Calendar end, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
256 Messprogramm messprogramm |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
257 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
258 int realStart = start.get(Calendar.DAY_OF_YEAR); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
259 int realEnd = end.get(Calendar.DAY_OF_YEAR); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
260 int startYear = start.get(Calendar.YEAR); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
261 int endYear = end.get(Calendar.YEAR); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
262 int years = (endYear - startYear) + 1; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 Date[][] intervals = new Date[years][2]; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
264 for (int i = 0; i < years; i++) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
265 Calendar cStart = Calendar.getInstance(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
266 cStart.set(startYear + i, start.get(Calendar.MONTH), start.get(Calendar.DAY_OF_MONTH)); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
267 if (messprogramm.getGueltigVon() == null || |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
268 messprogramm.getGueltigVon() <= 0 || |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
269 (realStart > messprogramm.getGueltigVon() && |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
270 i == 0) |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
271 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
272 intervals[0][0] = start.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
273 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
274 else { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
275 start.add(Calendar.DATE, messprogramm.getGueltigVon() - realStart); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 Date startDate = start.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
277 intervals[i][0] = startDate; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
279 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
280 Calendar cEnd = Calendar.getInstance(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
281 cEnd.set(startYear + i, end.get(Calendar.MONTH), end.get(Calendar.DAY_OF_MONTH)); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
282 if (messprogramm.getGueltigBis() == null || |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 messprogramm.getGueltigBis() <= 0 || |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 (realEnd < messprogramm.getGueltigBis() && |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 i == years - 1) |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
286 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
287 intervals[i][1] = cEnd.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
288 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
289 else { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
290 cEnd.add(Calendar.DATE, messprogramm.getGueltigBis() - realEnd); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
291 Date endDate = cEnd.getTime(); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
292 intervals[i][1] = endDate; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
293 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
294 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
295 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
296 return intervals; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
297 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
298 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
299 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
300 * Parse an interval string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
301 * Posible values are: J, H, Q, M, W4, W2, W, T |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
302 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
303 * @param interval the interval string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
304 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
305 * @return the amount of days for the given interval. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
306 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
307 private int parseInterval(String interval) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
308 if ("J".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
309 return 365; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
310 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
311 else if ("H".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
312 return 183; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
313 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
314 else if ("Q".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
315 return 91; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
316 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
317 else if ("M".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
318 return 30; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
319 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
320 else if ("W4".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
321 return 28; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
322 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
323 else if ("W2".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
324 return 14; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
325 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
326 else if ("W".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
327 return 7; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
328 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
329 else if ("T".equals(interval)) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
330 return 1; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
331 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
332 else { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
333 return 0; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
334 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
335 } |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
336 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
337 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
338 * Search for the umwelt id using the 'deskriptor'. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
339 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
340 * @param probe The probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
341 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
342 * @return The updated probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
343 */ |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
344 public LProbe findUmweltId(LProbe probe) { |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
345 String[] mediaDesk = probe.getMediaDesk().split(" "); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
346 if (mediaDesk.length <= 1) { |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
347 return probe; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
348 } |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
349 probe.setUmwId(findUmwelt(mediaDesk)); |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
350 return probe; |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
351 } |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
352 |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
353 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
354 * Search for the media description using the 'deskriptor'. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
355 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
356 * @param probe The probe object |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
357 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
358 * @return The updated probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
359 */ |
709
e502e1af6256
added autofill Mediadescription
Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de>
parents:
698
diff
changeset
|
360 public LProbe findMediaDesk(LProbe probe) { |
713
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
361 Object result = repository.queryFromString( |
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
362 "SELECT get_media_from_media_desk( :mediaDesk );", "stamm") |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
363 .setParameter("mediaDesk", probe.getMediaDesk()) |
713
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
364 .getSingleResult(); |
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
365 probe.setMedia(result != null ? result.toString() : ""); |
709
e502e1af6256
added autofill Mediadescription
Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de>
parents:
698
diff
changeset
|
366 return probe; |
e502e1af6256
added autofill Mediadescription
Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de>
parents:
698
diff
changeset
|
367 } |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
368 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
369 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
370 * Search for the umwelt id using the 'deskriptor'. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
371 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
372 * @param messprogramm The messprogramm |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
373 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
374 * @return The updated messprogramm. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
375 */ |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
376 public Messprogramm findUmweltId(Messprogramm messprogramm) { |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
377 String[] mediaDesk = messprogramm.getMediaDesk().split(" "); |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
378 if (mediaDesk.length <= 1) { |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
379 return messprogramm; |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
380 } |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
381 messprogramm.setUmwId(findUmwelt(mediaDesk)); |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
382 return messprogramm; |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
383 } |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
384 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
385 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
386 * Find the umwelt id for a given deskriptor. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
387 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
388 * @param mediaDesk The deskriptor string |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
389 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
390 * @return The umwelt id or an empty string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
391 */ |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
392 private String findUmwelt(String[] mediaDesk) { |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
393 List<Integer> mediaIds = new ArrayList<Integer>(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
394 boolean zebs = false; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
395 Integer parent = null; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
396 Integer hdParent = null; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
397 Integer ndParent = null; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
398 if ("01".equals(mediaDesk[1])) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
399 zebs = true; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
400 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
401 for (int i = 1; i < mediaDesk.length; i++) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
402 if ("00".equals(mediaDesk[i])) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
403 mediaIds.add(-1); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
404 continue; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
405 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
406 if (zebs && i < 5) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
407 parent = hdParent; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
408 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
409 else if (!zebs && i < 3) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
410 parent = hdParent; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
411 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
412 else { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
413 parent = ndParent; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
414 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
415 QueryBuilder<Deskriptoren> builder = new QueryBuilder<Deskriptoren>( |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
416 repository.entityManager("stamm"), Deskriptoren.class); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
417 if (parent != null) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
418 builder.and("vorgaenger", parent); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
419 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
420 builder.and("sn", mediaDesk[i]); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
421 builder.and("ebene", i - 1); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
422 Response response = repository.filter(builder.getQuery(), "stamm"); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
423 @SuppressWarnings("unchecked") |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
424 List<Deskriptoren> data = (List<Deskriptoren>)response.getData(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
425 if (data.isEmpty()) { |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
426 return ""; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
427 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
428 hdParent = data.get(0).getId(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
429 mediaIds.add(data.get(0).getId()); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
430 if (i == 2) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
431 ndParent = data.get(0).getId(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
432 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
433 } |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
434 return getUmwelt(mediaIds, zebs); |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
435 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
436 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
437 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
438 * Find the umwelt id in the database using media deskriptor ids. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
439 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
440 * @param media The list of media ids. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
441 * @param isZebs Flag for type of the deskriptor. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
442 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
443 * @return The umwelt id or an empty string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
444 */ |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
445 private String getUmwelt(List<Integer> media, boolean isZebs) { |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
446 QueryBuilder<DeskriptorUmwelt> builder = |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
447 new QueryBuilder<DeskriptorUmwelt>( |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
448 repository.entityManager("stamm"), DeskriptorUmwelt.class); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
449 |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
450 if (media.size() == 0) { |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
451 return ""; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
452 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
453 |
735
bcaf30a871ef
Set fixed size for first deskriptoren request.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
732
diff
changeset
|
454 int size = 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
455 for (int i = size; i >= 0; i--) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
456 if (media.get(i) == -1) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
457 continue; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
458 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
459 String field = "s" + (i > 9 ? i : "0" + i); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
460 builder.and(field, media.get(i)); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
461 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
462 Response response = repository.filter(builder.getQuery(), "stamm"); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
463 @SuppressWarnings("unchecked") |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
464 List<DeskriptorUmwelt> data = (List<DeskriptorUmwelt>)response.getData(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
465 if (data.isEmpty()) { |
732
83acc3b63354
Fixed size of main descriptor fields and return 'null' instead of "" for empty
Raimund Renkert <raimund.renkert@intevation.de>
parents:
713
diff
changeset
|
466 return null; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
467 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
468 |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
469 boolean unique = isUnique(data); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
470 if (unique) { |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
471 return data.get(0).getUmwId(); |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
472 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
473 else { |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
474 int found = -1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
475 for (int i = 0; i < data.size(); i++) { |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
476 int matches = 0; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
477 int lastMatch = 0; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
478 for (int j = size + 1; j < 12; j++) { |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
479 switch(j) { |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
480 case 2: if (media.get(2).equals(data.get(i).getS02())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
481 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
482 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
483 case 3: if (media.get(3).equals(data.get(i).getS03())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
484 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
485 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
486 case 4: if (media.get(4).equals(data.get(i).getS04())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
487 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
488 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
489 case 5: if (media.get(5).equals(data.get(i).getS05())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
490 matches +=1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
491 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
492 case 6: if (media.get(6).equals(data.get(i).getS06())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
493 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
494 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
495 case 7: if (media.get(7).equals(data.get(i).getS07())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
496 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
497 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
498 case 8: if (media.get(8).equals(data.get(i).getS08())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
499 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
500 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
501 case 9: if (media.get(9).equals(data.get(i).getS09())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
502 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
503 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
504 case 10: if (media.get(10).equals(data.get(i).getS10())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
505 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
506 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
507 case 11: if (media.get(11).equals(data.get(i).getS11())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
508 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
509 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
510 case 12: if (media.get(12).equals(data.get(i).getS12())) |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
511 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
512 break; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
513 } |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
514 if (matches > lastMatch) { |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
515 lastMatch = matches; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
516 found = i; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
517 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
518 } |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
519 if (found >= 0) { |
697
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
520 return data.get(found).getUmwId(); |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
521 } |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
522 } |
732
83acc3b63354
Fixed size of main descriptor fields and return 'null' instead of "" for empty
Raimund Renkert <raimund.renkert@intevation.de>
parents:
713
diff
changeset
|
523 return null; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
524 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
525 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
526 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
527 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
528 * Determine if the entries in the list have the same umwelt id. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
529 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
530 * @param list A list of DescriptorUmwelt objects. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
531 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
532 * @return true if the objects have the same umwelt id else false. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
533 */ |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
534 private boolean isUnique(List<DeskriptorUmwelt> list) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
535 if (list.isEmpty()) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
536 return false; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
537 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
538 String element = list.get(0).getUmwId(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
539 for (int i = 1; i < list.size(); i++) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
540 if (!element.equals(list.get(i))) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
541 return false; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
542 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
543 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
544 return true; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
545 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
546 |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
547 } |