annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/FixingsOverviewService.java @ 5868:35b2d86c3fb5

River artifacts: Renamed FLYSService to D4EService.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 15:26:59 +0200
parents 4897a58c8746
children af13ceeba52a
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
9 package org.dive4elements.river.artifacts.services;
2561
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
11 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
12 import org.dive4elements.artifacts.GlobalContext;
2564
3f038d54bc87 FixingsOverviewService: Made the filter mechanisms available via the incoming XML document.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2561
diff changeset
13
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
14 import org.dive4elements.artifacts.common.utils.XMLUtils;
2564
3f038d54bc87 FixingsOverviewService: Made the filter mechanisms available via the incoming XML document.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2561
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
16 import org.dive4elements.river.artifacts.model.FixingsFilterBuilder;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
17
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
18 import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing.Filter;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
19
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
20 import org.dive4elements.river.artifacts.model.Range;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
21
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
22 import org.dive4elements.river.artifacts.model.FixingsOverview;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3138
diff changeset
23 import org.dive4elements.river.artifacts.model.FixingsOverviewFactory;
2561
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import org.apache.log4j.Logger;
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 import org.w3c.dom.Document;
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 import org.w3c.dom.Element;
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 import org.w3c.dom.NodeList;
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 public class FixingsOverviewService
5868
35b2d86c3fb5 River artifacts: Renamed FLYSService to D4EService.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
32 extends D4EService
2561
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 {
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 private static Logger log =
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 Logger.getLogger(FixingsOverviewService.class);
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 public FixingsOverviewService() {
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 @Override
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public Document doProcess(
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 Document data,
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 GlobalContext globalContext,
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 CallMeta callMeta
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 ) {
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 log.debug("FixingsOverviewService.doProcess");
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 Document document = XMLUtils.newDocument();
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 NodeList nodes = data.getElementsByTagName("river");
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 String river = nodes.getLength() > 0
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 ? ((Element)nodes.item(0)).getAttribute("name")
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 : "";
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 FixingsOverview overview = FixingsOverviewFactory.getOverview(river);
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 if (overview != null) {
2608
938e2f6c0c9a Refactored the code of the fixings filter building to be useful in more cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2564
diff changeset
59 FixingsFilterBuilder ffb = new FixingsFilterBuilder(data);
938e2f6c0c9a Refactored the code of the fixings filter building to be useful in more cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2564
diff changeset
60 Range range = ffb.getRange();
938e2f6c0c9a Refactored the code of the fixings filter building to be useful in more cases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2564
diff changeset
61 Filter filter = ffb.getFilter();
2564
3f038d54bc87 FixingsOverviewService: Made the filter mechanisms available via the incoming XML document.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2561
diff changeset
62 overview.generateOverview(document, range, filter);
2561
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 }
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 else {
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 log.warn("No overview for river '" + river + "' available.");
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 return document;
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 }
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
b3f6d49cdc80 Service to generate the data needed to build the "Fixerungen pro Fluss Uebersicht"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org