bjoern@3630: package de.intevation.flys.artifacts.services; bjoern@3630: bjoern@3630: import java.util.List; bjoern@3630: bjoern@3630: import org.apache.log4j.Logger; bjoern@3630: bjoern@3630: import org.w3c.dom.Document; bjoern@3630: import org.w3c.dom.Element; bjoern@3630: bjoern@3630: import de.intevation.artifacts.common.utils.XMLUtils; bjoern@3630: bjoern@3630: import de.intevation.artifacts.CallMeta; bjoern@3630: import de.intevation.artifacts.GlobalContext; bjoern@3630: import de.intevation.artifacts.ArtifactNamespaceContext; bjoern@3630: import de.intevation.flys.artifacts.model.Module; bjoern@3630: import de.intevation.flys.artifacts.context.FLYSContext; bjoern@3630: import de.intevation.flys.artifacts.resources.Resources; bjoern@3630: bjoern@3630: public class ModuleService extends FLYSService { bjoern@3630: bjoern@3630: private static final String MODULE = "module"; bjoern@3630: bjoern@3630: private static Logger logger = Logger.getLogger(ModuleService.class); bjoern@3630: bjoern@3630: protected Document doProcess( bjoern@3630: Document data, bjoern@3630: GlobalContext globalContext, bjoern@3630: CallMeta callMeta bjoern@3630: ) { bjoern@3630: logger.debug("ModuleService.process"); bjoern@3630: bjoern@3630: Document result = XMLUtils.newDocument(); bjoern@3630: bjoern@3630: XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( bjoern@3630: result, bjoern@3630: ArtifactNamespaceContext.NAMESPACE_URI, bjoern@3630: ArtifactNamespaceContext.NAMESPACE_PREFIX); bjoern@3630: bjoern@3630: Element em = ec.create("modules"); bjoern@3630: List modules = (List)globalContext.get(FLYSContext.MODULES); bjoern@3630: bjoern@3630: for (Module module : modules) { bjoern@3630: Element m = ec.create("module"); bjoern@3630: ec.addAttr(m, "name", module.getName(), true); bjoern@3630: String localname = Resources.getMsg(callMeta, bjoern@3630: MODULE + "." + module.getName(), module.getName()); bjoern@3630: ec.addAttr(m, "localname", localname, true); bjoern@3630: bjoern@3630: if (module.isSelected()) { bjoern@3630: ec.addAttr(m, "selected", "true", true); bjoern@3630: } bjoern@3630: bjoern@3630: em.appendChild(m); bjoern@3630: } bjoern@3630: bjoern@3630: result.appendChild(em); bjoern@3630: bjoern@3630: return result; bjoern@3630: } bjoern@3630: } bjoern@3630: bjoern@3630: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80: