# HG changeset patch # User Bjoern Ricks # Date 1346419036 0 # Node ID 28be160b58704927581631e33ff5f7584dfb015f # Parent f3717e625b0ac919ded5bc9fa73e3e02f9ce0e9c Add a module service. It's now possible to configure the modules which are available for a client. With the selected attribute it is possible to give a hint for the client which module should be pre selected by default flys-artifacts/trunk@5330 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Aug 31 11:26:49 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Aug 31 13:17:16 2012 +0000 @@ -1,3 +1,18 @@ +2012-08-31 Björn Ricks + + * src/main/java/de/intevation/flys/artifacts/services/ModuleService.java, + src/main/java/de/intevation/flys/artifacts/model/Module.java, + src/main/java/de/intevation/flys/artifacts/context/FLYSContext.java, + src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java, + src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties, + doc/conf/conf.xml: + Add a module service. It's now possible to configure the modules which are + available for a client. With the selected attribute it is possible to give + a hint for the client which module should be pre selected by default. + 2012-08-31 Raimund Renkert * src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java, diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Fri Aug 31 11:26:49 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Fri Aug 31 13:17:16 2012 +0000 @@ -182,6 +182,10 @@ name="sq-km-chart" service="de.intevation.flys.artifacts.services.SQKMChartService" description="Returns a chart of km and date of meassuring points of a given river.">de.intevation.artifactdatabase.DefaultServiceFactory + de.intevation.artifactdatabase.DefaultServiceFactory @@ -215,6 +219,13 @@ + + + + + + + modules = new ArrayList(num); + + for (int i = 0; i < num; i++) { + Element e = (Element) modulenodes.item(i); + String modulename = e.getAttribute("name"); + String attrselected = e.getAttribute("selected"); + boolean selected = attrselected == null ? false : + attrselected.equalsIgnoreCase("true"); + logger.debug("Loaded module " + modulename); + modules.add(new Module(modulename, selected)); + } + context.put(FLYSContext.MODULES, modules); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Module.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Module.java Fri Aug 31 13:17:16 2012 +0000 @@ -0,0 +1,25 @@ +package de.intevation.flys.artifacts.model; + +/** + * Represents a Module as is is loaded from the config + */ +public class Module { + + private String name; + private boolean selected; + + public Module(String name, boolean selected) { + this.name = name; + this.selected = selected; + } + + public String getName() { + return this.name; + } + + public boolean isSelected() { + return this.selected; + } +} + +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80: diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/ModuleService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/ModuleService.java Fri Aug 31 13:17:16 2012 +0000 @@ -0,0 +1,62 @@ +package de.intevation.flys.artifacts.services; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import de.intevation.artifacts.common.utils.XMLUtils; + +import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.GlobalContext; +import de.intevation.artifacts.ArtifactNamespaceContext; +import de.intevation.flys.artifacts.model.Module; +import de.intevation.flys.artifacts.context.FLYSContext; +import de.intevation.flys.artifacts.resources.Resources; + +public class ModuleService extends FLYSService { + + private static final String MODULE = "module"; + + private static Logger logger = Logger.getLogger(ModuleService.class); + + protected Document doProcess( + Document data, + GlobalContext globalContext, + CallMeta callMeta + ) { + logger.debug("ModuleService.process"); + + Document result = XMLUtils.newDocument(); + + XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( + result, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX); + + Element em = ec.create("modules"); + List modules = (List)globalContext.get(FLYSContext.MODULES); + + for (Module module : modules) { + Element m = ec.create("module"); + ec.addAttr(m, "name", module.getName(), true); + String localname = Resources.getMsg(callMeta, + MODULE + "." + module.getName(), module.getName()); + ec.addAttr(m, "localname", localname, true); + + if (module.isSelected()) { + ec.addAttr(m, "selected", "true", true); + } + + em.appendChild(m); + } + + result.appendChild(em); + + return result; + } +} + +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80: diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Fri Aug 31 11:26:49 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Aug 31 13:17:16 2012 +0000 @@ -417,3 +417,9 @@ sq.km.chart.title = Measuring Points sq.km.chart.km.axis = km sq.km.chart.date.axis = Date + +module.winfo = WINFO +module.minfo = MINFO +module.fixanalysis = Fix Analysis +module.new_map = New Map +module.new_chart = New Chart diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Fri Aug 31 11:26:49 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Aug 31 13:17:16 2012 +0000 @@ -420,3 +420,9 @@ sq.km.chart.title = Messstellen sq.km.chart.km.axis = km sq.km.chart.date.axis = Datum + +module.winfo = WINFO +module.minfo = MINFO +module.fixanalysis = Fixierungsanalyse +module.new_map = Neue Karte +module.new_chart = Neues Diagramm diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Aug 31 11:26:49 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Aug 31 13:17:16 2012 +0000 @@ -419,3 +419,9 @@ sq.km.chart.title = Messstellen sq.km.chart.km.axis = km sq.km.chart.date.axis = Datum + +module.winfo = WINFO +module.minfo = MINFO +module.fixanalysis = Fixierungsanalyse +module.new_map = Neue Karte +module.new_chart = Neues Diagramm diff -r f3717e625b0a -r 28be160b5870 flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Fri Aug 31 11:26:49 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Aug 31 13:17:16 2012 +0000 @@ -419,3 +419,8 @@ sq.km.chart.km.axis = km sq.km.chart.date.axis = Date +module.winfo = WINFO +module.minfo = MINFO +module.fixanalysis = Fix Analysis +module.new_map = New Map +module.new_chart = New Chart