view gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java @ 88:1b12021905b9

Some CodeCleanup done. ExceptionDocument will now be returned gnv-artifacts/trunk@125 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 24 Sep 2009 10:45:24 +0000
parents 5d4f5d26bb7a
children bd284d8306db
line wrap: on
line source
/**
 *
 */
package de.intevation.gnv.transition;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.log4j.Logger;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import de.intevation.artifactdatabase.Config;
import de.intevation.gnv.geobackend.base.Result;
import de.intevation.gnv.transition.exception.TransitionException;

/**
 * @author Tim Englich <tim.englich@intevation.de>
 *
 */
public abstract class OutputTransitionBase extends TransitionBase implements
        OutputTransition {
    
    
    /**
     * Thie UID of this Class
     */
    private static final long serialVersionUID = -1718732895737303823L;
   
    /**
     * the logger, used to log exceptions and additonaly information
     */
    private static Logger log = Logger.getLogger(OutputTransitionBase.class);
    /**
     * The Results which should be used for Rendering the Charts or 
     * do other output
     */
    protected Collection<Result> chartResult = null;
    
    /**
     * The different Outputmodes which are provided by an OutputTransition
     */
    protected Collection<OutputMode> outputModes = null;
    
    /**
     * Constructor
     */
    public OutputTransitionBase() {
        super();
    }

    /**
     * @see de.intevation.gnv.transition.OutputTransition#getOutputModes()
     */
    public Collection<OutputMode> getOutputModes() {
        log.debug("OutputTransitionBase.getOutputModes");
        return this.outputModes;
    }
    /**
     * @see de.intevation.gnv.transition.Transition#validate()
     */
    public boolean validate() {
        log.debug("OutputTransitionBase.validate");
        return true;
    }

    /**
     * @see de.intevation.gnv.transition.TransitionBase#setup(org.w3c.dom.Node)
     */
    @Override
    public void setup(Node configuration) {
        log.debug("OutputTransitionBase.setup");
        super.setup(configuration);
        NodeList outputModeList = Config.getNodeSetXPath(configuration, "outputsModes/outputsMode");
        if (outputModeList != null){
            log.debug(outputModeList.getLength()+ " were found.");
            this.outputModes = new ArrayList<OutputMode>(outputModeList.getLength());
            for (int i = 0; i < outputModeList.getLength(); i++){
                Node currentNode = outputModeList.item(i);
                String name  = Config.getStringXPath(currentNode, "@name");
                String description  = Config.getStringXPath(currentNode, "@description");
                String mimeType = Config.getStringXPath(currentNode, "@mime-type");
                OutputMode outputMode = new DefaultOutputMode(name, description, mimeType);
                log.debug(outputMode.toString());
                this.outputModes.add(outputMode);
                
            }
        }
    }
    
    /**
     * @see de.intevation.gnv.transition.TransitionBase#advance()
     */
    @Override
    public void advance() throws TransitionException {
        log.debug("OutputTransitionBase.advance");
        if (this.chartResult == null){
            super.advance();
        }
    }

    /**
     * @see de.intevation.gnv.transition.TransitionBase#getInputData()
     */
    @Override
    public Collection<InputData> getInputData() throws TransitionException {
        log.debug("OutputTransitionBase.getInputData");
        this.chartResult = null;
        return super.getInputData();
    }

}

http://dive4elements.wald.intevation.org