# HG changeset patch # User Sascha L. Teichmann # Date 1312285100 0 # Node ID 1917f32701dce3c27b7383ac11b1ac5247ad0405 # Parent 52949da92f7a83ec1f48e44c5aac356e63e7075f Forwarded kill collections and artifacts events to datacage. flys-artifacts/trunk@2447 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 52949da92f7a -r 1917f32701dc flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java: diff -r 52949da92f7a -r 1917f32701dc flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.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 outs) { @@ -993,5 +997,53 @@ log.error("storing facets failed"); } } + + public void killedCollections( + final List 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 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 : diff -r 52949da92f7a -r 1917f32701dc flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java --- 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 identifiers, Backend backend) { - // TODO: Implement me! + log.debug("killedCollections"); + Datacage l = getDatacage(); + if (l != null) { + l.killedCollections(identifiers, context); + } } @Override public void killedArtifacts(List 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 : diff -r 52949da92f7a -r 1917f32701dc flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties --- 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 = ? diff -r 52949da92f7a -r 1917f32701dc flys-artifacts/src/main/resources/datacage-sql/org-postgresql-driver.properties --- 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