Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/EventSelect.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/EventSelect.java@58bdf95df5e4 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.states.fixation; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import org.w3c.dom.Element; | |
8 | |
9 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | |
10 | |
11 import org.dive4elements.artifacts.CallContext; | |
12 | |
13 import org.dive4elements.river.artifacts.states.DefaultState; | |
14 import org.dive4elements.river.artifacts.FLYSArtifact; | |
15 import org.dive4elements.river.utils.FLYSUtils; | |
16 | |
17 import org.dive4elements.river.artifacts.model.FixingsOverview; | |
18 import org.dive4elements.river.artifacts.model.FixingsOverviewFactory; | |
19 import org.dive4elements.river.artifacts.model.FixingsOverview.IdFilter; | |
20 import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing; | |
21 | |
22 | |
23 /** | |
24 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
25 */ | |
26 public class EventSelect extends DefaultState { | |
27 | |
28 /** The logger used in this class. */ | |
29 private static Logger logger = Logger.getLogger(EventSelect.class); | |
30 | |
31 | |
32 /** | |
33 * The default constructor that initializes an empty State object. | |
34 */ | |
35 public EventSelect() { | |
36 } | |
37 | |
38 @Override | |
39 protected String getUIProvider() { | |
40 return "fix.event_panel"; | |
41 } | |
42 | |
43 @Override | |
44 protected Element createStaticData( | |
45 FLYSArtifact flys, | |
46 ElementCreator creator, | |
47 CallContext cc, | |
48 String name, | |
49 String value, | |
50 String type | |
51 ) { | |
52 int[] array = FLYSUtils.intArrayFromString(value); | |
53 | |
54 Element dataElement = creator.create("data"); | |
55 creator.addAttr(dataElement, "name", name, true); | |
56 creator.addAttr(dataElement, "type", type, true); | |
57 | |
58 String river = FLYSUtils.getRiver(flys).getName(); | |
59 | |
60 FixingsOverview overview = FixingsOverviewFactory.getOverview(river); | |
61 | |
62 for (int i = 0; i < array.length; i++) { | |
63 Element itemElement = creator.create("item"); | |
64 creator.addAttr( | |
65 itemElement, | |
66 "value", | |
67 String.valueOf(array[i]), | |
68 true); | |
69 | |
70 creator.addAttr( | |
71 itemElement, | |
72 "label", | |
73 getLabel(cc, array[i], overview), | |
74 true); | |
75 dataElement.appendChild(itemElement); | |
76 } | |
77 return dataElement; | |
78 } | |
79 | |
80 | |
81 public static String getLabel( | |
82 CallContext cc, | |
83 int value, | |
84 FixingsOverview overview | |
85 ) { | |
86 logger.debug("Create label for value: " + value); | |
87 | |
88 IdFilter filter = new IdFilter(value); | |
89 List<Fixing.Column> columns = overview.filter(null, filter); | |
90 return columns.isEmpty() | |
91 ? "" | |
92 : columns.get(0).getDescription(); | |
93 } | |
94 } | |
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |