changeset 1006:1917f32701dc

Forwarded kill collections and artifacts events to datacage. flys-artifacts/trunk@2447 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 02 Aug 2011 11:38:20 +0000
parents 52949da92f7a
children ed918497873b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties flys-artifacts/src/main/resources/datacage-sql/org-postgresql-driver.properties
diffstat 5 files changed, 76 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Aug 02 11:20:18 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Aug 02 11:38:20 2011 +0000
@@ -1,3 +1,13 @@
+2011-08-02  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java,
+	  src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java:
+	  Forwarded kill collections and artifacts events to datacage.
+	
+	* src/main/resources/datacage-sql/org-h2-driver.properties,
+	  src/main/resources/datacage-sql/org-postgresql-driver.properties:
+	  Added statement to delete artifact by uuid.
+
 2011-08-02  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Tue Aug 02 11:20:18 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Tue Aug 02 11:38:20 2011 +0000
@@ -77,6 +77,8 @@
         "delete.outs.by.artifact.id";
     private String SQL_DELETE_FACETS_BY_ARTIFACT_ID =
         "delete.facets.by.artifacts.id";
+    private String SQL_DELETE_ARTIFACT_BY_GID =
+        "delete.artifact.by.gid";
 
     protected SQLExecutor sqlExecutor;
 
@@ -372,6 +374,8 @@
             sql.get(SQL_DELETE_OUTS_BY_ARTIFACT_ID);
         SQL_DELETE_FACETS_BY_ARTIFACT_ID =
             sql.get(SQL_DELETE_FACETS_BY_ARTIFACT_ID);
+        SQL_DELETE_ARTIFACT_BY_GID =
+            sql.get(SQL_DELETE_ARTIFACT_BY_GID);
     }
 
     protected static final int numFacets(List<Output> outs) {
@@ -993,5 +997,53 @@
             log.error("storing facets failed");
         }
     }
+
+    public void killedCollections(
+        final List<String> identifiers,
+        GlobalContext      context
+    ) {
+        log.debug("killedCollections");
+
+        SQLExecutor.Instance exec = sqlExecutor.new Instance() {
+            @Override
+            public boolean doIt() throws SQLException {
+                prepareStatement(SQL_DELETE_COLLECTION_BY_GID);
+                for (String identifier: identifiers) {
+                    stmnt.setString(1, identifier);
+                    stmnt.execute();
+                }
+                conn.commit();
+                return true;
+            }
+        };
+
+        if (!exec.runWrite()) {
+            log.error("killing collections failed");
+        }
+    }
+
+    public void killedArtifacts(
+        final List<String> identifiers,
+        GlobalContext      context
+    ) {
+        log.debug("killedArtifacts");
+
+        SQLExecutor.Instance exec = sqlExecutor.new Instance() {
+            @Override
+            public boolean doIt() throws SQLException {
+                prepareStatement(SQL_DELETE_ARTIFACT_BY_GID);
+                for (String identifier: identifiers) {
+                    stmnt.setString(1, identifier);
+                    stmnt.execute();
+                }
+                conn.commit();
+                return true;
+            }
+        };
+
+        if (!exec.runWrite()) {
+            log.error("killing artifacts failed");
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java	Tue Aug 02 11:20:18 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java	Tue Aug 02 11:38:20 2011 +0000
@@ -171,12 +171,20 @@
 
     @Override
     public void killedCollections(List<String> identifiers, Backend backend) {
-        // TODO: Implement me!
+        log.debug("killedCollections");
+        Datacage l = getDatacage();
+        if (l != null) {
+            l.killedCollections(identifiers, context);
+        }
     }
 
     @Override
     public void killedArtifacts(List<String> identifiers, Backend backend) {
-        // TODO: Implement me!
+        log.debug("killedArtifacts");
+        Datacage l = getDatacage();
+        if (l != null) {
+            l.killedArtifacts(identifiers, context);
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties	Tue Aug 02 11:20:18 2011 +0000
+++ b/flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties	Tue Aug 02 11:38:20 2011 +0000
@@ -25,3 +25,5 @@
 delete.artifact.data.by.artifact.id = DELETE FROM artifact_data WHERE artifact_id = ?
 delete.outs.by.artifact.id = DELETE FROM outs WHERE artifact_id = ?
 delete.facets.by.artifact.id = DELETE FROM facets WHERE out_id IN (SELECT id FROM outs WHERE artifact_id = ?)
+
+delete.artifact.by.gid = DELETE FROM artifacts WHERE gid = ?
--- a/flys-artifacts/src/main/resources/datacage-sql/org-postgresql-driver.properties	Tue Aug 02 11:20:18 2011 +0000
+++ b/flys-artifacts/src/main/resources/datacage-sql/org-postgresql-driver.properties	Tue Aug 02 11:38:20 2011 +0000
@@ -25,3 +25,5 @@
 delete.artifact.data.by.artifact.id = DELETE FROM artifact_data WHERE artifact_id = ?
 delete.outs.by.artifact.id = DELETE FROM outs WHERE artifact_id = ?
 delete.facets.by.artifact.id = DELETE FROM facets WHERE out_id IN (SELECT id FROM outs WHERE artifact_id = ?)
+
+delete.artifact.by.gid = DELETE FROM artifacts WHERE gid = ?::uuid

http://dive4elements.wald.intevation.org