annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/RiverService.java @ 302:f526f02e8ce2

Bugfix: States are filled with data before they describe themself. flys-artifacts/trunk@1664 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Apr 2011 07:49:36 +0000
parents d6197a05a87c
children aeeb9054b7cf
rev   line source
118
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
133
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
3 import java.util.List;
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
4
118
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Document;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Element;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.CallMeta;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.common.ArtifactNamespaceContext;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifacts.common.utils.XMLUtils;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.artifactdatabase.DefaultService;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
133
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
17 import de.intevation.flys.model.River;
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
18
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
19 import de.intevation.flys.artifacts.model.RiverFactory;
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
20
118
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 /**
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 * This service provides information about the supported rivers by this
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 * application.
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 *
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 */
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 public class RiverService extends DefaultService {
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /** The logger used in this service.*/
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private static Logger logger = Logger.getLogger(RiverService.class);
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 /**
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 * The default constructor.
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 */
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public RiverService() {
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 }
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 public Document process(
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 Document data,
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 Object globalContext,
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 CallMeta callMeta)
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 {
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 logger.debug("RiverService.process");
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 Document result = XMLUtils.newDocument();
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 result,
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 ArtifactNamespaceContext.NAMESPACE_URI,
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 ArtifactNamespaceContext.NAMESPACE_PREFIX);
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
133
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
55 List<River> allRivers = RiverFactory.getRivers();
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
56
118
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 Element rivers = ec.create("rivers");
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
133
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
59 for (River river: allRivers) {
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
60 Element r = ec.create("river");
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
61 ec.addAttr(r, "name", river.getName(), true);
118
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
133
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
63 rivers.appendChild(r);
d6197a05a87c The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
64 }
118
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 result.appendChild(rivers);
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 return result;
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 }
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
888e3b1dcdd9 Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org