changeset 157:013d47662161

Switched the Communication for Describe-Calls to the artifact-database from get to post. Added the possibility to tell the artifact-database that the ui should not be delivered in describe-responses. gnv/trunk@285 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 05 Nov 2009 14:53:24 +0000
parents aa5197b3f930
children f38a86c2c012
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java
diffstat 8 files changed, 70 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/ChangeLog	Thu Nov 05 14:53:24 2009 +0000
@@ -1,3 +1,20 @@
+2009-11-05  Tim Englich  <tim.englich@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java (ArtifactDatabaseClientFactory): 
+	  Removed some deprecatde TODO-Tasks.
+	* src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java (getCurrentStepDescription): 
+	  Changed the Describe-Call of an Artifact from get to  post an add the Flag which 
+	  determines if the UI should be delivered to the client.
+	* src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java (getCurrentStepDescription): 
+	  Added the possibility to put an Flag which determines if the UI should be delivered from
+	  the artifact-database to the Metodsignature.
+	
+	* src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java (execute),
+	  src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute),
+	  src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java (execute),
+	  src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java (testArtifactDatabaseClient): 
+	  Added the Flag if the UI should be delivered by the artifact-database to the Method-Call.
+
 2009-10-28  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/resources/applicationMessages*.properties:
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Thu Nov 05 14:53:24 2009 +0000
@@ -78,7 +78,8 @@
 
             ArtifactDescription artifactDescription = adc
                     .getCurrentStepDescription(sm.getSelectedArtifactFactory(),
-                            sm.getCurrentArtifact());
+                                               sm.getCurrentArtifact(),
+                                               true);
 
             Node currentUI = artifactDescription.getCurrentUI();
             XSLTransformer transformer = new XSLTransformer();
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Thu Nov 05 14:53:24 2009 +0000
@@ -146,7 +146,8 @@
                     artifactDescription = adc
                             .getCurrentStepDescription(sm
                                     .getSelectedArtifactFactory(), sm
-                                    .getCurrentArtifact());
+                                    .getCurrentArtifact(),
+                                    true);
                     
                     request.setAttribute("diagramm", true);
                     
--- a/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java	Thu Nov 05 14:53:24 2009 +0000
@@ -70,7 +70,7 @@
             sm.setCurrentArtifact(artifact);
 
             ArtifactDescription artifactdescription = adc
-                    .getCurrentStepDescription(af, artifact);
+                    .getCurrentStepDescription(af, artifact,true);
 
             XSLTransformer transformer = new XSLTransformer();
             String ui = transformer.transform(artifactdescription
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java	Thu Nov 05 14:53:24 2009 +0000
@@ -39,7 +39,7 @@
      * @throws ArtifactDatabaseClientException
      */
     public ArtifactObject createNewArtifact(ArtifactObject artifactFactory)
-                                                                           throws ArtifactDatabaseClientException;
+                                            throws ArtifactDatabaseClientException;
 
     /**
      * 
@@ -49,8 +49,9 @@
      */
     public ArtifactDescription getCurrentStepDescription(
                                                          ArtifactObject artifactFactory,
-                                                         ArtifactObject currentArtifact)
-                                                                                        throws ArtifactDatabaseClientException;
+                                                         ArtifactObject currentArtifact,
+                                                         boolean includeUI)
+                                                         throws ArtifactDatabaseClientException;
 
     /**
      * 
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientFactory.java	Thu Nov 05 14:53:24 2009 +0000
@@ -49,7 +49,6 @@
      * @return the ArtifactDatabaseClient
      */
     public ArtifactDatabaseClient getArtifactDatabaseClient(Locale locale) {
-        // TODO Read from Configuration?
         DefaultArtifactDatabaseClient adc = new DefaultArtifactDatabaseClient();
         adc.setLocale(locale);
         return adc;
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Thu Nov 05 14:53:24 2009 +0000
@@ -324,17 +324,46 @@
      */
     public ArtifactDescription getCurrentStepDescription(
                                                          ArtifactObject artifactFactory,
-                                                         ArtifactObject currentArtifact)
-                                                                                        throws ArtifactDatabaseClientException {
+                                                         ArtifactObject currentArtifact,
+                                                         boolean includeUI)
+                                                         throws ArtifactDatabaseClientException {
         try {
             String url = this.getArtifactUrl(artifactFactory, currentArtifact);
-            Document result = this.doGetRequest(url);
-            return this.readDescription(result, currentArtifact);
+            Document request = this.createDescribeRequestBody(currentArtifact,
+                                                              includeUI);
+            InputStream describeResult = this.doPostRequest(url, request);
+    
+            return this.readDescription(new XMLUtils().readDocument(describeResult), 
+                                        currentArtifact);
         } catch (IOException e) {
             log.error(e, e);
             throw new ArtifactDatabaseClientException(e);
         }
     }
+    
+    
+    private Document createDescribeRequestBody(ArtifactObject currentArtifact,
+                                                         boolean includeUI){
+        
+        Document document = new XMLUtils().newDocument();
+        Node rootNode = this.createRootNode(document);
+
+        Element typeNode = this.createArtifactElement(document, "type");
+        typeNode.setAttribute("name", "describe");
+        rootNode.appendChild(typeNode);
+
+        Element uuidNode = this.createArtifactElement(document, "uuid");
+        uuidNode.setAttribute("value", currentArtifact.getId());
+        rootNode.appendChild(uuidNode);
+
+        Element hashNode = this.createArtifactElement(document, "hash");
+        hashNode.setAttribute("value", currentArtifact.getHash());
+        rootNode.appendChild(hashNode);
+        Element includeUINode = this.createArtifactElement(document, "include-ui");
+        includeUINode.appendChild(document.createTextNode(""+includeUI));
+        rootNode.appendChild(includeUINode);
+        return document;
+    }
 
     /**
      * @param artifactFactory
@@ -454,7 +483,15 @@
         try {
             // 1 Feed
             this.doFeed(artifactFactory, currentArtifact, inputParameter);
-            // 2 Advance
+            
+            // 2. Noch einmal Describe um das jetzt zu erreichende Ziel zu ermitteln
+            ArtifactDescription ad = this.getCurrentStepDescription(artifactFactory, 
+                                                                    new Artifact(currentArtifact.getId(), 
+                                                                                 currentArtifact.getHash()),
+                                                                    false);
+            target = ad.getReachableStates().iterator().next();
+            
+            // 3 Advance
             String url = this.getArtifactUrl(artifactFactory, currentArtifact);
             Document advanceDocument = this.createAdvanceRequestBody(
                     currentArtifact, target);
@@ -464,7 +501,7 @@
                     .readDocument(advanceResult));
             // 3 Describe
             return this.getCurrentStepDescription(artifactFactory,
-                    currentArtifact);
+                    currentArtifact,true);
         } catch (IOException e) {
             log.error(e, e);
             throw new ArtifactDatabaseClientException(e);
--- a/gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java	Wed Oct 28 09:52:03 2009 +0000
+++ b/gnv/src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java	Thu Nov 05 14:53:24 2009 +0000
@@ -67,7 +67,7 @@
                     ArtifactObject artifact = artifactDatabaseClient
                             .createNewArtifact(aof);
                     ArtifactDescription ad = artifactDatabaseClient
-                            .getCurrentStepDescription(aof, artifact);
+                            .getCurrentStepDescription(aof, artifact,true);
                     log.debug("Artifact aktualisert.");
                     XSLTransformer transformer = new XSLTransformer();
                     String transformedUI = transformer

http://dive4elements.wald.intevation.org