changeset 811:8fa303586f14

Pass user id to the meta data service. flys-client/trunk@2466 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 08 Aug 2011 11:02:45 +0000
parents a443dd6566b8
children 70b728a9f4e8
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataService.java flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.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/DatacageButton.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java
diffstat 9 files changed, 76 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/ChangeLog	Mon Aug 08 11:02:45 2011 +0000
@@ -1,3 +1,19 @@
+2011-08-08  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/services/MetaDataService.java,
+	  src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java,
+	  src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.java:
+	  Take the user id, too.
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java,
+	  src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java,
+	  src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Adjusted call to pass the user id to the datacage window.
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacageButton.java,
+	  src/main/java/de/intevation/flys/client/client/ui/DatacagePanel.java:
+	  TODO: Bring user id into play.
+
 2011-08-02  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataService.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataService.java	Mon Aug 08 11:02:45 2011 +0000
@@ -10,8 +10,10 @@
 @RemoteServiceRelativePath("meta-data")
 public interface MetaDataService extends RemoteService
 {
-    DataCageTree getMetaData(String serverUrl, String locale, String name)
-        throws ServerException;
+    DataCageTree getMetaData(
+        String serverUrl, String locale,
+        String artifactId, String userId
+    ) throws ServerException;
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.java	Mon Aug 08 11:02:45 2011 +0000
@@ -8,7 +8,8 @@
     void getMetaData(
         String              serverUrl,
         String              locale,
-        String              name,
+        String              artifactId,
+        String              userId,
         AsyncCallback<DataCageTree> cb);
 }
 // 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/CollectionView.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Mon Aug 08 11:02:45 2011 +0000
@@ -304,6 +304,10 @@
         return artifact;
     }
 
+    public User getUser() {
+        return getFlys().getCurrentUser();
+    }
+
 
     /**
      * Set the current artifact that is the master of the parameterization.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageButton.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageButton.java	Mon Aug 08 11:02:45 2011 +0000
@@ -7,24 +7,26 @@
 import com.smartgwt.client.widgets.events.CloseClientEvent;
 
 import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.User;
 
 
 public class DatacageButton extends Button implements ClickHandler {
 
     protected Artifact artifact;
+    protected User     user;
 
-
-    public DatacageButton(String title, Artifact artifact) {
+    public DatacageButton(String title, Artifact artifact, User user) {
         super(title);
 
         this.artifact = artifact;
+        this.user     = user;
 
         addClickHandler(this);
     }
 
 
     public void onClick(ClickEvent event) {
-        final DatacageWindow dc = new DatacageWindow(artifact);
+        final DatacageWindow dc = new DatacageWindow(artifact, user);
         dc.addCloseClickHandler(new CloseClickHandler() {
             public void onCloseClick(CloseClientEvent event) {
                 dc.destroy();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePanel.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePanel.java	Mon Aug 08 11:02:45 2011 +0000
@@ -52,7 +52,9 @@
         layout.setMembersMargin(10);
 
         layout.addMember(createForm());
-        layout.addMember(new DatacageButton(MSG.databasket(), artifact));
+        // TODO: fetch current user!
+        layout.addMember(
+            new DatacageButton(MSG.databasket(), artifact, null));
 
         return layout;
     }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Mon Aug 08 11:02:45 2011 +0000
@@ -22,6 +22,7 @@
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.User;
 
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.Config;
@@ -43,17 +44,19 @@
 
 
     protected Artifact artifact;
+    protected User     user;
 
     protected TreeGrid treeGrid;
 
     protected Layout layout;
 
 
-    public DatacageWindow(Artifact artifact) {
+    public DatacageWindow(Artifact artifact, User user) {
         this.artifact = artifact;
+        this.user     = user;
 
-        setWidth(200);
-        setHeight(300);
+        setWidth(250);
+        setHeight(400);
 
         layout = new VLayout();
         layout.setWidth100();
@@ -68,6 +71,7 @@
         layout.addMember(treeGrid);
 
         String river =  findRiver();
+        // TODO: i18n
         setTitle("Datenkorb: " + river);
         setShowMinimizeButton(false);
         setIsModal(true);
@@ -76,16 +80,21 @@
 
         centerInPage();
 
-        triggerTreeBuilding(river);
+        triggerTreeBuilding();
     }
 
-    protected void triggerTreeBuilding(String river) {
+    protected void triggerTreeBuilding() {
         Config config = Config.getInstance();
         String url    = config.getServerUrl();
         String locale = config.getLocale();
 
+        String artifactId = artifact.getUuid();
+        String userId     = user != null ? user.identifier() : null;
+
         metaDataService.getMetaData(
-            url, locale, river,
+            url, locale,
+            artifactId,
+            userId,
             new AsyncCallback<DataCageTree>() {
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not load meta data.");
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java	Mon Aug 08 11:02:45 2011 +0000
@@ -12,6 +12,7 @@
 import com.smartgwt.client.widgets.events.CloseClientEvent;
 
 import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.User;
 
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.ui.CollectionView;
@@ -64,7 +65,7 @@
         datacage.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent event) {
                 GWT.log("Clicked 'datacage' button.");
-                openDatacageWindow(getArtifact());
+                openDatacageWindow();
             }
         });
 
@@ -121,6 +122,10 @@
         return view.getArtifact();
     }
 
+    public User getUser() {
+        return view.getUser();
+    }
+
 
     public ChartOutputTab getChartOutputTab() {
         return chartTab;
@@ -149,8 +154,11 @@
     }
 
 
-    protected void openDatacageWindow(Artifact artifact) {
-        final DatacageWindow dc = new DatacageWindow(artifact);
+    protected void openDatacageWindow() {
+        Artifact artifact = getArtifact();
+        User     user     = getUser();
+
+        final DatacageWindow dc = new DatacageWindow(artifact, user);
         dc.addCloseClickHandler(new CloseClickHandler() {
             public void onCloseClick(CloseClientEvent event) {
                 dc.destroy();
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java	Tue Aug 02 12:57:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java	Mon Aug 08 11:02:45 2011 +0000
@@ -29,8 +29,12 @@
     public static final String ERROR_NO_META_DATA_FOUND =
         "error_no_meta_data_found";
 
-    public DataCageTree getMetaData(String url, String locale, String river)
-    throws ServerException
+    public DataCageTree getMetaData(
+        String url,
+        String locale,
+        String artifactId,
+        String userId
+    ) throws ServerException
     {
         System.out.println("MetaDataService.getDistanceInfo");
 
@@ -41,11 +45,18 @@
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
-        Element riverEl = ec.create("river");
 
-        riverEl.setTextContent(river);
+        if (artifactId != null) {
+            Element artifactEl = ec.create("artifact-id");
+            artifactEl.setAttribute("value", artifactId);
+            doc.appendChild(artifactEl);
+        }
 
-        doc.appendChild(riverEl);
+        if (userId != null) {
+            Element userEl = ec.create("user-id");
+            userEl.setAttribute("value", userId);
+            doc.appendChild(userEl);
+        }
 
         HttpClient client = new HttpClientImpl(url, locale);
 

http://dive4elements.wald.intevation.org