# HG changeset patch # User Sascha L. Teichmann # Date 1312293934 0 # Node ID 824051dff0180deb58b69642351d2e4573debdc2 # Parent 0ca9b1073ccf3a133347a7f22e065f019f20f13b When loading all artifacts fetch the name of the collections, too. artifacts/trunk@2453 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0ca9b1073ccf -r 824051dff018 ChangeLog --- a/ChangeLog Tue Aug 02 13:10:56 2011 +0000 +++ b/ChangeLog Tue Aug 02 14:05:34 2011 +0000 @@ -1,3 +1,16 @@ +2011-08-02 Sascha L. Teichmann + + * artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java: + Change the ArtifactLoadedCallback interface to take the name of the + collection, too. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: + Fetches the collection name, too. + + * artifact-database/src/main/resources/sql/org-h2-driver.properties, + artifact-database/src/main/resources/sql/org-postgresql-driver.properties: + Adjusted SQL statements. + 2011-08-02 Sascha L. Teichmann * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUser.java: diff -r 0ca9b1073ccf -r 824051dff018 artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Tue Aug 02 13:10:56 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Tue Aug 02 14:05:34 2011 +0000 @@ -1760,16 +1760,19 @@ prepareStatement(SQL_ALL_ARTIFACTS); result = stmnt.executeQuery(); while (result.next()) { - String userId = result.getString(1); - String collectionId = result.getString(2); - String artifactId = result.getString(3); - String factoryName = result.getString(4); + String userId = result.getString(1); + String collectionId = result.getString(2); + String artifactId = result.getString(3); + String collectionName = result.getString(4); + String factoryName = result.getString(5); Artifact artifact = alreadyLoaded.get(artifactId); if (artifact != null) { alc.artifactLoaded( - userId, collectionId, artifactId, artifact); + userId, + collectionId, collectionName, + artifactId, artifact); continue; } @@ -1781,13 +1784,15 @@ continue; } - byte [] bytes = result.getBytes(5); + byte [] bytes = result.getBytes(6); artifact = factory.getSerializer().fromBytes(bytes); if (artifact != null) { alc.artifactLoaded( - userId, collectionId, artifactId, artifact); + userId, + collectionId, collectionName, + artifactId, artifact); } alreadyLoaded.put(artifactId, artifact); diff -r 0ca9b1073ccf -r 824051dff018 artifact-database/src/main/resources/sql/org-h2-driver.properties --- a/artifact-database/src/main/resources/sql/org-h2-driver.properties Tue Aug 02 13:10:56 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties Tue Aug 02 14:05:34 2011 +0000 @@ -183,7 +183,9 @@ UPDATE collections SET attribute = ? WHERE gid = ? all.artifacts = \ - SELECT u.gid AS u_gid, c.gid AS c_gid, a.gid AS a_gid, a.factory AS factory, a.data AS data FROM \ + SELECT u.gid AS u_gid, c.gid AS c_gid, c.name as name, \ + a.gid AS a_gid, a.factory AS factory, a.data AS data \ + FROM \ users u INNER JOIN collections c ON u.id = c.owner_id \ INNER JOIN collection_items ci ON c.id = ci.collection_id \ INNER JOIN artifacts a ON a.id = ci.artifact_id \ diff -r 0ca9b1073ccf -r 824051dff018 artifact-database/src/main/resources/sql/org-postgresql-driver.properties --- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Tue Aug 02 13:10:56 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Tue Aug 02 14:05:34 2011 +0000 @@ -172,7 +172,9 @@ UPDATE collections SET attribute = ? WHERE gid = ?::uuid all.artifacts = \ - SELECT u.gid AS u_gid, c.gid AS c_gid, a.gid AS a_gid, a.factory AS factory, a.data AS data FROM \ + SELECT u.gid AS u_gid, c.gid AS c_gid, c.name as name, \ + a.gid AS a_gid, a.factory AS factory, a.data AS data \ + FROM \ users u INNER JOIN collections c ON u.id = c.owner_id \ INNER JOIN collection_items ci ON c.id = ci.collection_id \ INNER JOIN artifacts a ON a.id = ci.artifact_id \ diff -r 0ca9b1073ccf -r 824051dff018 artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java --- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java Tue Aug 02 13:10:56 2011 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java Tue Aug 02 14:05:34 2011 +0000 @@ -277,6 +277,7 @@ void artifactLoaded( String userId, String collectionId, + String collectionName, String artifactId, Artifact artifact); };