changeset 132:8be4a837f20a

Added support for the flys backend and an example how to use it. flys-artifacts/trunk@1498 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 17 Mar 2011 11:46:43 +0000
parents 0bab3a39a474
children d6197a05a87c
files flys-artifacts/ChangeLog flys-artifacts/pom.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/River.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java
diffstat 5 files changed, 38 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Mar 15 17:12:58 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Mar 17 11:46:43 2011 +0000
@@ -1,3 +1,16 @@
+2011-03-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* pom.xml: Added dependency to flys backend.
+
+	* src/main/java/de/intevation/flys/artifacts/model/River.java:
+	  Removed. We are using the backend model now.
+
+	* src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java:
+	  Fetches the rivers from the backend.
+
+	* src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java:
+	  Import fixes.
+
 2011-03-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* doc/conf/conf.xml: Added section for database backend configuration.
--- a/flys-artifacts/pom.xml	Tue Mar 15 17:12:58 2011 +0000
+++ b/flys-artifacts/pom.xml	Thu Mar 17 11:46:43 2011 +0000
@@ -45,5 +45,10 @@
       <artifactId>artifacts-common</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>de.intevation.flys</groupId>
+      <artifactId>flys-backend</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 </project>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/River.java	Tue Mar 15 17:12:58 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import java.io.Serializable;
-
-
-/**
- * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
- */
-public class River implements Serializable {
-
-    /** The river's name. */
-    protected String name;
-
-
-    /**
-     * The default constructor that create a river with a name.
-     *
-     * @param name The name of the river.
-     */
-    public River(String name) {
-        this.name = name;
-    }
-
-
-    /**
-     * Returns the name of the river.
-     *
-     * @return the name of the river.
-     */
-    public String getName() {
-        return name;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java	Tue Mar 15 17:12:58 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java	Thu Mar 17 11:46:43 2011 +0000
@@ -1,8 +1,15 @@
 package de.intevation.flys.artifacts.model;
 
-import java.util.ArrayList;
+
 import java.util.List;
 
+import de.intevation.flys.model.River;
+
+import de.intevation.flys.backend.SessionFactoryProvider;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -20,12 +27,15 @@
      * @return all rivers.
      */
     public static List<River> getRivers() {
-        List<River> rivers = new ArrayList<River>();
-
-        rivers.add(new River("Mosel"));
-        rivers.add(new River("Saar"));
-
-        return rivers;
+        SessionFactory sf = SessionFactoryProvider.getSessionFactory();
+        Session session = sf.openSession();
+        try {
+            return (List<River>)session
+                .createQuery("from River order by name").list();
+        }
+        finally {
+            session.close();
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java	Tue Mar 15 17:12:58 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java	Thu Mar 17 11:46:43 2011 +0000
@@ -14,8 +14,10 @@
 import de.intevation.artifactdatabase.ProtocolUtils;
 import de.intevation.artifactdatabase.data.StateData;
 
-import de.intevation.flys.artifacts.model.River;
+import de.intevation.flys.model.River;
+
 import de.intevation.flys.artifacts.model.RiverFactory;
+
 import de.intevation.flys.artifacts.resources.Resources;
 
 

http://dive4elements.wald.intevation.org