comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/ModuleService.java @ 8870:c26fb37899ca

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 11:59:13 +0100
parents 5e38e2924c07
children
comparison
equal deleted inserted replaced
8869:20b85ea3b524 8870:c26fb37899ca
28 28
29 private static final String MODULE = "module"; 29 private static final String MODULE = "module";
30 30
31 private static Logger log = Logger.getLogger(ModuleService.class); 31 private static Logger log = Logger.getLogger(ModuleService.class);
32 32
33 @Override
33 protected Document doProcess( 34 protected Document doProcess(
34 Document data, 35 Document data,
35 GlobalContext globalContext, 36 GlobalContext globalContext,
36 CallMeta callMeta 37 CallMeta callMeta
37 ) { 38 ) {
38 log.debug("ModuleService.process"); 39 log.debug("ModuleService.process");
39 40
40 Document result = XMLUtils.newDocument(); 41 final Document result = XMLUtils.newDocument();
41 42
42 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( 43 final XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
43 result, 44 result,
44 ArtifactNamespaceContext.NAMESPACE_URI, 45 ArtifactNamespaceContext.NAMESPACE_URI,
45 ArtifactNamespaceContext.NAMESPACE_PREFIX); 46 ArtifactNamespaceContext.NAMESPACE_PREFIX);
46 47
47 Element em = ec.create("modules"); 48 final Element em = ec.create("modules");
48 List<Module> modules = (List<Module>)globalContext.get( 49 final List<Module> modules = (List<Module>)globalContext.get( RiverContext.MODULES);
49 RiverContext.MODULES);
50 50
51 for (Module module : modules) { 51 for (final Module module : modules) {
52 Element m = ec.create("module"); 52 final Element m = ec.create("module");
53 ec.addAttr(m, "name", module.getName(), true); 53 ec.addAttr(m, "name", module.getName(), true);
54 String localname = Resources.getMsg(callMeta, 54
55 MODULE + "." + module.getName(), module.getName()); 55 final String localname = Resources.getMsg(callMeta, MODULE + "." + module.getName(), module.getName());
56 ec.addAttr(m, "localname", localname, true); 56 ec.addAttr(m, "localname", localname, true);
57 57
58 for (String river : module.getRivers()) { 58 for (final String river : module.getRivers()) {
59 Element r = ec.create("river"); 59 final Element r = ec.create("river");
60 r.setAttribute("uuid", river); 60 r.setAttribute("uuid", river);
61 m.appendChild(r); 61 m.appendChild(r);
62 } 62 }
63 if (module.isSelected()) { 63 if (module.isSelected()) {
64 ec.addAttr(m, "selected", "true", true); 64 ec.addAttr(m, "selected", "true", true);
65 }
66
67 final String group = module.getGroup();
68 if( group != null ) {
69 final String groupLabel = Resources.getMsg(callMeta, group);
70 ec.addAttr(m, "groupId", group, true);
71 ec.addAttr(m, "groupLabel", groupLabel, true);
65 } 72 }
66 73
67 em.appendChild(m); 74 em.appendChild(m);
68 } 75 }
69 76

http://dive4elements.wald.intevation.org