annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java @ 9588:c57caff9b00b

Punkt 10.6 CSV-Ausgabe Abflusszeitreihenlänge
author gernotbelger
date Thu, 10 Jan 2019 11:56:39 +0100
parents c26fb37899ca
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
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
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
33 @Override
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
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
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
41 final Document result = XMLUtils.newDocument();
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
42
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
43 final XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
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
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
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
48 final Element em = ec.create("modules");
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
49 final 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
50
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
51 for (final Module module : modules) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
52 final Element m = ec.create("module");
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
53 ec.addAttr(m, "name", module.getName(), true);
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
54
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
55 final String localname = Resources.getMsg(callMeta, MODULE + "." + module.getName(), module.getName());
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
56 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
57
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
58 for (final String river : module.getRivers()) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
59 final Element r = ec.create("river");
7755
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
60 r.setAttribute("uuid", river);
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
61 m.appendChild(r);
4a85cc6add7f Added list of rivers a module supports.
Raimund Renkert <rrenkert@intevation.de>
parents: 5994
diff changeset
62 }
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
63 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
64 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
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
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
67 final String group = module.getGroup();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
68 if( group != null ) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
69 final String groupLabel = Resources.getMsg(callMeta, group);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
70 ec.addAttr(m, "groupId", group, true);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
71 ec.addAttr(m, "groupLabel", groupLabel, true);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
72 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
73
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
74 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
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 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
78
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
79 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
80 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
81 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
82
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
83 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80:

http://dive4elements.wald.intevation.org