comparison flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java @ 575:5277f46a63c2

The description of a facet is now displayed in the ChartThemePanel. flys-client/trunk@2141 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Jun 2011 09:57:23 +0000
parents ba238f917b94
children 210339fd1a34
comparison
equal deleted inserted replaced
574:3629d36f0e5d 575:5277f46a63c2
6 import java.util.Map; 6 import java.util.Map;
7 7
8 import javax.xml.xpath.XPathConstants; 8 import javax.xml.xpath.XPathConstants;
9 9
10 import org.w3c.dom.Document; 10 import org.w3c.dom.Document;
11 import org.w3c.dom.Element;
11 import org.w3c.dom.Node; 12 import org.w3c.dom.Node;
12 import org.w3c.dom.NodeList; 13 import org.w3c.dom.NodeList;
13 14
14 import com.google.gwt.user.server.rpc.RemoteServiceServlet; 15 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
15 16
201 int num = themes != null ? themes.getLength() : 0; 202 int num = themes != null ? themes.getLength() : 0;
202 203
203 List<Theme> themeList = new ArrayList<Theme>(num); 204 List<Theme> themeList = new ArrayList<Theme>(num);
204 205
205 for (int i = 0; i < num; i++) { 206 for (int i = 0; i < num; i++) {
206 Theme theme = parseTheme(themes.item(i)); 207 Theme theme = parseTheme((Element) themes.item(i));
207 208
208 if (theme != null) { 209 if (theme != null) {
209 themeList.add(theme); 210 themeList.add(theme);
210 } 211 }
211 } 212 }
212 213
213 return new ThemeList(themeList); 214 return new ThemeList(themeList);
214 } 215 }
215 216
216 217
217 protected Theme parseTheme(Node node) { 218 protected Theme parseTheme(Element ele) {
218 System.out.println("DescribeCollectionServiceImpl.parseTheme"); 219 System.out.println("DescribeCollectionServiceImpl.parseTheme");
219 220
220 String strAct = XMLUtils.xpathString( 221 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
221 node, "@art:active", ArtifactNamespaceContext.INSTANCE); 222
222 223 String strAct = ele.getAttributeNS(uri, "active");
223 String art = XMLUtils.xpathString( 224 String art = ele.getAttributeNS(uri, "artifact");
224 node, "@art:artifact", ArtifactNamespaceContext.INSTANCE); 225 String fac = ele.getAttributeNS(uri, "facet");
225 226 String strPos = ele.getAttributeNS(uri, "pos");
226 String fac = XMLUtils.xpathString( 227 String desc = ele.getAttributeNS(uri, "description");
227 node, "@art:facet", ArtifactNamespaceContext.INSTANCE); 228 String strIdx = ele.getAttributeNS(uri, "index");
228 229
229 String strPos = XMLUtils.xpathString( 230 if (strAct != null && art != null && fac != null
230 node, "@art:pos", ArtifactNamespaceContext.INSTANCE); 231 && strPos != null && strIdx != null)
231 232 {
232 if (strAct != null && art != null && fac != null && strPos != null) {
233 try { 233 try {
234 int pos = Integer.valueOf(strPos); 234 int pos = Integer.valueOf(strPos);
235 int active = Integer.valueOf(strAct); 235 int active = Integer.valueOf(strAct);
236 236 int idx = Integer.valueOf(strIdx);
237 return new DefaultTheme(pos, active > 0, art, fac); 237
238 return new DefaultTheme(pos, idx, active > 0, art, fac, desc);
238 } 239 }
239 catch (NumberFormatException nfe) { 240 catch (NumberFormatException nfe) {
240 nfe.printStackTrace(); 241 nfe.printStackTrace();
241 } 242 }
242 } 243 }
357 358
358 int num = facetList != null ? facetList.getLength() : 0; 359 int num = facetList != null ? facetList.getLength() : 0;
359 360
360 List<Facet> facets = new ArrayList<Facet>(num); 361 List<Facet> facets = new ArrayList<Facet>(num);
361 362
363 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
364
362 for (int i = 0; i < num; i++) { 365 for (int i = 0; i < num; i++) {
363 Node facetNode = facetList.item(i); 366 Element facetEl = (Element) facetList.item(i);
364 367
365 String name = XMLUtils.xpathString( 368 String name = facetEl.getAttributeNS(uri, "name");
366 facetNode, "@art:name", ArtifactNamespaceContext.INSTANCE); 369 String desc = facetEl.getAttributeNS(uri, "description");
367 370 String index = facetEl.getAttributeNS(uri, "index");
368 if (name != null && name.length() > 0) { 371
369 facets.add(new DefaultFacet(name)); 372 if (name != null && name.length() > 0 && index != null) {
373 facets.add(new DefaultFacet(name, Integer.valueOf(index),desc));
370 } 374 }
371 } 375 }
372 376
373 return facets; 377 return facets;
374 } 378 }

http://dive4elements.wald.intevation.org