changeset 996:f61fe8b561d2

Datacage: delete artifacts at initial scan, too. Fixed problem with writing content of state data. flys-artifacts/trunk@2432 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 31 Jul 2011 19:47:41 +0000
parents e0df86bc6d31
children 4c82609824c8
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties flys-artifacts/src/main/resources/datacage-sql/org-postgresql-driver.properties
diffstat 4 files changed, 38 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sun Jul 31 19:07:02 2011 +0000
+++ b/flys-artifacts/ChangeLog	Sun Jul 31 19:47:41 2011 +0000
@@ -1,3 +1,16 @@
+2011-07-31  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java:
+	  Delete the artifacts at before initial scan, too. They are independent
+	  from users. Fixed problem when writing state data content.
+
+	* src/main/resources/datacage-sql/org-h2-driver.properties: Added
+	  statement to delete the artifacts at initial scan, too.
+
+	* src/main/resources/datacage-sql/org-postgresql-driver.properties:
+	  New. PostgreSQL version of the statements. The database scheme
+	  is the same as H2. Very useful for debugging.
+
 2011-07-31  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Sun Jul 31 19:07:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Sun Jul 31 19:47:41 2011 +0000
@@ -40,6 +40,7 @@
         "global.artifact.database";
 
     private String SQL_DELETE_ALL_USERS      = "delete.all.users";
+    private String SQL_DELETE_ALL_ARTIFACTS  = "delete.all.artifacts";
     private String SQL_USER_ID_NEXTVAL       = "user.id.nextval";
     private String SQL_USER_BY_GID           = "user.by.gid";
     private String SQL_INSERT_USER           = "insert.user";
@@ -317,7 +318,7 @@
                         if (type == null) type = "String";
                         stmnt.setString(3, type);
                         stmnt.setString(4, sd.getName());
-                        setString(stmnt, 5, sd);
+                        setString(stmnt, 5, sd.getValue());
                         stmnt.execute();
                     }
 
@@ -466,6 +467,7 @@
 
     protected void setupSQL(SQL sql) {
         SQL_DELETE_ALL_USERS      = sql.get(SQL_DELETE_ALL_USERS);
+        SQL_DELETE_ALL_ARTIFACTS  = sql.get(SQL_DELETE_ALL_ARTIFACTS);
         SQL_USER_ID_NEXTVAL       = sql.get(SQL_USER_ID_NEXTVAL);
         SQL_USER_BY_GID           = sql.get(SQL_USER_BY_GID);
         SQL_INSERT_USER           = sql.get(SQL_INSERT_USER);
@@ -550,13 +552,11 @@
         boolean success = sqlExecutor.new Instance() {
             @Override
             public boolean doIt() throws SQLException {
-                log.debug("doIt");
                 prepareStatement(SQL_DELETE_ALL_USERS);
-                log.debug("prepareStatement");
                 stmnt.execute();
-                log.debug("execute");
+                prepareStatement(SQL_DELETE_ALL_ARTIFACTS);
+                stmnt.execute();
                 conn.commit();
-                log.debug("commit");
                 return true;
             }
         }.runWrite();
--- a/flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties	Sun Jul 31 19:07:02 2011 +0000
+++ b/flys-artifacts/src/main/resources/datacage-sql/org-h2-driver.properties	Sun Jul 31 19:47:41 2011 +0000
@@ -1,4 +1,5 @@
 delete.all.users = DELETE FROM users
+delete.all.artifacts = DELETE FROM artifacts
 user.id.nextval = SELECT NEXTVAL('USERS_ID_SEQ')
 user.by.gid = SELECT id FROM users WHERE gid = ?
 insert.user = INSERT INTO users (id, gid) VALUES (?, ?)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/resources/datacage-sql/org-postgresql-driver.properties	Sun Jul 31 19:47:41 2011 +0000
@@ -0,0 +1,19 @@
+delete.all.users = DELETE FROM users
+delete.all.artifacts = DELETE FROM artifacts
+user.id.nextval = SELECT NEXTVAL('USERS_ID_SEQ')
+user.by.gid = SELECT id FROM users WHERE gid = ?::uuid
+insert.user = INSERT INTO users (id, gid) VALUES (?, ?::uuid)
+collection.by.gid = SELECT id FROM collections WHERE gid = ?::uuid
+collection.id.nextval = SELECT NEXTVAL('COLLECTIONS_ID_SEQ')
+insert.collection = INSERT INTO collections (id, gid, user_id, name) VALUES (?, ?::uuid, ?, ?)
+artifact.by.gid = SELECT id FROM artifacts WHERE gid = ?::uuid
+collection.item.id.nextval = SELECT NEXTVAL('COLLECTION_ITEMS_ID_SEQ')
+insert.collection.item = INSERT INTO collection_items (id, collection_id, artifact_id) VALUES (?, ?, ?)
+artifact.id.nextval = SELECT NEXTVAL('ARTIFACTS_ID_SEQ')
+insert.artifact = INSERT INTO artifacts (id, gid, state) VALUES (?, ?::uuid, ?)
+artifact.data.id.nextval = SELECT NEXTVAL('ARTIFACT_DATA_ID_SEQ')
+insert.artifact.data = INSERT INTO artifact_data (id, artifact_id, kind, k, v) VALUES (?, ?, ?, ?, ?)
+out.id.nextval = SELECT NEXTVAL('OUTS_ID_SEQ')
+insert.out = INSERT INTO outs (id, artifact_id, name, description, out_type) VALUES (?, ?, ?, ?, ?)
+facet.id.nextval = SELECT NEXTVAL('FACETS_ID_SEQ')
+insert.facet = INSERT INTO facets (id, out_id, name, num, state, description) VALUES (?, ?, ?, ?, ?, ?)

http://dive4elements.wald.intevation.org