Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferState.java @ 875:5e9efdda6894
merged gnv-artifacts/1.0
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:56 +0200 |
parents | 05bf8534a35a |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
722:bb3ffe7d719e | 875:5e9efdda6894 |
---|---|
1 package de.intevation.gnv.state; | |
2 | |
3 import de.intevation.artifactdatabase.Config; | |
4 | |
5 import de.intevation.artifacts.CallContext; | |
6 | |
7 import de.intevation.gnv.state.exception.StateException; | |
8 | |
9 import java.util.ArrayList; | |
10 import java.util.Collection; | |
11 import java.util.Map; | |
12 | |
13 import org.w3c.dom.Element; | |
14 import org.w3c.dom.Node; | |
15 | |
16 /** | |
17 * This special state does a lookup for already inserted data while | |
18 * initializing. If there are some data for this state, take them for further | |
19 * work. | |
20 * | |
21 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | |
22 */ | |
23 public class PreSettingsTransferState extends DefaultState { | |
24 | |
25 /** | |
26 * The UID of this Class | |
27 */ | |
28 private static final long serialVersionUID = 573381812690806922L; | |
29 | |
30 private String transferPreSettingsName = null; | |
31 | |
32 private String transferInputDataname = null; | |
33 /** | |
34 * Constructor | |
35 */ | |
36 public PreSettingsTransferState() { | |
37 super(); | |
38 } | |
39 | |
40 | |
41 /** | |
42 * This method does a lookup for already inserted data before initializing | |
43 * it. | |
44 * | |
45 * @param uuid | |
46 * @param context | |
47 * @throws StateException | |
48 */ | |
49 @Override | |
50 public void initialize(String uuid, CallContext context) | |
51 throws StateException { | |
52 Map<String, InputData> preSettings = this.getPreSettings(); | |
53 if (preSettings != null){ | |
54 InputData ip = preSettings.get(transferPreSettingsName); | |
55 if (ip != null){ | |
56 Collection<InputData> localInputdata = new ArrayList<InputData>(1); | |
57 localInputdata.add(new DefaultInputData(transferInputDataname, | |
58 ip.getValue())); | |
59 this.putInputData(localInputdata, uuid); | |
60 } | |
61 } | |
62 | |
63 super.initialize(uuid, context); | |
64 } | |
65 | |
66 | |
67 /** | |
68 * | |
69 * @param configuration | |
70 */ | |
71 @Override | |
72 public void setup(Node configuration) { | |
73 | |
74 Element preSettingsNode = (Element)Config.getNodeXPath(configuration, | |
75 "presettings-transfer"); | |
76 if (preSettingsNode != null){ | |
77 this.transferPreSettingsName = preSettingsNode.getAttribute("presetting"); | |
78 this.transferInputDataname = preSettingsNode.getAttribute("inputvalue"); | |
79 } | |
80 super.setup(configuration); | |
81 } | |
82 } | |
83 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |