changeset 1409:ec6e4dad1279

Read and display all FLYS relevant information of Capabilities documents. flys-client/trunk@3296 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 21 Nov 2011 18:15:44 +0000
parents 5b5a20e4c4e5
children 6bb2c1ffab2b
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/map/CapabilitiesPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java flys-client/src/main/java/de/intevation/flys/client/server/GCServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Capabilities.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ContactInformation.java flys-client/src/main/webapp/FLYS.css
diffstat 11 files changed, 338 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/ChangeLog	Mon Nov 21 18:15:44 2011 +0000
@@ -1,3 +1,30 @@
+2011-11-21  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/shared/model/ContactInformation.java:
+	  New. This class is used to store contact information from Capabilities
+	  documents.
+
+	* src/main/java/de/intevation/flys/client/shared/model/Capabilities.java:
+	  Added title, onlineResource and ContactInformation.
+
+	* src/main/java/de/intevation/flys/client/server/GCServiceImpl.java: Read
+	  more meta information from capabilities document.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java:
+	  Center this window after stepping from URL input to information panel.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/CapabilitiesPanel.java:
+	  Display all information from Capabilities object and introduced I18N.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties:
+	  Added strings used in the CapabilitiesPanel.
+
+	* src/main/webapp/FLYS.css: Defined a style class for the user hint in the
+	  CapabilitiesPanel.
+
 2011-11-21  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/Capabilities.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Nov 21 18:15:44 2011 +0000
@@ -537,5 +537,23 @@
     String rastermap();
 
     String background();
+
+    // Capabilities Information Panel
+
+    String capabilitiesHint();
+
+    String capabilitiesTitle();
+
+    String capabilitiesURL();
+
+    String capabilitiesAccessConstraints();
+
+    String capabilitiesFees();
+
+    String capabilitiesContactInformation();
+
+    String capabilitiesEmail();
+
+    String capabilitiesPhone();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Nov 21 18:15:44 2011 +0000
@@ -277,3 +277,13 @@
 fixpoints = Fixpoints
 rastermap = Rastermap
 background = Background Map
+
+# capabilities information panel
+capabilitiesHint = Please notice the information of the WMS service.
+capabilitiesTitle = Title
+capabilitiesURL = URL
+capabilitiesAccessConstraints = Access Constraints
+capabilitiesFees = Fees
+capabilitiesContactInformation = Further Information
+capabilitiesEmail = Email
+capabilitiesPhone = Phone
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Nov 21 18:15:44 2011 +0000
@@ -277,3 +277,13 @@
 fixpoints = Festpunkte
 rastermap = Rasterkarte
 background = Hintergrundkarte
+
+# capabilities information panel
+capabilitiesHint = Bitte beachten Sie die folgenden Informationen des WMS-Dienstes.
+capabilitiesTitle = Titel
+capabilitiesURL = URL
+capabilitiesAccessConstraints = Nutzungsbedingungen
+capabilitiesFees = Geb\u00fchren
+capabilitiesContactInformation = Weitere Informationen
+capabilitiesEmail = Email
+capabilitiesPhone = Telefon
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Nov 21 18:15:44 2011 +0000
@@ -277,3 +277,13 @@
 fixpoints = Fixpoints
 rastermap = Rastermap
 background = Background Layer
+
+# capabilities information panel
+capabilitiesHint = Please notice the information of the WMS service.
+capabilitiesTitle = Title
+capabilitiesURL = URL
+capabilitiesAccessConstraints = Access Constraints
+capabilitiesFees = Fees
+capabilitiesContactInformation = Further Information
+capabilitiesEmail = Email
+capabilitiesPhone = Phone
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/CapabilitiesPanel.java	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/CapabilitiesPanel.java	Mon Nov 21 18:15:44 2011 +0000
@@ -1,17 +1,23 @@
 package de.intevation.flys.client.client.ui.map;
 
+import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.ui.Grid;
 
+import com.smartgwt.client.types.Overflow;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.Layout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.shared.model.Capabilities;
+import de.intevation.flys.client.shared.model.ContactInformation;
+import de.intevation.flys.client.client.FLYSConstants;
 
 
 public class CapabilitiesPanel extends VLayout {
 
+    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
     protected Capabilities capabilites;
 
 
@@ -24,55 +30,48 @@
 
 
     protected void initLayout() {
-        setMargin(10);
+        setMargin(5);
+        setOverflow(Overflow.AUTO);
         initContent();
     }
 
 
     protected void initContent() {
-        Grid grid = new Grid(5, 2);
+        Grid grid = new Grid(10, 2);
         grid.setCellPadding(10);
 
-        grid.setText(0, 0, "Titel:");
-        grid.setText(0, 1, "TODO:");
-        grid.setText(1, 0, "URL:");
-        grid.setText(1, 1, "TODO");
-        grid.setText(2, 0, "Nutzungsbedingungen:");
+        grid.setText(0, 0, MSG.capabilitiesTitle() + ":");
+        grid.setText(0, 1, capabilites.getTitle());
+        grid.setText(1, 0, MSG.capabilitiesURL() + ":");
+        grid.setText(1, 1, capabilites.getOnlineResource());
+        grid.setText(2, 0, MSG.capabilitiesAccessConstraints() + ":");
         grid.setText(2, 1, capabilites.getAccessConstraints());
-        grid.setText(3, 0, "Gebühren:");
+        grid.setText(3, 0, MSG.capabilitiesFees() + ":");
         grid.setText(3, 1, capabilites.getFees());
-        grid.setText(4, 0, "Weitere Informationen:");
-        grid.setText(4, 1, "TODO");
 
-        Label title = new Label("Bitte beachten Sie folgende Informationen des WMS-Dienstes:");
+        ContactInformation ci = capabilites.getContactInformation();
+        grid.setText(4, 0, MSG.capabilitiesContactInformation() + ":");
+        grid.setText(4, 1, ci.getPerson());
+        grid.setText(5, 0, "");
+        grid.setText(5, 1, ci.getOrganization());
+        grid.setText(6, 0, "");
+        grid.setText(6, 1, ci.getAddress());
+        grid.setText(7, 0, "");
+        grid.setText(7, 1, ci.getPostcode() + " " + ci.getCity());
+        grid.setText(8, 0, "");
+        grid.setText(8, 1, MSG.capabilitiesEmail() + ": " + ci.getEmail());
+        grid.setText(9, 0, "");
+        grid.setText(9, 1, MSG.capabilitiesPhone() + ": " + ci.getPhone());
+
+        Label title = new Label(MSG.capabilitiesHint());
         title.setHeight(25);
+        title.setStyleName("capabilities-info-title");
 
         addMember(title);
         addMember(grid);
     }
 
 
-    //private void initLayout() {
-    //    Label title   = new Label("Titel:");
-    //    Label url     = new Label("URL:");
-    //    Label access  = new Label("Nutzungsbedingungen:");
-    //    Label fees    = new Label("Gebühren:");
-    //    Label contact = new Label("Weitere Informationen:");
-
-    //    Label titleContent   = new Label("TODO");
-    //    Label urlContent     = new Label("TODO");
-    //    Label accessContent  = new Label(capabilites.getAccessConstraints());
-    //    Label feesContent    = new Label(capabilites.getFees());
-    //    Label contactContent = new Label("TODO");
-
-    //    addMember(createRow(title, titleContent));
-    //    addMember(createRow(url, urlContent));
-    //    addMember(createRow(access, accessContent));
-    //    addMember(createRow(fees, feesContent));
-    //    addMember(createRow(contact, contactContent));
-    //}
-
-
     protected Layout createRow(Label title, Label content) {
         title.setWidth(100);
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 21 18:15:44 2011 +0000
@@ -98,6 +98,8 @@
 
         setWidth(500);
         setHeight(500);
+
+        centerInPage();
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/server/GCServiceImpl.java	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/GCServiceImpl.java	Mon Nov 21 18:15:44 2011 +0000
@@ -11,6 +11,7 @@
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
 import org.apache.log4j.Logger;
 
@@ -18,6 +19,7 @@
 
 import de.intevation.flys.client.shared.exceptions.ServerException;
 import de.intevation.flys.client.shared.model.Capabilities;
+import de.intevation.flys.client.shared.model.ContactInformation;
 import de.intevation.flys.client.client.services.GCService;
 
 
@@ -37,6 +39,36 @@
     public static final String ERR_MALFORMED_URL =
         "error_malformed_url";
 
+    public static final String XPATH_TITLE =
+        "/WMS_Capabilities/Service/Title/text()";
+
+    public static final String XPATH_ONLINE_RESOURCE =
+        "/WMS_Capabilities/Service/OnlineResource/@href";
+
+    public static final String XPATH_CONTACT_INFORMATION =
+        "/WMS_Capabilities/Service/ContactInformation";
+
+    public static final String XPATH_CI_PERSON =
+        "ContactPersonPrimary/ContactPerson/text()";
+
+    public static final String XPATH_CI_ORGANIZATION =
+        "ContactPersonPrimary/ContactOrganization/text()";
+
+    public static final String XPATH_CI_ADDRESS =
+        "ContactAddress/Address/text()";
+
+    public static final String XPATH_CI_CITY =
+        "ContactAddress/City/text()";
+
+    public static final String XPATH_CI_POSTCODE =
+        "ContactAddress/PostCode/text()";
+
+    public static final String XPATH_CI_PHONE =
+        "ContactVoiceTelephone/text()";
+
+    public static final String XPATH_CI_EMAIL =
+        "ContactElectronicMailAddress/text()";
+
     public static final String XPATH_FEES =
         "/WMS_Capabilities/Service/Fees/text()";
 
@@ -87,6 +119,16 @@
             throw new ServerException(ERR_GC_DOC_NOT_VALID);
         }
 
+        String title = (String) XMLUtils.xpath(
+            doc,
+            XPATH_TITLE,
+            XPathConstants.STRING);
+
+        String onlineResource = (String) XMLUtils.xpath(
+            doc,
+            XPATH_ONLINE_RESOURCE,
+            XPathConstants.STRING);
+
         String fees = (String) XMLUtils.xpath(
             doc,
             XPATH_FEES,
@@ -97,12 +139,74 @@
             XPATH_ACCESS_CONSTRAINTS,
             XPathConstants.STRING);
 
+        Node contactInformation = (Node) XMLUtils.xpath(
+            doc,
+            XPATH_CONTACT_INFORMATION,
+            XPathConstants.NODE);
+
+        ContactInformation ci = parseContactInformation(contactInformation);
+
         logger.debug("Found fees: " + fees);
         logger.debug("Found access constraints: " + accessConstraints);
 
         // TODO PARSE LAYERS
 
-        return new Capabilities(fees, accessConstraints, null);
+        return new Capabilities(
+            title,
+            onlineResource,
+            ci,
+            fees,
+            accessConstraints,
+            null);
+    }
+
+
+    protected ContactInformation parseContactInformation(Node node) {
+        String person = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_PERSON,
+            XPathConstants.STRING);
+
+        String organization = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_ORGANIZATION,
+            XPathConstants.STRING);
+
+        String address = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_ADDRESS,
+            XPathConstants.STRING);
+
+        String postcode = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_POSTCODE,
+            XPathConstants.STRING);
+
+        String city = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_CITY,
+            XPathConstants.STRING);
+
+        String phone = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_PHONE,
+            XPathConstants.STRING);
+
+        String email = (String) XMLUtils.xpath(
+            node,
+            XPATH_CI_EMAIL,
+            XPathConstants.STRING);
+
+        ContactInformation ci = new ContactInformation();
+        ci.setPerson(person);
+        ci.setOrganization(organization);
+        ci.setAddress(address);
+        ci.setPostcode(postcode);
+        ci.setCity(city);
+        ci.setPhone(phone);
+        ci.setEmail(email);
+
+        return ci;
     }
 }
 // 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/Capabilities.java	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Capabilities.java	Mon Nov 21 18:15:44 2011 +0000
@@ -7,9 +7,13 @@
 
 public class Capabilities implements Serializable {
 
+    protected String title;
+    protected String onlineResource;
     protected String fees;
     protected String accessConstraints;
 
+    protected ContactInformation contactInformation;
+
     protected List<String> layers;
 
 
@@ -24,13 +28,34 @@
      * @param layers
      */
     public Capabilities(
-        String       fees,
-        String       accessConstraints,
-        List<String> layers
+        String             title,
+        String             onlineResource,
+        ContactInformation contactInformation,
+        String             fees,
+        String             accessConstraints,
+        List<String>       layers
     ) {
-        this.fees              = fees;
-        this.accessConstraints = accessConstraints;
-        this.layers            = layers;
+        this.title              = title;
+        this.onlineResource     = onlineResource;
+        this.contactInformation = contactInformation;
+        this.fees               = fees;
+        this.accessConstraints  = accessConstraints;
+        this.layers             = layers;
+    }
+
+
+    public String getTitle() {
+        return title;
+    }
+
+
+    public String getOnlineResource() {
+        return onlineResource;
+    }
+
+
+    public ContactInformation getContactInformation() {
+        return contactInformation;
     }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ContactInformation.java	Mon Nov 21 18:15:44 2011 +0000
@@ -0,0 +1,90 @@
+package de.intevation.flys.client.shared.model;
+
+import java.io.Serializable;
+
+
+public class ContactInformation implements Serializable {
+
+    protected String person;
+    protected String organization;
+    protected String address;
+    protected String city;
+    protected String postcode;
+    protected String phone;
+    protected String email;
+
+
+    public ContactInformation() {
+    }
+
+
+    public void setPerson(String person) {
+        this.person = person;
+    }
+
+
+    public String getPerson() {
+        return person;
+    }
+
+
+    public void setOrganization(String organization) {
+        this.organization = organization;
+    }
+
+
+    public String getOrganization() {
+        return organization;
+    }
+
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+
+    public String getAddress() {
+        return address;
+    }
+
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+
+    public String getCity() {
+        return city;
+    }
+
+
+    public void setPostcode(String postcode) {
+        this.postcode = postcode;
+    }
+
+
+    public String getPostcode() {
+        return postcode;
+    }
+
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+
+    public String getPhone() {
+        return phone;
+    }
+
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+
+    public String getEmail() {
+        return email;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/webapp/FLYS.css	Mon Nov 21 12:00:48 2011 +0000
+++ b/flys-client/src/main/webapp/FLYS.css	Mon Nov 21 18:15:44 2011 +0000
@@ -132,3 +132,7 @@
 .featureinfo-row {
     border-bottom: 1px solid black;
 }
+
+.capabilities-info-title {
+    font-weight: bold;
+}

http://dive4elements.wald.intevation.org