Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java @ 1571:1227878665b5
Introduced a DataFactory that should be used to create new Data instances.
flys-client/trunk@3836 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 31 Jan 2012 10:34:54 +0000 |
parents | c408074c6409 |
children | f34bbb5fb6d2 |
comparison
equal
deleted
inserted
replaced
1570:eeee85c4d996 | 1571:1227878665b5 |
---|---|
371 DataList list = new DataList(name, size, uiprovider, label); | 371 DataList list = new DataList(name, size, uiprovider, label); |
372 | 372 |
373 for (int j = 0; j < size; j++) { | 373 for (int j = 0; j < size; j++) { |
374 Node dataNode = dataNodes.item(j); | 374 Node dataNode = dataNodes.item(j); |
375 | 375 |
376 String dName = XMLUtils.xpathString( | 376 list.add(DataFactory.createDataFromElement((Element) dataNode)); |
377 dataNode, "@art:name", ArtifactNamespaceContext.INSTANCE); | |
378 String dType = XMLUtils.xpathString( | |
379 dataNode, "@art:type", ArtifactNamespaceContext.INSTANCE); | |
380 | |
381 DataItem[] items = extractOldDataItems(dataNode); | |
382 | |
383 list.add(new DefaultData(dName, dName, dType, items)); | |
384 | 377 |
385 data[i] = list; | 378 data[i] = list; |
386 } | 379 } |
387 } | 380 } |
388 | 381 |
389 return data; | 382 return data; |
390 } | |
391 | |
392 | |
393 /** | |
394 * This method extracts the data items from the data nodes that are placed | |
395 * in the static ui part of the DESCRIBE document. | |
396 * | |
397 * @param dataNode A data node that contains items. | |
398 * | |
399 * @return a list of DataItems. | |
400 */ | |
401 protected static DataItem[] extractOldDataItems(Node dataNode) { | |
402 NodeList itemList = (NodeList) XMLUtils.xpath( | |
403 dataNode, | |
404 XPATH_STATIC_ITEM_NODE, | |
405 XPathConstants.NODESET, | |
406 ArtifactNamespaceContext.INSTANCE); | |
407 | |
408 if (itemList == null || itemList.getLength() == 0) { | |
409 logger.debug("No old data items found."); | |
410 return null; | |
411 } | |
412 | |
413 int count = itemList.getLength(); | |
414 | |
415 DataItem[] items = new DataItem[count]; | |
416 | |
417 for (int i = 0; i < count; i++) { | |
418 Node tmp = itemList.item(i); | |
419 | |
420 String value = XMLUtils.xpathString( | |
421 tmp, "@art:value", ArtifactNamespaceContext.INSTANCE); | |
422 String label = XMLUtils.xpathString( | |
423 tmp, "@art:label", ArtifactNamespaceContext.INSTANCE); | |
424 | |
425 items[i] = new DefaultDataItem(label, label, value); | |
426 } | |
427 | |
428 return items; | |
429 } | 383 } |
430 | 384 |
431 | 385 |
432 /** | 386 /** |
433 * This method extracts the UIProvider specified by the data node. | 387 * This method extracts the UIProvider specified by the data node. |