# HG changeset patch # User Sascha L. Teichmann # Date 1299669261 0 # Node ID face2302387cbe16546e48f7117b16953cd87577 # Parent 6370369412e9cd5e9a484f1bdce27758ddb5e801 Insert collection attribute into database, too. Fixed broken SQL schema. artifacts/trunk@1437 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6370369412e9 -r face2302387c ChangeLog --- a/ChangeLog Wed Mar 09 11:03:25 2011 +0000 +++ b/ChangeLog Wed Mar 09 11:14:21 2011 +0000 @@ -1,3 +1,15 @@ +2011-03-08 Sascha L. Teichmann + + * artifact-database/doc/schema-pg.sql, artifact-database/doc/schema-h2.sql: + Fixed broken schemas. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: + Insert collection attribute into database, too. + + * artifact-database/src/main/resources/sql/org-h2-driver.properties, + artifact-database/src/main/resources/sql/org-postgresql-driver.properties: + Adjusted SQL statements to insert attribute into collection table. + 2011-03-09 Ingo Weinzierl * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: diff -r 6370369412e9 -r face2302387c artifact-database/doc/schema-h2.sql --- a/artifact-database/doc/schema-h2.sql Wed Mar 09 11:03:25 2011 +0000 +++ b/artifact-database/doc/schema-h2.sql Wed Mar 09 11:14:21 2011 +0000 @@ -37,6 +37,7 @@ creation TIMESTAMP NOT NULL, last_access TIMESTAMP NOT NULL, ttl BIGINT, -- NULL means eternal + attribute BINARY ); CREATE SEQUENCE COLLECTION_ITEMS_ID_SEQ; diff -r 6370369412e9 -r face2302387c artifact-database/doc/schema-pg.sql --- a/artifact-database/doc/schema-pg.sql Wed Mar 09 11:03:25 2011 +0000 +++ b/artifact-database/doc/schema-pg.sql Wed Mar 09 11:14:21 2011 +0000 @@ -24,7 +24,7 @@ id int PRIMARY KEY NOT NULL, gid uuid NOT NULL UNIQUE, name VARCHAR(256) NOT NULL UNIQUE, - role BINARY + role bytea ); CREATE SEQUENCE COLLECTIONS_ID_SEQ; @@ -37,6 +37,7 @@ creation timestamp NOT NULL, last_access timestamp NOT NULL, ttl bigint, -- NULL means eternal + attribute bytea ); CREATE SEQUENCE COLLECTION_ITEMS_ID_SEQ; @@ -45,7 +46,7 @@ id int PRIMARY KEY NOT NULL, collection_id int NOT NULL REFERENCES collections(id), artifact_id int NOT NULL REFERENCES artifacts(id), - attribute BINARY, + attribute bytea, UNIQUE (collection_id, artifact_id) ); diff -r 6370369412e9 -r face2302387c artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Wed Mar 09 11:03:25 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Wed Mar 09 11:14:21 2011 +0000 @@ -937,7 +937,7 @@ final String ownerIdentifier, final String name, final ArtifactCollectionFactory factory, - final Document data, + final Document attribute, final Object context ) { if (name == null) { @@ -997,6 +997,15 @@ stmnt.setLong(5, ttl); } + byte [] data = XMLUtils.toByteArray(attribute); + + if (data == null) { + stmnt.setNull(6, Types.BINARY); + } + else { + stmnt.setBytes(6, data); + } + stmnt.execute(); conn.commit(); @@ -1019,7 +1028,7 @@ } collection[0] = factory.createCollection( - identifier, name, creationTime, data, context); + identifier, name, creationTime, attribute, context); return true; } diff -r 6370369412e9 -r face2302387c artifact-database/src/main/resources/sql/org-h2-driver.properties --- a/artifact-database/src/main/resources/sql/org-h2-driver.properties Wed Mar 09 11:03:25 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties Wed Mar 09 11:14:21 2011 +0000 @@ -105,8 +105,9 @@ (SELECT id FROM collections WHERE owner_id = ?) collections.insert= \ - INSERT INTO collections (id, gid, name, owner_id, creation, last_access, ttl) \ - VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?) + INSERT INTO collections \ + (id, gid, name, owner_id, creation, last_access, ttl, attribute) \ + VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?, ?) collection.creation.time=SELECT creation from collections WHERE id = ? diff -r 6370369412e9 -r face2302387c artifact-database/src/main/resources/sql/org-postgresql-driver.properties --- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Wed Mar 09 11:03:25 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Wed Mar 09 11:14:21 2011 +0000 @@ -104,8 +104,9 @@ (SELECT id FROM collections WHERE owner_id = ?) collections.insert= \ - INSERT INTO collections (id, gid, name, owner_id, creation, last_access, ttl) \ - VALUES (?, ?::uuid, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?) + INSERT INTO collections \ + (id, gid, name, owner_id, creation, last_access, ttl, attribute) \ + VALUES (?, ?::uuid, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?, ?) collection.creation.time=SELECT creation from collections WHERE id = ?