Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/RiverService.java @ 4255:670e98f5a441
Fixed leak while merging facets.
The ThemeList that is used by OutputHelper to sort the
Facets for an Output now uses a list to store the ManagedFacets.
The correct order is made up by sorting the List using
Collections.sort() function of the Java JDK. Therfore, the
ManagedFacet class implements the Comparable interface. The
return value of its compareTo(other) method depends on the
value of the 'position' field.
author | Ingo Weinzierl <weinzierl.ingo@googlemail.com> |
---|---|
date | Thu, 25 Oct 2012 14:01:46 +0200 |
parents | 614ffddb860e |
children |
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; |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
316
diff
changeset
|
11 import de.intevation.artifacts.GlobalContext; |
118
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
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.ArtifactNamespaceContext; |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 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
|
15 |
133
d6197a05a87c
The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
118
diff
changeset
|
16 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
|
17 |
d6197a05a87c
The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
118
diff
changeset
|
18 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
|
19 |
118
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
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 * 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
|
23 * application. |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * @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
|
26 */ |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
27 public class RiverService extends FLYSService { |
118
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** 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
|
30 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
|
31 |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
33 protected Document doProcess( |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
316
diff
changeset
|
34 Document data, |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
316
diff
changeset
|
35 GlobalContext globalContext, |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
316
diff
changeset
|
36 CallMeta callMeta |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
316
diff
changeset
|
37 ) { |
118
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 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
|
39 |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 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
|
41 |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 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
|
43 result, |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 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
|
45 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
|
46 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
47 List<River> allRivers = RiverFactory.getRivers(); |
118
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
49 Element rivers = ec.create("rivers"); |
314
aeeb9054b7cf
Acquire/release sessions in services to avoid db connection leaks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
50 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
51 for (River river: allRivers) { |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
52 Element r = ec.create("river"); |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
53 ec.addAttr(r, "name", river.getName(), true); |
314
aeeb9054b7cf
Acquire/release sessions in services to avoid db connection leaks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
54 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
55 rivers.appendChild(r); |
133
d6197a05a87c
The 'rivers' service retrieves the rivers from backend now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
118
diff
changeset
|
56 } |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
57 |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
58 result.appendChild(rivers); |
118
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 return result; |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 } |
888e3b1dcdd9
Added a RiverService (/service/rivers) that retrieves a list of provided rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |