ingo@1115: /* ingo@1115: * Copyright (c) 2010 by Intevation GmbH ingo@1115: * ingo@1115: * This program is free software under the LGPL (>=v2.1) ingo@1115: * Read the file LGPL.txt coming with the software for details ingo@1115: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1115: */ ingo@1115: tim@612: package de.intevation.gnv.state; tim@612: sascha@1117: import de.intevation.artifacts.common.utils.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: } sascha@836: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :