Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferState.java @ 1119:7c4f81f74c47
merged gnv-artifacts
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:00 +0200 |
parents | dec4257ad570 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferState.java Fri Sep 28 12:14:00 2012 +0200 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2010 by Intevation GmbH + * + * This program is free software under the LGPL (>=v2.1) + * Read the file LGPL.txt coming with the software for details + * or visit http://www.gnu.org/licenses/ if it does not exist. + */ + +package de.intevation.gnv.state; + +import de.intevation.artifacts.common.utils.Config; + +import de.intevation.artifacts.CallContext; + +import de.intevation.gnv.state.exception.StateException; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * This special state does a lookup for already inserted data while + * initializing. If there are some data for this state, take them for further + * work. + * + * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> + */ +public class PreSettingsTransferState extends DefaultState { + + /** + * The UID of this Class + */ + private static final long serialVersionUID = 573381812690806922L; + + private String transferPreSettingsName = null; + + private String transferInputDataname = null; + /** + * Constructor + */ + public PreSettingsTransferState() { + super(); + } + + + /** + * This method does a lookup for already inserted data before initializing + * it. + * + * @param uuid + * @param context + * @throws StateException + */ + @Override + public void initialize(String uuid, CallContext context) + throws StateException { + Map<String, InputData> preSettings = this.getPreSettings(); + if (preSettings != null){ + InputData ip = preSettings.get(transferPreSettingsName); + if (ip != null){ + Collection<InputData> localInputdata = new ArrayList<InputData>(1); + localInputdata.add(new DefaultInputData(transferInputDataname, + ip.getValue())); + this.putInputData(localInputdata, uuid); + } + } + + super.initialize(uuid, context); + } + + + /** + * + * @param configuration + */ + @Override + public void setup(Node configuration) { + + Element preSettingsNode = (Element)Config.getNodeXPath(configuration, + "presettings-transfer"); + if (preSettingsNode != null){ + this.transferPreSettingsName = preSettingsNode.getAttribute("presetting"); + this.transferInputDataname = preSettingsNode.getAttribute("inputvalue"); + } + super.setup(configuration); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :