comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferCoordinateSelectionState.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
comparison
equal deleted inserted replaced
1027:fca4b5eb8d2f 1119:7c4f81f74c47
1 /*
2 * Copyright (c) 2010 by Intevation GmbH
3 *
4 * This program is free software under the LGPL (>=v2.1)
5 * Read the file LGPL.txt coming with the software for details
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
7 */
8
9 package de.intevation.gnv.state;
10
11 import de.intevation.artifacts.common.utils.Config;
12
13 import de.intevation.artifacts.CallContext;
14
15 import de.intevation.gnv.state.exception.StateException;
16
17 import java.util.ArrayList;
18 import java.util.Collection;
19 import java.util.Map;
20
21 import org.w3c.dom.Element;
22 import org.w3c.dom.Node;
23
24 /**
25 * This method looks for former inserted coordinates before initialization.
26 *
27 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
28 */
29 public class PreSettingsTransferCoordinateSelectionState extends CoordinateSelectionState {
30
31
32 /**
33 * The UID of this Class.
34 */
35 private static final long serialVersionUID = -3972304838976884048L;
36
37 private String transferPreSettingsName = null;
38
39 private String transferInputDataname = null;
40 /**
41 * Constructor
42 */
43 public PreSettingsTransferCoordinateSelectionState() {
44 super();
45 }
46
47
48 /**
49 * Lookup mechanism for former inserted data before intialization begins.
50 *
51 * @param uuid
52 * @param context
53 * @throws StateException
54 */
55 @Override
56 public void initialize(String uuid, CallContext context)
57 throws StateException {
58 Map<String, InputData> preSettings = this.getPreSettings();
59 if (preSettings != null){
60 InputData ip = preSettings.get(transferPreSettingsName);
61 if (ip != null){
62 Collection<InputData> localInputdata = new ArrayList<InputData>(1);
63 localInputdata.add(new DefaultInputData(transferInputDataname,
64 ip.getValue()));
65 this.putInputData(localInputdata, uuid);
66 }
67 }
68
69 super.initialize(uuid, context);
70 }
71
72
73 /**
74 *
75 * @param configuration
76 */
77 @Override
78 public void setup(Node configuration) {
79
80 Element preSettingsNode = (Element)Config.getNodeXPath(configuration,
81 "presettings-transfer");
82 if (preSettingsNode != null){
83 this.transferPreSettingsName = preSettingsNode.getAttribute("presetting");
84 this.transferInputDataname = preSettingsNode.getAttribute("inputvalue");
85 }
86 super.setup(configuration);
87 }
88 }
89 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org