Mercurial > lada > lada-server
annotate src/main/java/de/intevation/lada/factory/ProbeFactory.java @ 896:c94a07959060
Use the laborMstId in generated probe objects.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 14 Mar 2016 10:15:06 +0100 |
parents | 092e673cbb8d |
children | 67c3d22372e4 |
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.math.BigInteger; |
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.sql.Timestamp; |
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.ArrayList; |
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.Calendar; |
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.Date; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 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
|
16 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 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
|
18 |
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.LKommentarP; |
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.LMessung; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 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
|
22 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
|
23 import de.intevation.lada.model.land.LProbe; |
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"); |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 } |
698
cd22674b4673
Fixed ort generation from messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
697
diff
changeset
|
210 if (messprogramm.getOrtId() != null && |
cd22674b4673
Fixed ort generation from messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
697
diff
changeset
|
211 !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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 repository.entityManager("stamm"), Ort.class); |
698
cd22674b4673
Fixed ort generation from messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
697
diff
changeset
|
217 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
|
218 Response ortResponse = repository.filter(ortBuilder.getQuery(), "stamm"); |
685
3118fbbe6292
Fixed or supressed warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
684
diff
changeset
|
219 @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
|
220 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
|
221 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
|
222 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
|
223 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
224 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
|
225 } |
680
a5e6580e8016
Reload the created probe object to have the 'probeIdAlt' field available.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
656
diff
changeset
|
226 // 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
|
227 probe = |
a5e6580e8016
Reload the created probe object to have the 'probeIdAlt' field available.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
656
diff
changeset
|
228 (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
|
229 return probe; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
230 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
231 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
232 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
233 * 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
|
234 * and the messprogramm. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
235 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
236 * @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
|
237 * @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
|
238 * @param messprogramm The messprogramm |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
239 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
240 * @return An array of start/end pairs. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
241 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
242 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
|
243 Calendar start, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
244 Calendar end, |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
245 Messprogramm messprogramm |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
246 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 (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
|
259 i == 0) |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
260 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
261 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
|
262 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 else { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
268 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 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
|
273 (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
|
274 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
|
275 ) { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 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
|
277 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 else { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 return intervals; |
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 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
288 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
289 * Parse an interval string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
290 * 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
|
291 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
292 * @param interval the interval string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
293 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
294 * @return the amount of days for the given interval. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
295 */ |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
296 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
|
297 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
|
298 return 365; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
299 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
300 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
|
301 return 183; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
302 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
303 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
|
304 return 91; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
305 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
306 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
|
307 return 30; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
308 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
309 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
|
310 return 28; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
311 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
312 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
|
313 return 14; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
314 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
315 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
|
316 return 7; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
317 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
318 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
|
319 return 1; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
320 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
321 else { |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
322 return 0; |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
323 } |
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
324 } |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
325 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
326 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
327 * Search for the umwelt id using the 'deskriptor'. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
328 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
329 * @param probe The probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
330 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
331 * @return The updated probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
332 */ |
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
|
333 public LProbe findUmweltId(LProbe probe) { |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
334 String[] mediaDesk = probe.getMediaDesk().split(" "); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
335 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
|
336 return probe; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
337 } |
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
|
338 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
|
339 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
|
340 } |
711
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 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
343 * Search for the media description using the 'deskriptor'. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
344 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
345 * @param probe The probe object |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
346 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
347 * @return The updated probe object. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
348 */ |
709
e502e1af6256
added autofill Mediadescription
Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de>
parents:
698
diff
changeset
|
349 public LProbe findMediaDesk(LProbe probe) { |
713
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
350 Object result = repository.queryFromString( |
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
351 "SELECT get_media_from_media_desk( :mediaDesk );", "stamm") |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
352 .setParameter("mediaDesk", probe.getMediaDesk()) |
713
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
353 .getSingleResult(); |
d8e421d9d7ec
Fixed possible NPE.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
354 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
|
355 return probe; |
e502e1af6256
added autofill Mediadescription
Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de>
parents:
698
diff
changeset
|
356 } |
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
|
357 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
358 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
359 * Search for the umwelt id using the 'deskriptor'. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
360 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
361 * @param messprogramm The messprogramm |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
362 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
363 * @return The updated messprogramm. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
364 */ |
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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 } |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
370 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
|
371 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
|
372 } |
8c486052264c
Refactored finding the umwelt id to be able to use it for messprogramme.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
696
diff
changeset
|
373 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
374 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
375 * Find the umwelt id for a given deskriptor. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
376 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
377 * @param mediaDesk The deskriptor string |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
378 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
379 * @return The umwelt id or an empty string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
380 */ |
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
|
381 private String findUmwelt(String[] mediaDesk) { |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
382 List<Integer> mediaIds = new ArrayList<Integer>(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
383 boolean zebs = false; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
384 Integer parent = null; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
385 Integer hdParent = null; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
386 Integer ndParent = null; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
387 if ("01".equals(mediaDesk[1])) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
388 zebs = true; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
389 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
390 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
|
391 if ("00".equals(mediaDesk[i])) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
392 mediaIds.add(-1); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
393 continue; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
394 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
395 if (zebs && i < 5) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
396 parent = hdParent; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
397 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
398 else if (!zebs && i < 3) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
399 parent = hdParent; |
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 else { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
402 parent = ndParent; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
403 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
404 QueryBuilder<Deskriptoren> builder = new QueryBuilder<Deskriptoren>( |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
405 repository.entityManager("stamm"), Deskriptoren.class); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
406 if (parent != null) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
407 builder.and("vorgaenger", parent); |
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 builder.and("sn", mediaDesk[i]); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
410 builder.and("ebene", i - 1); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
411 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
|
412 @SuppressWarnings("unchecked") |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
413 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
|
414 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
|
415 return ""; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
416 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
417 hdParent = data.get(0).getId(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
418 mediaIds.add(data.get(0).getId()); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
419 if (i == 2) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
420 ndParent = data.get(0).getId(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
421 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
422 } |
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
|
423 return getUmwelt(mediaIds, zebs); |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
424 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
425 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
426 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
427 * 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
|
428 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
429 * @param media The list of media ids. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
430 * @param isZebs Flag for type of the deskriptor. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
431 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
432 * @return The umwelt id or an empty string. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
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 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
|
435 QueryBuilder<DeskriptorUmwelt> builder = |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
436 new QueryBuilder<DeskriptorUmwelt>( |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
437 repository.entityManager("stamm"), DeskriptorUmwelt.class); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
438 |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
439 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
|
440 return ""; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
441 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
442 |
735
bcaf30a871ef
Set fixed size for first deskriptoren request.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
732
diff
changeset
|
443 int size = 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
444 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
|
445 if (media.get(i) == -1) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
446 continue; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
447 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
448 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
|
449 builder.and(field, media.get(i)); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
450 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
451 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
|
452 @SuppressWarnings("unchecked") |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
453 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
|
454 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
|
455 return null; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
456 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
457 |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
458 boolean unique = isUnique(data); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
459 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
|
460 return data.get(0).getUmwId(); |
695
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 else { |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
463 int found = -1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
464 for (int i = 0; i < data.size(); i++) { |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
465 int matches = 0; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
466 int lastMatch = 0; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
467 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
|
468 switch(j) { |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
469 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
|
470 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
471 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
472 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
|
473 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
474 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
475 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
|
476 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
477 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
478 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
|
479 matches +=1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
480 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
481 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
|
482 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
483 break; |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
484 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
|
485 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
486 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
487 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
|
488 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
489 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
490 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
|
491 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
492 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
493 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
|
494 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
495 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
496 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
|
497 matches += 1; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
498 break; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
499 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
|
500 matches += 1; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
501 break; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
502 } |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
503 if (matches > lastMatch) { |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
504 lastMatch = matches; |
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
505 found = i; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
506 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
507 } |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
508 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
|
509 return data.get(found).getUmwId(); |
696
97ccdf45a4a3
Find the correct umweltbereich.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
695
diff
changeset
|
510 } |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
511 } |
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
|
512 return null; |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
513 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
514 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
515 |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
516 /** |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
517 * 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
|
518 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
519 * @param list A list of DescriptorUmwelt objects. |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
520 * |
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
709
diff
changeset
|
521 * @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
|
522 */ |
695
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
523 private boolean isUnique(List<DeskriptorUmwelt> list) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
524 if (list.isEmpty()) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
525 return false; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
526 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
527 String element = list.get(0).getUmwId(); |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
528 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
|
529 if (!element.equals(list.get(i))) { |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
530 return false; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
531 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
532 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
533 return true; |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
534 } |
b8afbf6c1b5d
Find the umw_id for probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
691
diff
changeset
|
535 |
656
866d05db7a6a
Added probe factory. This factory creates probe objects(and its childs) from
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
536 } |