ingo@1115: /* ingo@1115: * Copyright (c) 2010 by Intevation GmbH ingo@1115: * ingo@1115: * This program is free software under the LGPL (>=v2.1) ingo@1115: * Read the file LGPL.txt coming with the software for details ingo@1115: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1115: */ ingo@1115: ingo@488: package de.intevation.gnv.artifacts; ingo@488: ingo@488: import de.intevation.artifactdatabase.DefaultArtifact; sascha@1117: import de.intevation.artifacts.common.utils.XMLUtils; ingo@488: ingo@491: import de.intevation.artifacts.ArtifactNamespaceContext; ingo@488: import de.intevation.artifacts.CallContext; ingo@488: import de.intevation.artifacts.CallMeta; ingo@488: ingo@488: import de.intevation.gnv.artifacts.ressource.RessourceFactory; ingo@488: ingo@488: import org.apache.log4j.Logger; ingo@488: ingo@488: import org.w3c.dom.Document; ingo@488: import org.w3c.dom.Element; ingo@488: ingo@488: /** ingo@789: * The default gnv artifact. The only thing defined here is a method to append ingo@789: * the selected fis to the describe document. ingo@789: * sascha@780: * @author Ingo Weinzierl ingo@488: */ ingo@488: public class GNVDefaultArtifact extends DefaultArtifact { ingo@488: ingo@488: private static Logger logger = Logger.getLogger(GNVDefaultArtifact.class); ingo@488: ingo@789: /** ingo@789: * ingo@789: */ ingo@725: public static final String EXCEPTION_NO_INPUT = "no.input.data"; ingo@725: ingo@488: ingo@789: /** ingo@789: * Constructor. ingo@789: */ ingo@488: public GNVDefaultArtifact() { ingo@488: super(); ingo@488: } ingo@488: ingo@488: ingo@789: /** ingo@789: * Append the selected fis to the describe document. ingo@789: * ingo@789: * @param document ingo@789: * @param staticNode ingo@789: * @param context ingo@789: * @param fisName ingo@789: */ ingo@488: protected void appendFis( ingo@488: Document document, ingo@488: Element staticNode, ingo@488: CallContext context, ingo@488: String fisName ingo@488: ) { ingo@488: RessourceFactory resource = RessourceFactory.getInstance(); ingo@488: CallMeta callMeta = (CallMeta) context.getMeta(); ingo@488: ingo@488: XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( ingo@488: document, ingo@488: XMLUtils.XFORM_URL, ingo@488: XMLUtils.XFORM_PREFIX ingo@488: ); ingo@488: ingo@491: XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator( ingo@491: document, ingo@491: ArtifactNamespaceContext.NAMESPACE_URI, ingo@491: ArtifactNamespaceContext.NAMESPACE_PREFIX ingo@491: ); ingo@491: ingo@488: Element selectNode = creator.create("select1"); ingo@491: artCreator.addAttr(selectNode, "fis", "true", true); ingo@488: ingo@488: Element labelNode = creator.create("label"); ingo@488: labelNode.setTextContent( ingo@488: resource.getRessource(callMeta.getLanguages(), "fis", "fis") ingo@488: ); ingo@488: ingo@488: Element choicesNode = creator.create("choices"); ingo@488: ingo@488: Element itemNode = creator.create("item"); ingo@488: creator.addAttr(itemNode, "selected", "true"); ingo@488: ingo@488: Element choiceLabel = creator.create("label"); ingo@488: choiceLabel.setTextContent(resource.getRessource( ingo@488: callMeta.getLanguages(), ingo@488: fisName, ingo@488: fisName ingo@488: )); ingo@488: ingo@488: Element choiceValue = creator.create("value"); ingo@488: choiceValue.setTextContent(fisName); ingo@488: ingo@488: itemNode.appendChild(choiceLabel); ingo@488: itemNode.appendChild(choiceValue); ingo@488: choicesNode.appendChild(itemNode); ingo@488: ingo@488: selectNode.appendChild(labelNode); ingo@488: selectNode.appendChild(choicesNode); ingo@488: ingo@488: staticNode.appendChild(selectNode); ingo@488: } ingo@488: } sascha@836: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :