annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
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
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
13 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
14 import org.apache.logging.log4j.LogManager;
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
15
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.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
17 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
18
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
19 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
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
21 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
22 import org.dive4elements.artifacts.GlobalContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
23 import org.dive4elements.artifacts.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
24 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
25 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3630
diff changeset
26 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
27
5868
35b2d86c3fb5 River artifacts: Renamed FLYSService to D4EService.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
28 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
29
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 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
31
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
32 private static Logger log = LogManager.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
33
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 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
35 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
36 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
37 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
38 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7755
diff changeset
39 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
40
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 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
42
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 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
44 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
45 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
46 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
47
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
48 Element em = ec.create("modules");
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
49 List<Module> modules = (List<Module>)globalContext.get(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
50 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
51
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 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
53 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
54 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
55 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
56 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
57 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
58
7755
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
59 for (String river : module.getRivers()) {
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
60 Element r = ec.create("river");
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
61 r.setAttribute("uuid", river);
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
62 m.appendChild(r);
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
63 }
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
64 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
65 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
66 }
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 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
69 }
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 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
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 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
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 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
76
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80:

http://dive4elements.wald.intevation.org