changeset 227:7f7f6d2c4b2c

We can now distinuish between different artifact types based on its name in the DESCRIBE. The ArtifactCreator returns concrete instances of Artifacts now. flys-client/trunk@1673 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Apr 2011 13:46:33 +0000
parents a13382876e5d
children bbe32496dc84
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java
diffstat 5 files changed, 73 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Apr 12 13:11:46 2011 +0000
+++ b/flys-client/ChangeLog	Tue Apr 12 13:46:33 2011 +0000
@@ -1,3 +1,17 @@
+2011-04-12  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/shared/model/Artifact.java,
+	  src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java:
+	  An artifact knows its name now. It is retrievable via getName().
+
+	* src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java:
+	  New. A concrete class that represents an Artifact using the WINFO
+	  parameterization.
+
+	* src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java:
+	  The ArtifactCreator builds up new Artifacts based on the name in the
+	  DESCRIBE document. If no name is included, a DefaultArtifact is created.
+
 2011-04-12  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java	Tue Apr 12 13:11:46 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java	Tue Apr 12 13:46:33 2011 +0000
@@ -9,6 +9,7 @@
 
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.DefaultArtifact;
+import de.intevation.flys.client.shared.model.WINFOArtifact;
 
 
 /**
@@ -26,6 +27,9 @@
     /** The XPath to the artifact's hash value.*/
     public static final String XPATH_HASH = "/art:result/art:hash/@art:value";
 
+    /** The XPath to the artifact's name value.*/
+    public static final String XPATH_NAME = "/art:result/art:name/@art:value";
+
 
     /**
      * Creates a new instance of an {@link ArtifactCreator}.
@@ -69,8 +73,23 @@
         String hash = XMLUtils.xpathString(
             doc, XPATH_HASH, ArtifactNamespaceContext.INSTANCE);
 
+        String name = XMLUtils.xpathString(
+            doc, XPATH_NAME, ArtifactNamespaceContext.INSTANCE);
+
         System.out.println("NEW Artifact UUID: " + uuid);
         System.out.println("NEW Artifact HASH: " + hash);
+        System.out.println("NEW Artifact NAME: " + name);
+
+        if (name == null) {
+            return new DefaultArtifact(uuid, hash);
+        }
+
+        name = name.trim();
+
+        if (name.length() > 0 && name.equals("winfo")) {
+            System.out.println("+++++ NEW WINFO ARTIFACT.");
+            return new WINFOArtifact(uuid, hash);
+        }
 
         return new DefaultArtifact(uuid, hash);
     }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java	Tue Apr 12 13:11:46 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Artifact.java	Tue Apr 12 13:46:33 2011 +0000
@@ -28,6 +28,13 @@
 
 
     /**
+     * Returns the name of the artifact.
+     *
+     * @return the name-
+     */
+    public String getName();
+
+    /**
      * Returns the ArtifactDescription.
      *
      * @return the artifact description.
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java	Tue Apr 12 13:11:46 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifact.java	Tue Apr 12 13:46:33 2011 +0000
@@ -48,6 +48,11 @@
     }
 
 
+    public String getName() {
+        return "default";
+    }
+
+
     public ArtifactDescription getArtifactDescription() {
         return artifactDescription;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/WINFOArtifact.java	Tue Apr 12 13:46:33 2011 +0000
@@ -0,0 +1,28 @@
+package de.intevation.flys.client.shared.model;
+
+
+/**
+ * The WINFO implementation of an Artifact.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class WINFOArtifact extends DefaultArtifact {
+
+    /** The name of this artifact: 'winfo'.*/
+    public static final String NAME = "winfo";
+
+
+    public WINFOArtifact() {
+    }
+
+
+    public  WINFOArtifact(String uuid, String hash) {
+        super(uuid, hash);
+    }
+
+
+    public String getName() {
+        return NAME;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org