comparison 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
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 special state does a lookup for already inserted data while
26 * initializing. If there are some data for this state, take them for further
27 * work.
28 *
29 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
30 */
31 public class PreSettingsTransferState extends DefaultState {
32
33 /**
34 * The UID of this Class
35 */
36 private static final long serialVersionUID = 573381812690806922L;
37
38 private String transferPreSettingsName = null;
39
40 private String transferInputDataname = null;
41 /**
42 * Constructor
43 */
44 public PreSettingsTransferState() {
45 super();
46 }
47
48
49 /**
50 * This method does a lookup for already inserted data before initializing
51 * it.
52 *
53 * @param uuid
54 * @param context
55 * @throws StateException
56 */
57 @Override
58 public void initialize(String uuid, CallContext context)
59 throws StateException {
60 Map<String, InputData> preSettings = this.getPreSettings();
61 if (preSettings != null){
62 InputData ip = preSettings.get(transferPreSettingsName);
63 if (ip != null){
64 Collection<InputData> localInputdata = new ArrayList<InputData>(1);
65 localInputdata.add(new DefaultInputData(transferInputDataname,
66 ip.getValue()));
67 this.putInputData(localInputdata, uuid);
68 }
69 }
70
71 super.initialize(uuid, context);
72 }
73
74
75 /**
76 *
77 * @param configuration
78 */
79 @Override
80 public void setup(Node configuration) {
81
82 Element preSettingsNode = (Element)Config.getNodeXPath(configuration,
83 "presettings-transfer");
84 if (preSettingsNode != null){
85 this.transferPreSettingsName = preSettingsNode.getAttribute("presetting");
86 this.transferInputDataname = preSettingsNode.getAttribute("inputvalue");
87 }
88 super.setup(configuration);
89 }
90 }
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org