changeset 51:a2923d63f530

Introduced a data structure DataList to manage to list of Data objects of a single state. flys-client/trunk@1505 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Mar 2011 16:44:51 +0000
parents 827eb4e06ebf
children 1d0be51ab93b
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Data.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DataList.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultData.java
diffstat 16 files changed, 335 insertions(+), 127 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/ChangeLog	Thu Mar 17 16:44:51 2011 +0000
@@ -1,3 +1,28 @@
+2011-03-17  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/shared/model/DataList.java: This
+	  data structure manages a list of Data objects. A DataList is the list of
+	  Data objects that a single State can have. So, this class has methods to
+	  retrieve the name of the state it belongs to, the list of Data objects,
+	  the recommended UIProvider and a label.
+
+	* src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java,
+	  src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java,
+	  src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java,
+	  src/main/java/de/intevation/flys/client/shared/model/Data.java,
+	  src/main/java/de/intevation/flys/client/shared/model/DefaultData.java,
+	  src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java,
+	  src/main/java/de/intevation/flys/client/client/ui/ParameterList.java,
+	  src/main/java/de/intevation/flys/client/client/ui/MapSelection.java,
+	  src/main/java/de/intevation/flys/client/client/ui/CollectionView.java,
+	  src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/UIProvider.java,
+	  src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java,
+	  src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java:
+	  Necessary refactoring to introduce the DataList data structure to manage
+	  the list of Data objects a single State provides.
+
 2011-03-17  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/ParameterList.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java	Thu Mar 17 16:44:51 2011 +0000
@@ -13,6 +13,7 @@
 import de.intevation.flys.client.client.event.StepForwardEvent;
 import de.intevation.flys.client.client.event.StepForwardHandler;
 import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataList;
 
 
 /**
@@ -82,7 +83,7 @@
      *
      * @return a Canvas object that displays <i>data</i>.
      */
-    public abstract Canvas create(Data data);
+    public abstract Canvas create(DataList data);
 
 
     /**
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Thu Mar 17 16:44:51 2011 +0000
@@ -19,6 +19,7 @@
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.River;
@@ -260,8 +261,7 @@
             "river",
             messages.river_selection(),
             null,
-            items,
-            null);
+            items);
 
         ModuleSelection widget         = new ModuleSelection();
         HasStepForwardHandlers handler = (HasStepForwardHandlers) widget;
@@ -306,7 +306,10 @@
             }
         });
 
-        return widget.create(data);
+        DataList list = new DataList();
+        list.add(data);
+
+        return widget.create(list);
     }
 
 
@@ -385,7 +388,7 @@
         GWT.log("CollectionView.updateView()");
         ArtifactDescription desc = artifact.getArtifactDescription();
 
-        Data currentData = desc.getCurrentData();
+        DataList currentData = desc.getCurrentData();
         if (currentData != null) {
             String uiProvider   = currentData.getUIProvider();
             UIProvider provider = UIProviderFactory.getProvider(uiProvider);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java	Thu Mar 17 16:44:51 2011 +0000
@@ -19,6 +19,7 @@
 
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.client.FLYSMessages;
@@ -89,7 +90,7 @@
      *
      * @return a panel.
      */
-    public Canvas create(Data data) {
+    public Canvas create(DataList data) {
         VLayout layout = new VLayout();
 
         Label label    = new Label(MESSAGES.location_distance_state());
@@ -106,7 +107,7 @@
     }
 
 
-    protected Canvas createWidget(Data data) {
+    protected Canvas createWidget(DataList data) {
         VLayout layout       = new VLayout();
         container            = new HLayout();
         Canvas checkboxPanel = createRadioButtonPanel();
@@ -146,7 +147,7 @@
         String value  = Double.valueOf(getFinalFrom()).toString();
         DataItem item = new DefaultDataItem("ld_from", "ld_from", value);
         return new DefaultData(
-            "ld_from", null, null, new DataItem[] { item }, null);
+            "ld_from", null, null, new DataItem[] { item });
     }
 
 
@@ -159,7 +160,7 @@
         String value  = Double.valueOf(getFinalTo()).toString();
         DataItem item = new DefaultDataItem("ld_to", "ld_to", value);
         return new DefaultData(
-            "ld_to", null, null, new DataItem[] { item }, null);
+            "ld_to", null, null, new DataItem[] { item });
     }
 
 
@@ -172,7 +173,7 @@
         String value  = Double.valueOf(getFinalStep()).toString();
         DataItem item = new DefaultDataItem("ld_step","ld_step", value);
         return new DefaultData(
-            "ld_step", null, null, new DataItem[] { item }, null);
+            "ld_step", null, null, new DataItem[] { item });
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java	Thu Mar 17 16:44:51 2011 +0000
@@ -8,7 +8,7 @@
 import com.smartgwt.client.widgets.Img;
 import com.smartgwt.client.widgets.layout.HLayout;
 
-import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.client.FLYSImages;
 
 
@@ -37,11 +37,11 @@
      * <b>TODO: The map panel for the river selection needs to be
      * implemented!</b>
      *
-     * @param data The {@link Data} object.
+     * @param data The {@link DataList} object.
      *
      * @return a combobox.
      */
-    protected Canvas createWidget(Data data) {
+    protected Canvas createWidget(DataList data) {
         GWT.log("MapSelection - create()");
 
         HLayout h = new HLayout();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java	Thu Mar 17 16:44:51 2011 +0000
@@ -14,6 +14,7 @@
 
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 
@@ -68,9 +69,7 @@
      *
      * @return the module selection combined with the river selection.
      */
-    public Canvas create(Data data) {
-        dataName = data.getLabel();
-
+    public Canvas create(DataList data) {
         VLayout newLayout = new VLayout();
         newLayout.setMembersMargin(10);
 
@@ -142,7 +141,7 @@
         DataItem[] items = new DefaultDataItem[1];
         items[0]         = new DefaultDataItem(module, module, module);
 
-        Data       data  = new DefaultData("module", null, null, items, null);
+        Data       data  = new DefaultData("module", null, null, items);
 
         return new Data[] {data, river[0]};
     }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Thu Mar 17 16:44:51 2011 +0000
@@ -12,12 +12,13 @@
 
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
 
 
 public class ParameterList extends VLayout {
 
-    protected List<Data> old;
-    protected Data       current;
+    protected List<DataList> old;
+    protected DataList   current;
 
     protected UIProvider uiProvider;
 
@@ -25,7 +26,7 @@
     protected VLayout currentItems;
 
     public ParameterList() {
-        old          = new ArrayList<Data>();
+        old          = new ArrayList<DataList>();
         oldItems     = new VLayout();
         currentItems = new VLayout();
 
@@ -50,7 +51,7 @@
     }
 
 
-    public void addOldData(Data old) {
+    public void addOldData(DataList old) {
         if (old != null) {
             this.old.add(old);
         }
@@ -59,9 +60,9 @@
     }
 
 
-    public void addOldDatas(Data[] old) {
+    public void addOldDatas(DataList[] old) {
         if (old != null && old.length > 0) {
-            for (Data o: old) {
+            for (DataList o: old) {
                 if (!exists(o)) {
                     GWT.log("Data '" + o.getLabel() + "' is new.");
                     addOldData(o);
@@ -75,11 +76,11 @@
     }
 
 
-    public boolean exists(Data data) {
-        String label = data.getLabel();
+    public boolean exists(DataList data) {
+        String stateName = data.getState();
 
-        for (Data o: old) {
-            if (label.equals(o.getLabel())) {
+        for (DataList o: old) {
+            if (stateName.equals(o.getState())) {
                 return true;
             }
         }
@@ -88,7 +89,7 @@
     }
 
 
-    public void setCurrentData(Data current, UIProvider uiProvider) {
+    public void setCurrentData(DataList current, UIProvider uiProvider) {
         this.current    = current;
         this.uiProvider = uiProvider;
 
@@ -101,19 +102,25 @@
         // to the list.
         oldItems.removeMembers(oldItems.getMembers());
 
-        for (Data data: old) {
+        for (DataList dataList: old) {
             HLayout h = new HLayout();
             h.setAlign(VerticalAlignment.TOP);
             h.setHeight(20);
 
-            DataItem[] items = data.getItems();
-            Label label = new Label(data.getLabel());
-            Label value = new Label(items[0].getLabel());
+            int size  = dataList.size();
+            for (int i = 0; i < size; i++) {
+                // TODO Display all Data objects and use the UIProvider to do so!
+                Data data = dataList.get(i);
 
-            h.addMember(label);
-            h.addMember(value);
+                DataItem[] items = data.getItems();
+                Label label = new Label(data.getLabel());
+                Label value = new Label(items[0].getLabel());
 
-            oldItems.addMember(h);
+                h.addMember(label);
+                h.addMember(value);
+
+                oldItems.addMember(h);
+            }
         }
 
         int minHeight = oldItems.getMinHeight();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java	Thu Mar 17 16:44:51 2011 +0000
@@ -1,6 +1,8 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.Map;
 
 import com.google.gwt.core.client.GWT;
 
@@ -10,11 +12,11 @@
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
-import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 
@@ -33,10 +35,7 @@
     protected FLYSMessages messages = GWT.create(FLYSMessages.class);
 
     /** The combobox.*/
-    protected ComboBoxItem combobox;
-
-    /** The name of the data object.*/
-    protected String dataName;
+    protected DynamicForm form;
 
 
     /**
@@ -48,9 +47,7 @@
      *
      * @return a combobox.
      */
-    public Canvas create(Data data) {
-        dataName = data.getLabel();
-
+    public Canvas create(DataList data) {
         VLayout v = new VLayout();
 
         Canvas content = createWidget(data);
@@ -71,29 +68,38 @@
      *
      * @return a combobox.
      */
-    protected Canvas createWidget(Data data) {
+    protected Canvas createWidget(DataList data) {
         GWT.log("SelectProvider - create()");
 
-        HLayout layout   = new HLayout();
-        Label label      = new Label(data.getDescription());
-        DynamicForm form = new DynamicForm();
-        combobox         = new ComboBoxItem(data.getLabel());
+        VLayout layout   = new VLayout();
 
-        LinkedHashMap<String, String> it = new LinkedHashMap<String, String>();
+        form = new DynamicForm();
 
-        for (DataItem item: data.getItems()) {
-            it.put(item.getStringValue(), item.getLabel());
+        int size = data.size();
+
+        for (int i = 0; i < size; i++) {
+            Data d = data.get(i);
+
+            Label label = new Label(d.getDescription());
+            label.setValign(VerticalAlignment.TOP);
+
+            ComboBoxItem combobox = new ComboBoxItem(d.getLabel());
+
+            LinkedHashMap<String, String> it = new LinkedHashMap<String, String>();
+
+            for (DataItem item: d.getItems()) {
+                it.put(item.getStringValue(), item.getLabel());
+            }
+
+            label.setWidth(50);
+            combobox.setValueMap(it);
+            combobox.setShowTitle(false);
+            form.setItems(combobox);
+
+            layout.addMember(label);
+            layout.addMember(form);
         }
 
-        label.setWidth(50);
-        combobox.setValueMap(it);
-        combobox.setShowTitle(false);
-        form.setItems(combobox);
-
-        layout.addMember(label);
-        layout.addMember(form);
-
-        label.setValign(VerticalAlignment.TOP);
         layout.setAlign(VerticalAlignment.TOP);
 
         return layout;
@@ -101,11 +107,23 @@
 
 
     protected Data[] getData() {
-        String selection = combobox.getValueAsString();
-        DataItem item    = new DefaultDataItem(dataName, null, selection);
+        Map values    = form.getValues();
+        Iterator keys = values.keySet().iterator();
 
-        return new Data[] { new DefaultData(
-            dataName, null, null, new DataItem[] { item }, null) };
+        Data[] list = new Data[values.size()];
+        int       i = 0;
+
+        while (keys.hasNext()) {
+            String fieldname = (String) keys.next();
+            String selection = (String) values.get(fieldname);
+
+            DataItem item    = new DefaultDataItem(fieldname, null, selection);
+
+            list[i++] = new DefaultData(
+                fieldname, null, null, new DataItem[] { item });
+        }
+
+        return list;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java	Thu Mar 17 16:44:51 2011 +0000
@@ -4,7 +4,7 @@
 
 import com.smartgwt.client.widgets.Canvas;
 
-import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataList;
 
 
 /**
@@ -19,10 +19,10 @@
      * This method creates a Canvas element showing the DataItems in
      * <i>data</i>.
      *
-     * @param data The data object.
+     * @param data The DataList object.
      *
      * @return the Canvas showing the Data.
      */
-    public Canvas create(Data data);
+    public Canvas create(DataList data);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Thu Mar 17 16:44:51 2011 +0000
@@ -18,6 +18,7 @@
 
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.client.FLYSMessages;
@@ -103,7 +104,7 @@
      *
      * @return the widget.
      */
-    public Canvas create(Data data) {
+    public Canvas create(DataList data) {
         Canvas  widget = createWidget(data);
         IButton submit = new IButton(MSG.next(), this);
         Label   label  = new Label(MSG.wqTitle());
@@ -128,7 +129,7 @@
      *
      * @return the widget.
      */
-    protected Canvas createWidget(Data data) {
+    protected Canvas createWidget(DataList data) {
         VLayout layout  = new VLayout();
         container       = new VLayout();
         Canvas modeForm = createModePanel();
@@ -216,7 +217,7 @@
         String wqMode = modes.getValueAsString(FIELD_WQ);
         DataItem item = new DefaultDataItem("wq_mode", "wq_mode", wqMode);
         return new DefaultData(
-            "wq_mode", null, null, new DataItem[] { item }, null);
+            "wq_mode", null, null, new DataItem[] { item });
     }
 
 
@@ -229,7 +230,7 @@
         String value  = Double.valueOf(getFinalFrom()).toString();
         DataItem item = new DefaultDataItem("wq_from", "wq_from", value);
         return new DefaultData(
-            "wq_from", null, null, new DataItem[] { item }, null);
+            "wq_from", null, null, new DataItem[] { item });
     }
 
 
@@ -242,7 +243,7 @@
         String value  = Double.valueOf(getFinalTo()).toString();
         DataItem item = new DefaultDataItem("wq_to", "wq_to", value);
         return new DefaultData(
-            "wq_to", null, null, new DataItem[] { item }, null);
+            "wq_to", null, null, new DataItem[] { item });
     }
 
 
@@ -255,7 +256,7 @@
         String value  = Double.valueOf(getFinalStep()).toString();
         DataItem item = new DefaultDataItem("wq_step","wq_step", value);
         return new DefaultData(
-            "wq_step", null, null, new DataItem[] { item }, null);
+            "wq_step", null, null, new DataItem[] { item });
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Thu Mar 17 16:44:51 2011 +0000
@@ -14,11 +14,11 @@
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.flys.client.shared.model.ArtifactDescription;
-import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.DefaultArtifactDescription;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
-import de.intevation.flys.client.shared.model.DefaultArtifactDescription;
 
 
 /**
@@ -37,6 +37,8 @@
 
     public static final String XPATH_REACHABLE_STATE = "art:state";
 
+    public static final String XPATH_STATIC_STATE_NODE = "art:state";
+
     public static final String XPATH_STATIC_DATA_NODE = "art:data";
 
     public static final String XPATH_STATIC_ITEM_NODE = "art:item";
@@ -64,8 +66,8 @@
             ArtifactNamespaceContext.INSTANCE);
         System.out.println("Current state name: " + state);
 
-        Data     currentData = extractCurrentData(dynamicNode);
-        Data[]   old         = extractOldData(staticNode);
+        DataList currentData = extractCurrentData(dynamicNode, state);
+        DataList[] old       = extractOldData(staticNode);
         String[] states      = extractReachableStates(reachable);
 
         return new DefaultArtifactDescription(old, currentData, state, states);
@@ -77,24 +79,39 @@
      * current state of the artifact.
      *
      * @param dynamicNode The dynamic node of the DESCRIBE document.
+     * @param state The name of the current state.
      *
      * @return A {@link Data} object that represents the data which might be
      * entered by the user in the current state or null, if no data might be
      * entered.
      */
-    protected static Data extractCurrentData(Node dynamicNode) {
+    protected static DataList extractCurrentData(Node dynamicNode, String state) {
         System.out.println("ArtifactDescriptionFactory - extractCurrentData()");
 
-        Node     data    = ClientProtocolUtils.getSelectNode(dynamicNode);
-        NodeList choices = ClientProtocolUtils.getItemNodes(data);
-        String   label   = ClientProtocolUtils.getLabel(data);
-        String   name    = XMLUtils.xpathString(
-            data, "@art:name", ArtifactNamespaceContext.INSTANCE);
+        NodeList data     = ClientProtocolUtils.getSelectNode(dynamicNode);
+        String uiProvider = extractUIProvider(dynamicNode);
 
-        DataItem[] dataItems = extractCurrentDataItems(choices);
-        String uiProvider    = extractUIProvider(data);
+        if (data == null || data.getLength() == 0) {
+            return null;
+        }
 
-        return new DefaultData(name, label, null, dataItems, uiProvider);
+        int dataNum   = data.getLength();
+        DataList list = new DataList(state, dataNum, uiProvider);
+
+        for (int i = 0; i < dataNum; i++) {
+            Node d = data.item(i);
+
+            NodeList choices  = ClientProtocolUtils.getItemNodes(d);
+            String   label    = ClientProtocolUtils.getLabel(d);
+            String   name     = XMLUtils.xpathString(
+                d, "@art:name", ArtifactNamespaceContext.INSTANCE);
+
+            DataItem[] dataItems = extractCurrentDataItems(choices);
+
+            list.add(new DefaultData(name, label, null, dataItems));
+        }
+
+        return list;
     }
 
 
@@ -136,37 +153,58 @@
      *
      * @param staticNode The static ui node of the DESCRIBE.
      *
-     * @return the Data objects.
+     * @return the DataList objects.
      */
-    protected static Data[] extractOldData(Node staticNode) {
+    protected static DataList[] extractOldData(Node staticNode) {
         System.out.println("ArtifactDescriptionFactory - extractOldData()");
 
-        NodeList dataNodes = (NodeList) XMLUtils.xpath(
+        NodeList stateNodes = (NodeList) XMLUtils.xpath(
             staticNode,
-            XPATH_STATIC_DATA_NODE,
+            XPATH_STATIC_STATE_NODE,
             XPathConstants.NODESET,
             ArtifactNamespaceContext.INSTANCE);
 
-        if (dataNodes == null || dataNodes.getLength() == 0) {
+        if (stateNodes == null || stateNodes.getLength() == 0) {
             System.out.println("No old items found.");
             return null;
         }
 
-        int count = dataNodes.getLength();
-
-        Data[] data = new Data[count];
+        int count       = stateNodes.getLength();
+        DataList[] data = new DataList[count];
 
         for (int i = 0; i < count; i++) {
-            Node tmp = dataNodes.item(i);
+            Node tmp = stateNodes.item(i);
 
             String name = XMLUtils.xpathString(
                 tmp, "@art:name", ArtifactNamespaceContext.INSTANCE);
-            String type = XMLUtils.xpathString(
-                tmp, "@art:type", ArtifactNamespaceContext.INSTANCE);
 
-            DataItem[] items = extractOldDataItems(tmp);
+            NodeList dataNodes = (NodeList) XMLUtils.xpath(
+                tmp,
+                XPATH_STATIC_DATA_NODE,
+                XPathConstants.NODESET,
+                ArtifactNamespaceContext.INSTANCE);
 
-            data[i] = new DefaultData(name, name, type, items, null);
+            if (dataNodes == null || dataNodes.getLength() == 0) {
+                continue;
+            }
+
+            int size      = dataNodes.getLength();
+            DataList list = new DataList(name, size);
+
+            for (int j = 0; j < size; j++) {
+                Node dataNode = dataNodes.item(j);
+
+                String dName = XMLUtils.xpathString(
+                    dataNode, "@art:name", ArtifactNamespaceContext.INSTANCE);
+                String dType = XMLUtils.xpathString(
+                    dataNode, "@art:type", ArtifactNamespaceContext.INSTANCE);
+
+                DataItem[] items = extractOldDataItems(dataNode);
+
+                list.add(new DefaultData(dName, dName, dType, items));
+
+                data[i] = list;
+            }
         }
 
         return data;
@@ -218,9 +256,9 @@
      *
      * @return the UIProvider that is specified in the data node.
      */
-    protected static String extractUIProvider(Node data) {
+    protected static String extractUIProvider(Node ui) {
         return (String) XMLUtils.xpath(
-            data,
+            ui,
             XPATH_UIPROVIDER,
             XPathConstants.STRING,
             ArtifactNamespaceContext.INSTANCE);
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java	Thu Mar 17 16:44:51 2011 +0000
@@ -18,7 +18,7 @@
      *
      * @return the old data of former states.
      */
-    public Data[] getOldData();
+    public DataList[] getOldData();
 
 
     /**
@@ -27,7 +27,7 @@
      *
      * @return the current data.
      */
-    public Data getCurrentData();
+    public DataList getCurrentData();
 
 
     /**
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Data.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Data.java	Thu Mar 17 16:44:51 2011 +0000
@@ -42,13 +42,5 @@
      * @return the DataItems.
      */
     public DataItem[] getItems();
-
-
-    /**
-     * Returns the UIProvider that should be used to create UIs.
-     *
-     * @return the UIProvider.
-     */
-    public String getUIProvider();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DataList.java	Thu Mar 17 16:44:51 2011 +0000
@@ -0,0 +1,133 @@
+package de.intevation.flys.client.shared.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DataList implements Serializable {
+
+    /** The list of Data objects managed by this list.*/
+    protected List<Data> data;
+
+    /** The name of the state that this list belongs to.*/
+    protected String state;
+
+    /** The name of a UIProvider that is recommended to render this DataList.*/
+    protected String uiprovider;
+
+    /** The label that should be used to label data objects.*/
+    protected String label;
+
+
+    /**
+     * The default constructor that creates a new DataList without Data objects
+     * and no UIProvider.
+     */
+    public DataList() {
+        data = new ArrayList<Data>();
+    }
+
+
+    public DataList(String state, int size) {
+        this.state = state;
+        this.data  = new ArrayList<Data>(size);
+    }
+
+
+    /**
+     * A constructor that creates a new DataList without Data objects and no
+     * UIProvider. Size defines the initial size of the list.
+     *
+     * @param size The initial size of the list.
+     */
+    public DataList(String state, int size, String uiprovider) {
+        this(state, size);
+        this.uiprovider = uiprovider;
+    }
+
+
+    /**
+     * Adds a new Data object to the list.
+     *
+     * @param obj The Data object.
+     */
+    public void add(Data obj) {
+        if (obj != null) {
+            data.add(obj);
+        }
+    }
+
+
+    /**
+     * Adds a new Data objects to the list.
+     *
+     * @param obj The Data object.
+     */
+    public void add(Data[] obj) {
+        if (obj != null) {
+            for (Data o: obj) {
+                data.add(o);
+            }
+        }
+    }
+
+
+    /**
+     * Returns the Data element at position <i>idx</i>.
+     *
+     * @param idx The position of an element that should be returned.
+     *
+     * @return the Data element at position <i>idx</i>.
+     */
+    public Data get(int idx) {
+        if (idx < size()) {
+            return data.get(idx);
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Returns the number of Data objects in the list.
+     *
+     * @param the number of Data objects in the list.
+     */
+    public int size() {
+        return data.size();
+    }
+
+
+    /**
+     * Returns the name of the state that this list belongs to.
+     *
+     * @return the name of the state that this list belongs to.
+     */
+    public String getState() {
+        return state;
+    }
+
+
+    /**
+     * Returns the label for this list.
+     *
+     * @return the label of this list.
+     */
+    public String getLabel() {
+        return label;
+    }
+
+
+    /**
+     * Retrieves the name of a UIProvider or null if no one is recommended.
+     *
+     * @return the name of a UIProvider or null if no one is recommended.
+     */
+    public String getUIProvider() {
+        return uiprovider;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java	Thu Mar 17 16:44:51 2011 +0000
@@ -11,10 +11,10 @@
 public class DefaultArtifactDescription implements ArtifactDescription {
 
     /** Data that have been inserted in former states.*/
-    protected Data[]   oldData;
+    protected DataList[] oldData;
 
     /** The Data that is allowed to be inserted in the current state.*/
-    protected Data     currentData;
+    protected DataList currentData;
 
     /** The current state name.*/
     protected String   currentState;
@@ -36,7 +36,7 @@
      * @param reachableStates The names of the reachable states.
      */
     public DefaultArtifactDescription(
-        Data[] old, Data current, String state, String[] reachableStates)
+        DataList[] old, DataList current, String state, String[] reachableStates)
     {
         this.oldData         = old;
         this.currentData     = current;
@@ -45,12 +45,12 @@
     }
 
 
-    public Data[] getOldData() {
+    public DataList[] getOldData() {
         return oldData;
     }
 
 
-    public Data getCurrentData() {
+    public DataList getCurrentData() {
         return currentData;
     }
 
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultData.java	Thu Mar 17 11:49:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultData.java	Thu Mar 17 16:44:51 2011 +0000
@@ -21,9 +21,6 @@
     /** The DataItems.*/
     protected DataItem[] items;
 
-    /** The UIProvider that should be used to create UIs. */
-    protected String uiProvider;
-
 
     public DefaultData() {
     }
@@ -41,14 +38,12 @@
         String label,
         String description,
         String type,
-        DataItem[] items,
-        String uiProvider)
+        DataItem[] items)
     {
         this.label       = label;
         this.description = description;
         this.type        = type;
         this.items       = items;
-        this.uiProvider  = uiProvider;
     }
 
 
@@ -70,10 +65,5 @@
     public DataItem[] getItems() {
         return items;
     }
-
-
-    public String getUIProvider() {
-        return uiProvider;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org