Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/h2/CollectionAccessUpdateTrigger.java @ 414:c22f3a7640d7
Add ChangeLog entry for last commit
artifacts/trunk@5261 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 24 Aug 2012 14:06:06 +0000 |
parents | f33401ea2a6c |
children |
rev | line source |
---|---|
229
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase.h2; |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import org.h2.api.Trigger; |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.sql.Connection; |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.sql.SQLException; |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.sql.PreparedStatement; |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
305
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
9 import de.intevation.artifactdatabase.DBConfig; |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
10 |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
11 import de.intevation.artifactdatabase.db.SQL; |
229
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.Logger; |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 public class CollectionAccessUpdateTrigger |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 implements Trigger |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 { |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 private static Logger logger = |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 Logger.getLogger(CollectionAccessUpdateTrigger.class); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
305
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
21 public String COLLECTIONS_TOUCH_TRIGGER_FUNCTION; |
229
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 public void init( |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 Connection conn, |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 String schemaName, |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 String triggerName, |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 String tableName, |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 boolean before, |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 int type |
233
16cd059945e5
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
229
diff
changeset
|
30 ) |
229
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 throws SQLException { |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 logger.debug("CollectionAccessUpdateTrigger.init"); |
305
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
33 setupSQL(DBConfig.getInstance().getSQL()); |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
34 } |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
35 |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
36 protected void setupSQL(SQL sql) { |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
37 COLLECTIONS_TOUCH_TRIGGER_FUNCTION = |
f33401ea2a6c
Artifact database: Refactorized the usage of dialect independent SQL to be reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
233
diff
changeset
|
38 sql.get("collections.touch.trigger.function"); |
229
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 public void fire( |
233
16cd059945e5
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
229
diff
changeset
|
42 Connection conn, |
229
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 Object [] oldRow, |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 Object [] newRow |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 ) |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 throws SQLException { |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 logger.debug("CollectionAccessUpdateTrigger.fire"); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 PreparedStatement stmnt = conn.prepareStatement( |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 COLLECTIONS_TOUCH_TRIGGER_FUNCTION); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 stmnt.setObject(1, newRow[0]); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 stmnt.execute(); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 stmnt.close(); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 public void close() throws SQLException { |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 logger.debug("CollectionAccessUpdateTrigger.close"); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 public void remove() throws SQLException { |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 logger.debug("CollectionAccessUpdateTrigger.remove"); |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
328ef982d768
When an artifact is touched the collections which contain the artifact are touched, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |