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