Mercurial > dive4elements > framework
changeset 170:ac0f8bd97277
Fix parameter propagation of creation time ond collection names.
artifacts/trunk@1395 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 04 Mar 2011 10:51:10 +0000 |
parents | 2f575d594fdb |
children | 401dd251fbf4 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java artifact-database/src/main/resources/sql/org-h2-driver.properties artifact-database/src/main/resources/sql/org-postgresql-driver.properties artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java |
diffstat | 8 files changed, 66 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Mar 04 09:56:35 2011 +0000 +++ b/ChangeLog Fri Mar 04 10:51:10 2011 +0000 @@ -1,3 +1,19 @@ +2011-03-04 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * artifact-database/src/main/resources/sql/org-h2-driver.properties, + artifact-database/src/main/resources/sql/org-postgresql-driver.properties: + Added new statement to extract the creation time for a given collection. + XXX: listing of collection does not. Need to look at that. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java, + artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java + artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java: + Repaired parameter propagation of creation times and collection names. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: + Adjusted the backend to propagate the creation time and the collection names. + 2011-03-04 Ingo Weinzierl <ingo@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Fri Mar 04 09:56:35 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Fri Mar 04 10:51:10 2011 +0000 @@ -22,9 +22,11 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.sql.Types; import java.util.ArrayList; +import java.util.Date; import javax.sql.DataSource; @@ -147,6 +149,9 @@ public static final String SQL_COLLECTIONS_SELECT_ALL = SQL.get("collections.select.all"); + public static final String SQL_COLLECTIONS_CREATION_TIME = + SQL.get("collection.creation.time"); + /** The singleton.*/ protected static Backend instance; @@ -1175,8 +1180,26 @@ stmnt.execute(); conn.commit(); + stmnt.close(); stmnt = null; + + // fetch creation time from database + // done this way to use the time system + // of the database. + + stmnt = conn.prepareStatement(SQL_COLLECTIONS_CREATION_TIME); + stmnt.setInt(1, id); + + result = stmnt.executeQuery(); + + Date creationTime = null; + + if (result.next()) { + Timestamp timestamp = result.getTimestamp(1); + creationTime = new Date(timestamp.getTime()); + } + return factory.createCollection( - identifier, name, data, context); + identifier, name, creationTime, data, context); } catch (SQLException sqle) { conn.rollback(); @@ -1239,13 +1262,15 @@ while (result.next()) { String collectionIdentifier = result.getString(1); String collectionName = result.getString(2); - long creationTime = result.getLong(3); + Date creationTime = + new Date(result.getTimestamp(3).getTime()); String userIdentifier = result.getString(4); ArtifactCollection collection = collectionFactory.createCollection( collectionIdentifier, collectionName, + creationTime, data, context);
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java Fri Mar 04 09:56:35 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java Fri Mar 04 10:51:10 2011 +0000 @@ -86,6 +86,8 @@ */ public void setup( String identifier, + String name, + Date creationTime, ArtifactCollectionFactory factory, Object context, Document data) @@ -96,6 +98,8 @@ attributes = new HashMap<String, Document>(); setIdentifier(identifier); + setName(name); + setCreationTime(creationTime); }
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java Fri Mar 04 09:56:35 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java Fri Mar 04 10:51:10 2011 +0000 @@ -15,6 +15,8 @@ import de.intevation.artifacts.ArtifactCollection; import de.intevation.artifacts.ArtifactCollectionFactory; +import java.util.Date; + /** * The default implementation of a ArtifactCollectionFactory. @@ -121,6 +123,7 @@ public ArtifactCollection createCollection( String identifier, String name, + Date creationTime, Document data, Object context ) { @@ -128,7 +131,7 @@ ArtifactCollection collection = (ArtifactCollection) clazz.newInstance(); - collection.setup(identifier, this, context, data); + collection.setup(identifier, name, creationTime, this, context, data); return collection; }
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties Fri Mar 04 09:56:35 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties Fri Mar 04 10:51:10 2011 +0000 @@ -49,14 +49,16 @@ INSERT INTO collections (id, gid, name, owner_id, creation, last_access, ttl) \ VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?) +collection.creation.time=SELECT creation from collections WHERE id = ? + collections.select.user= \ SELECT c.gid, c.name, c.creation, u.gid FROM \ - collections c OUTER LEFT JOIN user u ON c.owner_id = u.id \ + collections c OUTER LEFT JOIN users u ON c.owner_id = u.id \ WHERE u.gid = ? collections.select.all= \ SELECT c.gid, c.name, c.creation, u.gid FROM \ - collections c OUTER LEFT JOIN user u ON c.owner_id = u.id + collections c OUTER LEFT JOIN users u ON c.owner_id = u.id users.collections=SELECT collection_id, gid, name FROM collections WHERE owner_id = ? users.collection.ids=SELECT collection_id FROM collections WHERE owner_id = ?
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Fri Mar 04 09:56:35 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Fri Mar 04 10:51:10 2011 +0000 @@ -49,14 +49,16 @@ INSERT INTO collections (id, gid, name, owner_id, creation, last_access, ttl) \ VALUES (?, ?::uuid, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?) +collection.creation.time=SELECT creation from collections WHERE id = ? + collections.select.user= \ SELECT c.gid, c.name, c.creation, u.gid FROM \ - collections c OUTER LEFT JOIN user u ON c.owner_id = u.id \ + collections c OUTER LEFT JOIN users u ON c.owner_id = u.id \ WHERE u.gid = ?::uuid collections.select.all= \ SELECT c.gid, c.name, c.creation, u.gid FROM \ - collections c OUTER LEFT JOIN user u ON c.owner_id = u.id + collections c OUTER LEFT JOIN users u ON c.owner_id = u.id users.collections=SELECT collection_id, gid, name FROM collections WHERE owner_id = ? users.collection.ids=SELECT collection_id FROM collections WHERE owner_id = ?
--- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java Fri Mar 04 09:56:35 2011 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java Fri Mar 04 10:51:10 2011 +0000 @@ -62,6 +62,8 @@ */ void setup( String identifier, + String name, + Date creationTime, ArtifactCollectionFactory factory, Object context, Document data);
--- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java Fri Mar 04 09:56:35 2011 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java Fri Mar 04 10:51:10 2011 +0000 @@ -7,9 +7,12 @@ */ package de.intevation.artifacts; +import java.util.Date; + import org.w3c.dom.Document; import org.w3c.dom.Node; + public interface ArtifactCollectionFactory { /** @@ -34,7 +37,8 @@ */ ArtifactCollection createCollection( String identifier, - String name, + String name, + Date creationTime, Document data, Object context);