Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HWSDatacageState.java @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | 11c853b0854a |
children |
comparison
equal
deleted
inserted
replaced
5175:cfc5540a4eec | 5379:61bf64b102bc |
---|---|
1 package de.intevation.flys.artifacts.states; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import org.w3c.dom.Element; | |
5 | |
6 import de.intevation.artifacts.Artifact; | |
7 import de.intevation.artifacts.CallContext; | |
8 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | |
9 import de.intevation.flys.artifacts.FLYSArtifact; | |
10 | |
11 | |
12 public class HWSDatacageState | |
13 extends DefaultState | |
14 { | |
15 | |
16 private static final Logger logger = Logger.getLogger(HWSDatacageState.class); | |
17 | |
18 @Override | |
19 protected String getUIProvider() { | |
20 return "hws_datacage_panel"; | |
21 } | |
22 | |
23 | |
24 @Override | |
25 protected Element createStaticData( | |
26 FLYSArtifact flys, | |
27 ElementCreator creator, | |
28 CallContext cc, | |
29 String name, | |
30 String value, | |
31 String type | |
32 ) { | |
33 Element dataElement = creator.create("data"); | |
34 creator.addAttr(dataElement, "name", name, true); | |
35 creator.addAttr(dataElement, "type", type, true); | |
36 | |
37 Element itemElement = creator.create("item"); | |
38 creator.addAttr(itemElement, "value", value, true); | |
39 | |
40 creator.addAttr(itemElement, "label", getLabel(cc, value), true); | |
41 dataElement.appendChild(itemElement); | |
42 | |
43 return dataElement; | |
44 } | |
45 | |
46 | |
47 public static String getLabel(CallContext cc, String value) { | |
48 logger.debug("Create label for value: " + value); | |
49 | |
50 return value; | |
51 } | |
52 | |
53 | |
54 @Override | |
55 public boolean validate(Artifact artifact) | |
56 throws IllegalArgumentException | |
57 { | |
58 FLYSArtifact flys = (FLYSArtifact) artifact; | |
59 String hws = flys.getDataAsString("uesk.hws"); | |
60 logger.debug("hws: " + hws); | |
61 return true; | |
62 } | |
63 | |
64 | |
65 /** | |
66 * Returns the DGM specified in the parameters of <i>flys</i>. | |
67 * | |
68 * @param flys The FLYSArtifact that knows the ID of a DGM. | |
69 * | |
70 * @throws IllegalArgumentException If the FLYSArtifact doesn't know the ID | |
71 * of a DGM. | |
72 * | |
73 * @return the DGM specified by FLYSArtifact's parameters. | |
74 */ | |
75 public static String getHWS(FLYSArtifact flys) | |
76 throws IllegalArgumentException | |
77 { | |
78 String hws= flys.getDataAsString("uesk.hws"); | |
79 if (hws == null) { | |
80 return null; | |
81 } | |
82 | |
83 logger.debug("Found selected hws: '" + hws + "'"); | |
84 | |
85 return hws; | |
86 } | |
87 | |
88 | |
89 | |
90 } |