changeset 7972:ae1629258692

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 26 Jun 2014 15:00:28 +0200
parents 93da474506e7 (diff) 912cf4ec09d1 (current diff)
children 02b7ef079e6f
files
diffstat 3 files changed, 126 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Thu Jun 26 13:00:18 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Thu Jun 26 15:00:28 2014 +0200
@@ -1734,23 +1734,22 @@
                      FROM   bed_height_single bhs
                             JOIN bed_height_single_values bhsv
                               ON bhsv.bed_height_single_id = bhs.id
-                     WHERE  bhs.river_id = ${river_id}
-                            AND bhs.year BETWEEN ${year_from} AND ${year_to}),
+                     WHERE  bhs.river_id = ${river_id}),
                  csta
-                 AS (SELECT b1.id          AS id1,
+                 AS (SELECT b1.id          AS b1id,
                             b1.description AS b1desc,
                             b1.year        AS b1year,
-                            b2.id          AS id2,
-                            b2.description AS b2desv,
+                            b2.id          AS b2id,
+                            b2.description AS b2desc,
                             b2.year        AS b2year
                      FROM   sta b1
                             JOIN sta b2
                               ON b1.station = b2.station
                                  AND b1.id &lt; b2.id)
-            SELECT id1, b1desc, b1year,
-                   id2, b2desc, b2year
+            SELECT DISTINCT b1id, b1desc, b1year,
+                   b2id, b2desc, b2year
             FROM   csta
-            ORDER BY b1year, b2year
+            ORDER BY b1desc, b2desc
           </dc:statement>
           <dc:if test="dc:has-result()">
             <bedheights>
@@ -1763,38 +1762,55 @@
     </dc:macro>
 
     <dc:macro name="bed-heights-single-diff">
-      <dc:filter expr="not(contains(lower-case($b1desc), 'epoche') or contains(lower-case($b2desc), 'epoche'))">
+      <dc:filter expr="not(contains(dc:lowercase($b1desc), 'epoche') or contains(dc:lowercase($b2desc), 'epoche'))">
         <years>
-          <dc:call-macro name="bed-heights-diff-tree"/>
+          <dc:call-macro name="minfo-heights-diff-tree"/>
         </years>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bed-heights-epoch-diff">
-      <dc:filter expr="contains(lower-case($b1desc), 'epoche') and contains(lower-case($b2desc), 'epoche')">
+      <dc:filter expr="contains(dc:lowercase($b1desc), 'epoche') and contains(dc:lowercase($b2desc), 'epoche')">
         <epochs>
-          <dc:call-macro name="bed-heights-diff-tree"/>
+          <dc:call-macro name="minfo-heights-diff-tree"/>
         </epochs>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="minfo-heights-diff-tree">
-      <dc:group expr="$b1year #!# $b2year">
-        <dc:element name="${dc:group-key()}">
-          <dc:comment>TODO: Better structure</dc:comment>
+      <dc:group expr="dc:coalesce($b1year, 'sonstige') #!# dc:coalesce($b2year, 'sonstige')">
+        <minfo-diff name="{dc:group-key()}">
           <dc:for-each>
-            <dc:comment>A - B</dc:comment>
-            <height factory="bedheight"
-                    target_out="{$out}"
-                    ids="bedheight-single-{$b1id}-{$b2id}"
-                    description="{$b1desc} - {$b2desc}"/>
-            <dc:comment>B - A</dc:comment>
-            <height factory="bedheight"
-                    target_out="{$out}"
-                    ids="bedheight-single-{$b2id}-{$b1id}"
-                    description="{$b2desc} - {$b1desc}"/>
+            <dc:choose>
+              <dc:when test="dc:group-key() = $b1year">
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b1id}-{$b1year}#bedheight-single-{$b2id}-{$b2year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b1desc} - {$b2desc}"/>
+              </dc:when>
+              <dc:when test="dc:group-key() = 'sonstige'">
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b1id}-{$b1year}#bedheight-single-{$b2id}-{$b2year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b1desc} - {$b2desc}"/>
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b2id}-{$b2year}#bedheight-single-{$b1id}-{$b1year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b2desc} - {$b1desc}"/>
+              </dc:when>
+              <dc:otherwise>
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b2id}-{$b2year}#bedheight-single-{$b1id}-{$b1year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b2desc} - {$b1desc}"/>
+              </dc:otherwise>
+            </dc:choose>
           </dc:for-each>
-        </dc:element>
+        </minfo-diff>
       </dc:group>
     </dc:macro>
 
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacageWidget.java	Thu Jun 26 13:00:18 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacageWidget.java	Thu Jun 26 15:00:28 2014 +0200
@@ -292,6 +292,20 @@
     }
 
 
+    public List<TreeNode> getPlainSelection() {
+        ListGridRecord [] selection = treeGrid.getSelectedRecords();
+        List<TreeNode> nodes = new ArrayList<TreeNode>();
+        if (selection != null) {
+            for (ListGridRecord record: selection) {
+                if (record instanceof TreeNode) {
+                    nodes.add((TreeNode)record);
+                }
+            }
+        }
+        return nodes;
+    }
+
+
     /**
      * Returns the titles of selected items (if any).
      */
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedHeightsDatacagePanel.java	Thu Jun 26 13:00:18 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedHeightsDatacagePanel.java	Thu Jun 26 15:00:28 2014 +0200
@@ -14,14 +14,17 @@
 
 import com.smartgwt.client.data.Record;
 
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
 
 import com.smartgwt.client.widgets.events.ClickEvent;
-
+import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
 
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tree.TreeNode;
 
 import org.dive4elements.river.client.client.Config;
 import org.dive4elements.river.client.client.FLYSConstants;
@@ -35,6 +38,7 @@
 
 import org.dive4elements.river.client.client.ui.DatacagePairWidget;
 import org.dive4elements.river.client.client.ui.DatacageTwinPanel;
+import org.dive4elements.river.client.client.ui.DatacageWidget;
 import org.dive4elements.river.client.client.ui.RecommendationPairRecord;
 
 import org.dive4elements.river.client.shared.model.Artifact;
@@ -42,6 +46,7 @@
 import org.dive4elements.river.client.shared.model.Data;
 import org.dive4elements.river.client.shared.model.DataItem;
 import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.ToLoad;
 
 import org.dive4elements.river.client.shared.model.Recommendation.Facet;
 import org.dive4elements.river.client.shared.model.Recommendation.Filter;
@@ -80,6 +85,7 @@
     RemoveArtifactServiceAsync removeArtifactService = GWT.create(
             org.dive4elements.river.client.client.services.RemoveArtifactService.class);
 
+    protected DatacageWidget datacage;
 
     public BedHeightsDatacagePanel(User user) {
         super(user);
@@ -120,14 +126,25 @@
     public Canvas create(DataList dataList) {
         GWT.log("createData()");
 
-        String filter = "minfo-heights";
+        String filter = "minfo-heights-diff";
         Canvas widget = createWidget();
         Canvas submit = getNextButton();
+        datacage = new DatacageWidget(
+            this.artifact, user, filter, "load-system:true", false);
+
+        Button plusBtn = new Button(MSG.datacage_add_pair());
+        plusBtn.setAutoFit(true);
+        plusBtn.addClickHandler(new ClickHandler() {
+            @Override
+            public void onClick(ClickEvent event) {
+                plusClicked();
+            }
+        });
 
         VLayout layout       = new VLayout();
-        HLayout helperLayout = new HLayout();
-        helperLayout.addMember(new DatacagePairWidget(this.artifact,
-            user, filter, differencesList));
+        VLayout helperLayout = new VLayout();
+        helperLayout.addMember(datacage);
+        helperLayout.addMember(plusBtn);
 
         layout.addMember(widget);
         layout.addMember(submit);
@@ -306,5 +323,53 @@
                 + recommendation.getDisplayName() + "]";
         }
     }
+
+    /**
+     * Callback for add-button.
+     * Fires to load for every selected element and handler.
+     */
+    public void plusClicked() {
+        List<TreeNode> selection = datacage.getPlainSelection();
+
+        if (selection == null || selection.isEmpty()) {
+            SC.say(MSG.warning());
+            return;
+        }
+
+        for (TreeNode node : selection) {
+            ToLoad toLoad1 = new ToLoad();
+            ToLoad toLoad2 = new ToLoad();
+
+            String factory = node.getAttribute("factory");
+            if (factory != null) { // we need at least a factory
+                String artifact    = node.getAttribute("artifact-id");
+                String out         = node.getAttribute("out");
+                String name        = node.getAttribute("facet");
+                String ids         = node.getAttribute("ids");
+                String info        = node.getAttribute("info");
+                String targetOut   = node.getAttribute("target_out");
+
+                String[] splitIds = ids.split("#");
+                String[] splitInfo = info.split("#");
+                toLoad1.add(artifact,
+                     factory,
+                     out,
+                     name,
+                     splitIds[0],
+                     splitInfo[0],
+                     targetOut);
+                toLoad2.add(artifact,
+                     factory,
+                     out,
+                     name,
+                     splitIds[1],
+                     splitInfo[1],
+                     targetOut);
+            }
+            differencesList.addData(new RecommendationPairRecord(
+                toLoad1.toRecommendations().get(0),
+                toLoad2.toRecommendations().get(0)));
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org