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: /**
ingo@796: * This special state does a lookup for already inserted data while
ingo@796: * initializing. If there are some data for this state, take them for further
ingo@796: * work.
ingo@796: *
sascha@780: * @author Tim Englich
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:
ingo@796:
tim@612: /**
ingo@796: * This method does a lookup for already inserted data before initializing
ingo@796: * it.
sascha@803: *
ingo@796: * @param uuid
ingo@796: * @param context
ingo@796: * @throws StateException
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:
ingo@796:
tim@612: /**
sascha@803: *
ingo@796: * @param configuration
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: }
tim@612: }
ingo@796: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :