annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents 4a85cc6add7f
children 5e38e2924c07
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 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5868
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
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
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5868
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
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: 3630
diff changeset
9 package org.dive4elements.river.artifacts.services;
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
10
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
11 import java.util.List;
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
12
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
14
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
15 import org.w3c.dom.Document;
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Element;
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
18 import org.dive4elements.artifacts.common.utils.XMLUtils;
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
19
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
20 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
21 import org.dive4elements.artifacts.GlobalContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
22 import org.dive4elements.artifacts.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
23 import org.dive4elements.river.artifacts.model.Module;
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
24 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
25 import org.dive4elements.river.artifacts.resources.Resources;
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
26
5868
35b2d86c3fb5 River artifacts: Renamed FLYSService to D4EService.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
27 public class ModuleService extends D4EService {
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
29 private static final String MODULE = "module";
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7755
diff changeset
31 private static Logger log = Logger.getLogger(ModuleService.class);
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 protected Document doProcess(
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 Document data,
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 GlobalContext globalContext,
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 CallMeta callMeta
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7755
diff changeset
38 log.debug("ModuleService.process");
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
40 Document result = XMLUtils.newDocument();
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
43 result,
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44 ArtifactNamespaceContext.NAMESPACE_URI,
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
45 ArtifactNamespaceContext.NAMESPACE_PREFIX);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47 Element em = ec.create("modules");
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
48 List<Module> modules = (List<Module>)globalContext.get(RiverContext.MODULES);
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
49
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50 for (Module module : modules) {
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 Element m = ec.create("module");
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52 ec.addAttr(m, "name", module.getName(), true);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53 String localname = Resources.getMsg(callMeta,
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
54 MODULE + "." + module.getName(), module.getName());
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
55 ec.addAttr(m, "localname", localname, true);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
56
7755
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
57 for (String river : module.getRivers()) {
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
58 Element r = ec.create("river");
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
59 r.setAttribute("uuid", river);
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
60 m.appendChild(r);
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
61 }
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62 if (module.isSelected()) {
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
63 ec.addAttr(m, "selected", "true", true);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
64 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
65
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
66 em.appendChild(m);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
67 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
68
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
69 result.appendChild(em);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
70
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
71 return result;
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
72 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
73 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
74
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80:

http://dive4elements.wald.intevation.org