view gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVDefaultArtifact.java @ 763:e4d1fded433b

Bugfix: The Description of an InputData-Object will now only be fetched if the Name of the data of the Current State is equal to the Name of the InputData-Object. gnv-artifacts/trunk@818 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 22 Mar 2010 12:52:09 +0000
parents dde7f51dbe1e
children c4156275c1e1
line wrap: on
line source
package de.intevation.gnv.artifacts;

import de.intevation.artifactdatabase.DefaultArtifact;
import de.intevation.artifactdatabase.XMLUtils;

import de.intevation.artifacts.ArtifactNamespaceContext;
import de.intevation.artifacts.CallContext;
import de.intevation.artifacts.CallMeta;

import de.intevation.gnv.artifacts.ressource.RessourceFactory;

import org.apache.log4j.Logger;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * @author Ingo Weinzierl <ingo.weinzierl@intevation.de>
 */
public class GNVDefaultArtifact extends DefaultArtifact {

    private static Logger logger = Logger.getLogger(GNVDefaultArtifact.class);

    public static final String EXCEPTION_NO_INPUT = "no.input.data";


    public GNVDefaultArtifact() {
        super();
    }


    protected void appendFis(
        Document    document,
        Element     staticNode,
        CallContext context,
        String      fisName
    ) {
        RessourceFactory resource = RessourceFactory.getInstance();
        CallMeta callMeta         = (CallMeta) context.getMeta();

        XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
            document,
            XMLUtils.XFORM_URL,
            XMLUtils.XFORM_PREFIX
        );

        XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator(
            document,
            ArtifactNamespaceContext.NAMESPACE_URI,
            ArtifactNamespaceContext.NAMESPACE_PREFIX
        );

        Element selectNode = creator.create("select1");
        artCreator.addAttr(selectNode, "fis", "true", true);

        Element labelNode = creator.create("label");
        labelNode.setTextContent(
            resource.getRessource(callMeta.getLanguages(), "fis", "fis")
        );

        Element choicesNode = creator.create("choices");

        Element itemNode = creator.create("item");
        creator.addAttr(itemNode, "selected", "true");

        Element choiceLabel = creator.create("label");
        choiceLabel.setTextContent(resource.getRessource(
            callMeta.getLanguages(),
            fisName,
            fisName
        ));

        Element choiceValue = creator.create("value");
        choiceValue.setTextContent(fisName);

        itemNode.appendChild(choiceLabel);
        itemNode.appendChild(choiceValue);
        choicesNode.appendChild(itemNode);

        selectNode.appendChild(labelNode);
        selectNode.appendChild(choicesNode);

        staticNode.appendChild(selectNode);
    }
}

http://dive4elements.wald.intevation.org