tim@612: package de.intevation.gnv.state;
tim@612:
sascha@779: import de.intevation.artifactdatabase.Config;
sascha@779:
sascha@779: import de.intevation.artifacts.CallContext;
sascha@779:
sascha@779: import de.intevation.gnv.state.exception.StateException;
sascha@779:
tim@612: import java.util.ArrayList;
tim@612: import java.util.Collection;
tim@612: import java.util.Map;
tim@612:
tim@612: import org.w3c.dom.Element;
tim@612: import org.w3c.dom.Node;
tim@612:
tim@612: /**
sascha@780: * @author Tim Englich
tim@612: *
tim@612: */
tim@612: public class PreSettingsTransferState extends DefaultState {
tim@612:
tim@612: /**
tim@612: * The UID of this Class
tim@612: */
tim@612: private static final long serialVersionUID = 573381812690806922L;
tim@612:
tim@612: private String transferPreSettingsName = null;
sascha@778:
tim@612: private String transferInputDataname = null;
tim@612: /**
tim@612: * Constructor
tim@612: */
tim@612: public PreSettingsTransferState() {
tim@612: super();
tim@612: }
tim@612:
tim@612: /**
tim@612: * @see de.intevation.gnv.state.StateBase#initialize(java.lang.String, de.intevation.artifacts.CallContext)
tim@612: */
tim@612: @Override
tim@612: public void initialize(String uuid, CallContext context)
tim@612: throws StateException {
tim@612: Map preSettings = this.getPreSettings();
tim@612: if (preSettings != null){
tim@612: InputData ip = preSettings.get(transferPreSettingsName);
tim@612: if (ip != null){
tim@612: Collection localInputdata = new ArrayList(1);
tim@612: localInputdata.add(new DefaultInputData(transferInputDataname,
tim@612: ip.getValue()));
tim@612: this.putInputData(localInputdata, uuid);
tim@612: }
tim@612: }
sascha@778:
tim@612: super.initialize(uuid, context);
tim@612: }
tim@612:
tim@612: /**
tim@612: * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node)
tim@612: */
tim@612: @Override
tim@612: public void setup(Node configuration) {
sascha@778:
tim@612: Element preSettingsNode = (Element)Config.getNodeXPath(configuration,
tim@612: "presettings-transfer");
tim@612: if (preSettingsNode != null){
tim@612: this.transferPreSettingsName = preSettingsNode.getAttribute("presetting");
tim@732: this.transferInputDataname = preSettingsNode.getAttribute("inputvalue");
tim@612: }
tim@612: super.setup(configuration);
tim@612: }
sascha@778:
sascha@778:
tim@612:
tim@612: }