changeset 187:a85d889a1b0d

Fixed some backend specific stuff (sql statements, schema). artifacts/trunk@1417 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 07 Mar 2011 16:23:27 +0000
parents 15c7638511dc
children 946e2245a6c0
files ChangeLog artifact-database/doc/schema-h2.sql artifact-database/doc/schema-pg.sql artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/resources/sql/org-h2-driver.properties artifact-database/src/main/resources/sql/org-postgresql-driver.properties
diffstat 6 files changed, 36 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 07 15:13:36 2011 +0000
+++ b/ChangeLog	Mon Mar 07 16:23:27 2011 +0000
@@ -1,3 +1,16 @@
+2011-03-07  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/doc/schema-pg.sql,
+	  artifact-database/doc/schema-h2.sql: Renamed a SEQUENCE - schema
+	  definition and sql statements did not fit to each other.
+
+	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
+	  artifact-database/src/main/resources/sql/org-postgresql-driver.properties:
+	  Fixed wrong table names in sql statements.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
+	  Fixed SQL constants.
+
 2011-03-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifacts/src/main/java/de/intevation/artifacts/CollectionItem.java:
--- a/artifact-database/doc/schema-h2.sql	Mon Mar 07 15:13:36 2011 +0000
+++ b/artifact-database/doc/schema-h2.sql	Mon Mar 07 16:23:27 2011 +0000
@@ -39,7 +39,7 @@
     ttl         BIGINT, -- NULL means eternal
 );
 
-CREATE SEQUENCE COLLECTION_ITEMS_SEQ;
+CREATE SEQUENCE COLLECTION_ITEMS_ID_SEQ;
 
 CREATE TABLE collection_items (
     id            INT PRIMARY KEY NOT NULL,
--- a/artifact-database/doc/schema-pg.sql	Mon Mar 07 15:13:36 2011 +0000
+++ b/artifact-database/doc/schema-pg.sql	Mon Mar 07 16:23:27 2011 +0000
@@ -39,7 +39,7 @@
     ttl         bigint, -- NULL means eternal
 );
 
-CREATE SEQUENCE COLLECTION_ITEMS_SEQ;
+CREATE SEQUENCE COLLECTION_ITEMS_ID_SEQ;
 
 CREATE TABLE collection_items (
     id            int PRIMARY KEY NOT NULL,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Mon Mar 07 15:13:36 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Mon Mar 07 16:23:27 2011 +0000
@@ -147,7 +147,7 @@
         SQL.get("collection.creation.time");
 
     public static final String SQL_COLLECTIONS_ID_BY_GID =
-        SQL.get("collection.creation.time");
+        SQL.get("collections.id.by.gid");
 
     public static final String SQL_DELETE_COLLECTION_ITEMS =
         SQL.get("delete.collection.items");
@@ -159,7 +159,7 @@
         SQL.get("collection.check.artifact");
 
     public static final String SQL_COLLECTION_ITEMS_ID_NEXTVAL =
-        SQL.get("collection.check.artifact");
+        SQL.get("collection.items.id.nextval");
 
     public static final String SQL_COLLECTION_ITEMS_INSERT =
         SQL.get("collection.items.insert");
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Mon Mar 07 15:13:36 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Mon Mar 07 16:23:27 2011 +0000
@@ -38,31 +38,31 @@
 
 users.select.all=SELECT id, gid, name, role FROM users
 
-collection.check.artifact=SELECT id FROM collections_items \
+collection.check.artifact=SELECT id FROM collection_items \
     WHERE artifact_id = ? AND collection_id = ?
 
 # COLLECTION ITEMS
 collection.items.id.nextval=SELECT NEXTVAL('COLLECTION_ITEMS_ID_SEQ')
 
-collection.items.insert=INSERT INTO collections_items \
+collection.items.insert=INSERT INTO collection_items \
     (id, collection_id, artifact_id, attribute) \
     VALUES (?, ?, ?, ?)
 
 collection.item.get.attribute= \
-    SELECT ci.attribute FROM collections_items ci \
+    SELECT ci.attribute FROM collection_items ci \
         INNER JOIN collection c ON ci.collection_id = c.id \
         INNER JOIN attributes a ON ci.artifact_id = a.id \
         WHERE c.gid = ? AND a.gid = ?
 
 collection.item.set.attribute= \
-    UPDATE collections_items SET attribute = ? WHERE id IN ( \
-        SELECT ci.id FROM collections_items ci \
+    UPDATE collection_items SET attribute = ? WHERE id IN ( \
+        SELECT ci.id FROM collection_items ci \
             INNER JOIN collection c ON ci.collection_id = c.id \
             INNER JOIN attributes a ON ci.artifact_id = a.id \
             WHERE c.gid = ? AND a.gid = ?)
 
 collection.item.id.cid.aid= \
-    SELECT ci.id, c.collection_id, c.artifact_id FROM collections_items ci \
+    SELECT ci.id, c.collection_id, c.artifact_id FROM collection_items ci \
         INNER JOIN collection c ON ci.collection_id = c.id \
         INNER JOIN attributes a ON ci.artifact_id = a.id \
         WHERE c.gid = ? AND a.gid = ?
@@ -71,12 +71,12 @@
     UPDATE artifacts \
     SET last_access = DATEADD('MILLISECOND', -2, CURRENT_TIMESTAMP), ttl = 1 \
     WHERE id = ? AND \
-    NOT EXSITS (SELECT id FROM collections_items WHERE <> collection_id = ?)
+    NOT EXSITS (SELECT id FROM collection_items WHERE <> collection_id = ?)
 
-collection.item.delete=DELETE FROM collections_items WHERE id = ?
+collection.item.delete=DELETE FROM collection_items WHERE id = ?
 
 collection.items.list.gid= \
-    SELECT a.gid, ci.attribute FROM collections_items ci \
+    SELECT a.gid, ci.attribute FROM collection_items ci \
     INNER JOIN artifacts a ON ci.artifact_id = a.id \
     WHERE ci.id IN (SELECT id FROM collections WHERE gid = ?)
 
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Mon Mar 07 15:13:36 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Mon Mar 07 16:23:27 2011 +0000
@@ -38,31 +38,31 @@
 
 users.select.all=SELECT id, gid, name, role FROM users
 
-collection.check.artifact=SELECT id FROM collections_items \
+collection.check.artifact=SELECT id FROM collection_items \
     WHERE artifact_id = ? AND collection_id = ?
 
 # COLLECTION ITEMS
 collection.items.id.nextval=SELECT NEXTVAL('COLLECTION_ITEMS_ID_SEQ')
 
-collection.items.insert=INSERT INTO collections_items \
+collection.items.insert=INSERT INTO collection_items \
     (id, collection_id, artifact_id, attribute) \
     VALUES (?, ?, ?, ?)
 
 collection.item.get.attribute= \
-    SELECT ci.attribute FROM collections_items ci \
+    SELECT ci.attribute FROM collection_items ci \
         INNER JOIN collection c ON ci.collection_id = c.id \
         INNER JOIN attributes a ON ci.artifact_id = a.id \
         WHERE c.gid = ?::uuid AND a.gid = ?::uuid
 
 collection.item.set.attribute= \
-    UPDATE collections_items SET attribute = ? WHERE id IN ( \
-        SELECT ci.id FROM collections_items ci \
+    UPDATE collection_items SET attribute = ? WHERE id IN ( \
+        SELECT ci.id FROM collection_items ci \
             INNER JOIN collection c ON ci.collection_id = c.id \
             INNER JOIN attributes a ON ci.artifact_id = a.id \
             WHERE c.gid = ?::uuid AND a.gid = ?::uuid)
 
 collection.item.id.cid.aid= \
-    SELECT ci.id, c.collection_id, c.artifact_id FROM collections_items ci \
+    SELECT ci.id, c.collection_id, c.artifact_id FROM collection_items ci \
         INNER JOIN collection c ON ci.collection_id = c.id \
         INNER JOIN attributes a ON ci.artifact_id = a.id \
         WHERE c.gid = ?::uuid AND a.gid = ?::uuid
@@ -71,14 +71,14 @@
     UPDATE artifacts \
     SET last_access = CURRENT_TIMESTAMP - '2 microseconds'::interval, ttl = 1 \
     WHERE id = ? AND \
-    NOT EXSITS (SELECT id FROM collections_items WHERE <> collection_id = ?)
+    NOT EXSITS (SELECT id FROM collection_items WHERE <> collection_id = ?)
 
-collection.item.delete=DELETE FROM collections_items WHERE id = ?
+collection.item.delete=DELETE FROM collection_items WHERE id = ?
 
 collection.items.list.gid= \
-    SELECT a.gid, ci.attribute FROM collections_items ci \
+    SELECT a.gid, ci.attribute FROM collection_items ci \
     INNER JOIN artifacts a ON ci.artifact_id = a.id \
-    WHERE ci.id IN (SELECT id FROM collections WHERE gid = ?)
+    WHERE ci.id IN (SELECT id FROM collections WHERE gid = ?::uuid)
 
 # COLLECTIONS
 collections.touch.by.gid =\

http://dive4elements.wald.intevation.org