changeset 999:b0218f21c664

Wire datacage with backend of artifact database. flys-artifacts/trunk@2438 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 01 Aug 2011 14:58:15 +0000
parents b81626b10cb7
children 46bfe06e51d9
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java
diffstat 4 files changed, 274 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Aug 01 08:31:09 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Aug 01 14:58:15 2011 +0000
@@ -1,3 +1,14 @@
+2011-08-01  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* doc/conf/conf.xml: Added backend listener for datacage.
+
+	* src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java:
+	  New. Proxies backend listener calls to datacage.
+	 
+	* src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java:
+	  Implements backend listener. TODO: Update the datacage database
+	  according the change calls.
+
 2011-08-01  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/services/meta,
--- a/flys-artifacts/doc/conf/conf.xml	Mon Aug 01 08:31:09 2011 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Mon Aug 01 14:58:15 2011 +0000
@@ -50,6 +50,10 @@
         <listener>de.intevation.flys.artifacts.datacage.Datacage</listener>
     </lifetime-listeners>
 
+    <backend-listeners>
+        <listener>de.intevation.flys.artifacts.datacage.DatacageBackendListener</listener>
+    </backend-listeners>
+
     <callcontext-listener
         name="SessionCallContextListener"
         description="A CallContext.Listener to open and close Hibernatesessions">de.intevation.flys.artifacts.context.SessionCallContextListener</callcontext-listener>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Mon Aug 01 08:31:09 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Mon Aug 01 14:58:15 2011 +0000
@@ -8,11 +8,15 @@
 import java.sql.Types;
 
 import de.intevation.artifacts.GlobalContext;
+import de.intevation.artifacts.ArtifactCollection;
+import de.intevation.artifacts.User;
 
 import de.intevation.artifactdatabase.db.SQL;
 import de.intevation.artifactdatabase.db.SQLExecutor;
 
 import de.intevation.artifactdatabase.LifetimeListener;
+import de.intevation.artifactdatabase.BackendListener;
+import de.intevation.artifactdatabase.Backend;
 
 import de.intevation.artifactdatabase.data.StateData;
 
@@ -32,10 +36,13 @@
 import org.w3c.dom.Document;
 
 public class Datacage
-implements   LifetimeListener
+implements   LifetimeListener, BackendListener
 {
     private static Logger log = Logger.getLogger(Datacage.class);
 
+    public static final String DATACAGE_KEY =
+        "global.datacage.instance";
+
     public static final String ARTEFACT_DATABASE_KEY =
         "global.artifact.database";
 
@@ -516,6 +523,7 @@
     public void systemUp(GlobalContext context) {
         log.debug("systemUp entered");
         initialScan(context);
+        context.put(DATACAGE_KEY, this);
         log.debug("systemUp leaved");
     }
 
@@ -571,5 +579,88 @@
     public void systemDown(GlobalContext context) {
         log.debug("systemDown");
     }
+
+    @Override
+    public void setup(GlobalContext globalContext) {
+        log.debug("setup");
+    }
+
+    @Override
+    public void createdArtifact(Artifact artifact, Backend backend) {
+        log.debug("createdArtifact");
+    }
+
+    @Override
+    public void storedArtifact(Artifact artifact, Backend backend) {
+        log.debug("storedArtifact");
+    }
+
+    @Override
+    public void createdUser(User user, Backend backend) {
+        log.debug("createdUser");
+    }
+
+    @Override
+    public void deletedUser(String identifier, Backend backend) {
+        log.debug("deletedUser");
+    }
+
+    @Override
+    public void createdCollection(
+        ArtifactCollection collection,
+        Backend            backend
+    ) {
+        log.debug("createdCollection");
+    }
+
+    @Override
+    public void deletedCollection(String identifier, Backend backend) {
+        log.debug("deletedCollection");
+    }
+
+    @Override
+    public void changedCollectionAttribute(
+        String   identifier,
+        Document document,
+        Backend  backend
+    ) {
+        log.debug("changedCollectionAttribute");
+    }
+
+    @Override
+    public void changedCollectionItemAttribute(
+        String   collectionId,
+        String   artifactId,
+        Document document,
+        Backend  backend
+    ) {
+        log.debug("changedCollectionItemAttribute");
+    }
+
+    @Override
+    public void addedArtifactToCollection(
+        String  artifactId,
+        String  collectionId,
+        Backend backend
+    ) {
+        log.debug("addedArtifactToCollection");
+    }
+
+    @Override
+    public void removedArtifactFromCollection(
+        String  artifactId,
+        String  collectionId,
+        Backend backend
+    ) {
+        log.debug("removedArtifactFromCollection");
+    }
+
+    @Override
+    public void setCollectionName(
+        String collectionId,
+        String name
+    ) {
+        log.debug("setCollectionName");
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java	Mon Aug 01 14:58:15 2011 +0000
@@ -0,0 +1,167 @@
+package de.intevation.flys.artifacts.datacage;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.ArtifactCollection;
+import de.intevation.artifacts.GlobalContext;
+import de.intevation.artifacts.User;
+
+import de.intevation.artifactdatabase.BackendListener;
+import de.intevation.artifactdatabase.Backend;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Document;
+
+public class DatacageBackendListener
+implements   BackendListener
+{
+    private static Logger log =
+        Logger.getLogger(DatacageBackendListener.class);
+
+    protected GlobalContext context;
+
+    public DatacageBackendListener() {
+    }
+
+    protected BackendListener getListener() {
+        Object listener = context.get(Datacage.DATACAGE_KEY);
+        return listener instanceof BackendListener
+            ? (BackendListener)listener
+            : null;
+    }
+
+    @Override
+    public void setup(GlobalContext context) {
+        this.context = context;
+        BackendListener l = getListener();
+        if (l != null) {
+            l.setup(context);
+        }
+    }
+
+    @Override
+    public void createdArtifact(Artifact artifact, Backend backend) {
+        log.debug("createdArtifact");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.createdArtifact(artifact, backend);
+        }
+    }
+
+    @Override
+    public void storedArtifact(Artifact artifact, Backend backend) {
+        log.debug("storedArtifact");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.storedArtifact(artifact, backend);
+        }
+    }
+
+    @Override
+    public void createdUser(User user, Backend backend) {
+        log.debug("createdUser");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.createdUser(user, backend);
+        }
+    }
+
+    @Override
+    public void deletedUser(String identifier, Backend backend) {
+        log.debug("deletedUser");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.deletedUser(identifier, backend);
+        }
+    }
+
+    @Override
+    public void createdCollection(
+        ArtifactCollection collection,
+        Backend            backend
+    ) {
+        log.debug("createdCollection");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.createdCollection(collection, backend);
+        }
+    }
+
+    @Override
+    public void deletedCollection(String identifier, Backend backend) {
+        log.debug("deletedCollection");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.deletedCollection(identifier, backend);
+        }
+    }
+
+    @Override
+    public void changedCollectionAttribute(
+        String   identifier,
+        Document document,
+        Backend  backend
+    ) {
+        log.debug("changedCollectionAttribute");
+        BackendListener l = getListener();
+        if (l != null) {
+            changedCollectionAttribute(identifier, document, backend);
+        }
+    }
+
+    @Override
+    public void changedCollectionItemAttribute(
+        String   collectionId,
+        String   artifactId,
+        Document document,
+        Backend  backend
+    ) {
+        log.debug("changedCollectionItemAttribute");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.changedCollectionItemAttribute(
+                collectionId, artifactId, document, backend);
+        }
+    }
+
+    @Override
+    public void addedArtifactToCollection(
+        String  artifactId,
+        String  collectionId,
+        Backend backend
+    ) {
+        log.debug("addedArtifactToCollection");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.addedArtifactToCollection(
+                artifactId, collectionId, backend);
+        }
+    }
+
+    @Override
+    public void removedArtifactFromCollection(
+        String  artifactId,
+        String  collectionId,
+        Backend backend
+    ) {
+        log.debug("removedArtifactFromCollection");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.removedArtifactFromCollection(
+                artifactId, collectionId, backend);
+        }
+    }
+
+    @Override
+    public void setCollectionName(
+        String collectionId,
+        String name
+    ) {
+        log.debug("setCollectionName");
+        BackendListener l = getListener();
+        if (l != null) {
+            l.setCollectionName(collectionId, name);
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org