tim@747: package de.intevation.gnv.state;
tim@747:
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@747: import java.util.ArrayList;
tim@747: import java.util.Collection;
tim@747: import java.util.Map;
tim@747:
tim@747: import org.w3c.dom.Element;
tim@747: import org.w3c.dom.Node;
tim@747:
tim@747: /**
ingo@796: * This method looks for former inserted coordinates before initialization.
sascha@803: *
sascha@780: * @author Tim Englich
tim@747: */
tim@747: public class PreSettingsTransferCoordinateSelectionState extends CoordinateSelectionState {
tim@747:
tim@747:
tim@747: /**
tim@747: * The UID of this Class.
tim@747: */
tim@747: private static final long serialVersionUID = -3972304838976884048L;
tim@747:
tim@747: private String transferPreSettingsName = null;
sascha@778:
tim@747: private String transferInputDataname = null;
tim@747: /**
tim@747: * Constructor
tim@747: */
tim@747: public PreSettingsTransferCoordinateSelectionState() {
tim@747: super();
tim@747: }
tim@747:
ingo@796:
tim@747: /**
ingo@796: * Lookup mechanism for former inserted data before intialization begins.
sascha@803: *
ingo@796: * @param uuid
ingo@796: * @param context
ingo@796: * @throws StateException
tim@747: */
tim@747: @Override
tim@747: public void initialize(String uuid, CallContext context)
tim@747: throws StateException {
tim@747: Map preSettings = this.getPreSettings();
tim@747: if (preSettings != null){
tim@747: InputData ip = preSettings.get(transferPreSettingsName);
tim@747: if (ip != null){
tim@747: Collection localInputdata = new ArrayList(1);
tim@747: localInputdata.add(new DefaultInputData(transferInputDataname,
tim@747: ip.getValue()));
tim@747: this.putInputData(localInputdata, uuid);
tim@747: }
tim@747: }
sascha@778:
tim@747: super.initialize(uuid, context);
tim@747: }
tim@747:
ingo@796:
tim@747: /**
sascha@803: *
ingo@796: * @param configuration
tim@747: */
tim@747: @Override
tim@747: public void setup(Node configuration) {
sascha@778:
tim@747: Element preSettingsNode = (Element)Config.getNodeXPath(configuration,
tim@747: "presettings-transfer");
tim@747: if (preSettingsNode != null){
tim@747: this.transferPreSettingsName = preSettingsNode.getAttribute("presetting");
tim@747: this.transferInputDataname = preSettingsNode.getAttribute("inputvalue");
tim@747: }
tim@747: super.setup(configuration);
tim@747: }
tim@747: }
ingo@796: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :