Mercurial > dive4elements > framework
changeset 281:942a54670a72
Made the TTL of a Collection retrievable via getter method.
artifacts/trunk@2174 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 21 Jun 2011 10:57:03 +0000 |
parents | 7fbe674d758a |
children | d15f09d5b89d |
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, 52 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Jun 17 07:40:20 2011 +0000 +++ b/ChangeLog Tue Jun 21 10:57:03 2011 +0000 @@ -1,3 +1,22 @@ +2011-06-21 Ingo Weinzierl <ingo@intevation.de> + + * artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java: + The ArtifactCollection now knows its time-to-live. This values is + retrievable via getTTL(). + + * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java, + artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java: + Creating an ArtifactCollection requires the time-to-live of it. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: + Create new ArtifactCollections with their time-to-live. + + * artifact-database/src/main/resources/sql/org-h2-driver.properties, + artifact-database/src/main/resources/sql/org-postgresql-driver.properties: + Adapted SQL statements that retrieve collections. The TTL of the + collection is fetched from database as well. + 2011-06-17 Ingo Weinzierl <ingo@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Fri Jun 17 07:40:20 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Tue Jun 21 10:57:03 2011 +0000 @@ -1036,7 +1036,7 @@ } collection[0] = factory.createCollection( - identifier, name, creationTime, attribute, context); + identifier, name, creationTime, ttl, attribute, context); return true; } @@ -1078,12 +1078,14 @@ new Date(result.getTimestamp(5).getTime()); Document attr = XMLUtils.fromByteArray(result.getBytes(6), true); + long ttl = result.getLong(7); ArtifactCollection collection = collectionFactory.createCollection( collectionId, collectionName, creationTime, + ttl, attr, context); @@ -1140,12 +1142,14 @@ Date creationTime = new Date(result.getTimestamp(3).getTime()); String userIdentifier = result.getString(4); + long ttl = result.getLong(5); ArtifactCollection collection = collectionFactory.createCollection( collectionIdentifier, collectionName, creationTime, + ttl, data, context);
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java Fri Jun 17 07:40:20 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java Tue Jun 21 10:57:03 2011 +0000 @@ -75,6 +75,8 @@ /** The creation time of this collection.*/ protected Date creationTime; + protected long ttl; + /** * Default constructor. @@ -96,6 +98,7 @@ String identifier, String name, Date creationTime, + long ttl, ArtifactCollectionFactory factory, Object context, Document data) @@ -108,6 +111,7 @@ setIdentifier(identifier); setName(name); setCreationTime(creationTime); + setTTL(ttl); setAttribute(data); } @@ -192,6 +196,16 @@ } + public long getTTL() { + return ttl; + } + + + public void setTTL(long ttl) { + this.ttl = ttl; + } + + /** * Returns the attribute of the collection. *
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java Fri Jun 17 07:40:20 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java Tue Jun 21 10:57:03 2011 +0000 @@ -126,6 +126,7 @@ String identifier, String name, Date creationTime, + long ttl, Document data, Object context ) { @@ -133,7 +134,7 @@ ArtifactCollection collection = (ArtifactCollection) clazz.newInstance(); - collection.setup(identifier, name, creationTime, this, context, data); + collection.setup(identifier, name, creationTime, ttl, this, context, data); return collection; }
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties Fri Jun 17 07:40:20 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties Tue Jun 21 10:57:03 2011 +0000 @@ -138,16 +138,16 @@ collection.creation.time=SELECT creation from collections WHERE id = ? collections.select.user= \ - SELECT c.gid, c.name, c.creation, u.gid FROM \ + SELECT c.gid, c.name, c.creation, u.gid, c.ttl FROM \ collections c LEFT OUTER 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 \ + SELECT c.gid, c.name, c.creation, u.gid, c.ttl FROM \ collections c LEFT OUTER JOIN users u ON c.owner_id = u.id collections.select.by.gid= \ - SELECT id, name, owner_id, creation, last_access, attribute \ + SELECT id, name, owner_id, creation, last_access, attribute, ttl \ FROM collections WHERE gid = ? users.collections=SELECT collection_id, gid, name FROM collections WHERE owner_id = ?
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Fri Jun 17 07:40:20 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Tue Jun 21 10:57:03 2011 +0000 @@ -129,16 +129,16 @@ collection.creation.time=SELECT creation from collections WHERE id = ? collections.select.user= \ - SELECT c.gid, c.name, c.creation, u.gid FROM \ + SELECT c.gid, c.name, c.creation, u.gid, c.ttl FROM \ collections c LEFT OUTER 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 \ + SELECT c.gid, c.name, c.creation, u.gid, c.ttl FROM \ collections c LEFT OUTER JOIN users u ON c.owner_id = u.id collections.select.by.gid= \ - SELECT id, name, owner_id, creation, last_access, attribute \ + SELECT id, name, owner_id, creation, last_access, attribute, ttl \ FROM collections WHERE gid = ?::uuid users.collections=SELECT collection_id, gid, name FROM collections WHERE owner_id = ?
--- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java Fri Jun 17 07:40:20 2011 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java Tue Jun 21 10:57:03 2011 +0000 @@ -39,6 +39,10 @@ void setCreationTime(Date creationTime); + long getTTL(); + + void setTTL(long ttl); + Document getAttribute(); void setAttribute(Document attribute); @@ -68,6 +72,7 @@ String identifier, String name, Date creationTime, + long ttl, ArtifactCollectionFactory factory, Object context, Document data);
--- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java Fri Jun 17 07:40:20 2011 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollectionFactory.java Tue Jun 21 10:57:03 2011 +0000 @@ -39,6 +39,7 @@ String identifier, String name, Date creationTime, + long ttl, Document data, Object context);