Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java @ 1020:a776afdf1ec5
Cosmetic: Replaced usage of legacy java.util.Stack with java.util.Deque.
flys-artifacts/trunk@2475 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 09 Aug 2011 10:23:04 +0000 |
parents | d419c9904825 |
children | ba88157c6aa3 |
rev | line source |
---|---|
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.datacage; |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
3 import java.util.Collection; |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
4 import java.util.List; |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
5 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
6 import java.sql.SQLException; |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
7 import java.sql.PreparedStatement; |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
8 import java.sql.Types; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
9 |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.GlobalContext; |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
11 import de.intevation.artifacts.ArtifactCollection; |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
12 import de.intevation.artifacts.User; |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
983
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
14 import de.intevation.artifactdatabase.db.SQL; |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
15 import de.intevation.artifactdatabase.db.SQLExecutor; |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
16 |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifactdatabase.LifetimeListener; |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
18 import de.intevation.artifactdatabase.Backend; |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
20 import de.intevation.artifactdatabase.data.StateData; |
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
21 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
22 import de.intevation.artifactdatabase.state.Output; |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
23 import de.intevation.artifactdatabase.state.Facet; |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
24 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
25 import de.intevation.artifacts.Artifact; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
26 import de.intevation.artifacts.ArtifactDatabase; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
27 import de.intevation.artifacts.ArtifactDatabaseException; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
28 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
29 import de.intevation.flys.artifacts.FLYSArtifact; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
30 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
31 import de.intevation.artifacts.common.utils.LRUCache; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
32 |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 import org.apache.log4j.Logger; |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 import org.w3c.dom.Document; |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public class Datacage |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
38 implements LifetimeListener |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 { |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 private static Logger log = Logger.getLogger(Datacage.class); |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
42 public static final String DATACAGE_KEY = |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
43 "global.datacage.instance"; |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
44 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
45 public static final String ARTEFACT_DATABASE_KEY = |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
46 "global.artifact.database"; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
47 |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
48 private String SQL_DELETE_ALL_USERS = "delete.all.users"; |
996
f61fe8b561d2
Datacage: delete artifacts at initial scan, too. Fixed problem with writing content of state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
995
diff
changeset
|
49 private String SQL_DELETE_ALL_ARTIFACTS = "delete.all.artifacts"; |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
50 private String SQL_USER_ID_NEXTVAL = "user.id.nextval"; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
51 private String SQL_USER_BY_GID = "user.by.gid"; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
52 private String SQL_INSERT_USER = "insert.user"; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
53 private String SQL_COLLECTION_BY_GID = "collection.by.gid"; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
54 private String SQL_COLLECTION_ID_NEXTVAL = "collection.id.nextval"; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
55 private String SQL_INSERT_COLLECTION = "insert.collection"; |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
56 private String SQL_ARTIFACT_BY_GID = "artifact.by.gid"; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
57 private String SQL_COLLECTION_ITEM_ID_NEXTVAL = |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
58 "collection.item.id.nextval"; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
59 private String SQL_INSERT_COLLECTION_ITEM = "insert.collection.item"; |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
60 private String SQL_ARTIFACT_ID_NEXTVAL = "artifact.id.nextval"; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
61 private String SQL_INSERT_ARTIFACT = "insert.artifact"; |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
62 private String SQL_ARTIFACT_DATA_ID_NEXTVAL = "artifact.data.id.nextval"; |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
63 private String SQL_INSERT_ARTIFACT_DATA = "insert.artifact.data"; |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
64 private String SQL_OUT_ID_NEXTVALUE = "out.id.nextval"; |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
65 private String SQL_INSERT_OUT = "insert.out"; |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
66 private String SQL_FACET_ID_NEXTVAL = "facet.id.nextval"; |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
67 private String SQL_INSERT_FACET = "insert.facet"; |
1003
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
68 private String SQL_UPDATE_COLLECTION_NAME = "update.collection.name"; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
69 private String SQL_DELETE_ARTIFACT_FROM_COLLECTION = |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
70 "delete.artifact.from.collection"; |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
71 private String SQL_DELETE_COLLECTION_BY_GID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
72 "delete.collection.by.gid"; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
73 private String SQL_DELETE_USER_BY_GID = "delete.user.by.gid"; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
74 private String SQL_DELETE_ARTIFACT_DATA_BY_ARTIFACT_ID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
75 "delete.artifact.data.by.artifact.id"; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
76 private String SQL_DELETE_OUTS_BY_ARTIFACT_ID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
77 "delete.outs.by.artifact.id"; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
78 private String SQL_DELETE_FACETS_BY_ARTIFACT_ID = |
1008
6268009e177d
Datacage: fixed wrong SQL references
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1007
diff
changeset
|
79 "delete.facets.by.artifact.id"; |
1006
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
80 private String SQL_DELETE_ARTIFACT_BY_GID = |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
81 "delete.artifact.by.gid"; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
82 |
983
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
83 protected SQLExecutor sqlExecutor; |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
84 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
85 public class InitialScan |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
86 implements ArtifactDatabase.ArtifactLoadedCallback |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
87 { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
88 protected LRUCache<String, Integer> users; |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
89 protected LRUCache<String, Integer> collections; |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
90 protected LRUCache<String, Integer> artifacts; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
91 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
92 protected GlobalContext context; |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
93 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
94 public InitialScan() { |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
95 users = new LRUCache<String, Integer>(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
96 collections = new LRUCache<String, Integer>(); |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
97 artifacts = new LRUCache<String, Integer>(); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
98 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
99 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
100 public InitialScan(GlobalContext context) { |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
101 this(); |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
102 this.context = context; |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
103 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
104 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
105 @Override |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
106 public void artifactLoaded( |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
107 String userId, |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
108 String collectionId, |
1009
fc5fca0c33b3
Datacage: Set the name of the collections at initial scan, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1008
diff
changeset
|
109 String collectionName, |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
110 String artifactId, |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
111 Artifact artifact |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
112 ) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
113 if (!(artifact instanceof FLYSArtifact)) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
114 log.warn("ignoring none FLYS artifacts"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
115 return; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
116 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
117 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
118 FLYSArtifact flysArtifact = (FLYSArtifact)artifact; |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
119 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
120 Integer uId = getUserId(userId); |
1009
fc5fca0c33b3
Datacage: Set the name of the collections at initial scan, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1008
diff
changeset
|
121 Integer cId = getCollectionId(collectionId, uId, collectionName); |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
122 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
123 storeArtifact(artifactId, cId, flysArtifact); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
124 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
125 |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
126 protected Integer getId( |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
127 LRUCache<String, Integer> cache, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
128 final String idString, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
129 final String selectById |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
130 ) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
131 Integer id = cache.get(idString); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
132 if (id != null) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
133 return id; |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
134 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
135 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
136 final Integer [] res = new Integer[1]; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
137 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
138 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
139 @Override |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
140 public boolean doIt() throws SQLException { |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
141 prepareStatement(selectById); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
142 stmnt.setString(1, idString); |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
143 result = stmnt.executeQuery(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
144 if (!result.next()) { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
145 return false; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
146 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
147 res[0] = result.getInt(1); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
148 return true; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
149 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
150 }; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
151 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
152 if (exec.runRead()) { |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
153 cache.put(idString, res[0]); |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
154 return res[0]; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
155 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
156 |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
157 return null; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
158 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
159 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
160 protected void storeArtifact( |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
161 final String artifactId, |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
162 Integer collectionId, |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
163 final FLYSArtifact artifact |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
164 ) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
165 Integer aId = getId(artifacts, artifactId, SQL_ARTIFACT_BY_GID); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
166 |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
167 if (aId != null) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
168 // We've already stored it. Just create the collection item. |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
169 storeCollectionItem(collectionId, aId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
170 return; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
171 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
172 // We need to write it to database |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
173 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
174 final Integer [] res = new Integer[1]; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
175 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
176 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
177 @Override |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
178 public boolean doIt() throws SQLException { |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
179 prepareStatement(SQL_ARTIFACT_ID_NEXTVAL); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
180 result = stmnt.executeQuery(); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
181 if (!result.next()) { |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
182 return false; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
183 } |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
184 res[0] = result.getInt(1); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
185 reset(); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
186 prepareStatement(SQL_INSERT_ARTIFACT); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
187 stmnt.setInt (1, res[0]); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
188 stmnt.setString(2, artifactId); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
189 stmnt.setString(3, artifact.getCurrentStateId()); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
190 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
191 conn.commit(); |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
192 return true; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
193 } |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
194 }; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
195 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
196 if (!exec.runWrite()) { |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
197 log.error("storing of artifact failed."); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
198 return; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
199 } |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
200 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
201 artifacts.put(artifactId, aId = res[0]); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
202 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
203 storeCollectionItem(collectionId, aId); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
204 |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
205 storeData(aId, artifact); |
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
206 |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
207 storeOuts(aId, artifact, context); |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
208 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
209 |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
210 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
211 protected void storeCollectionItem( |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
212 final Integer collectionId, |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
213 final Integer artifactId |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
214 ) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
215 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
216 @Override |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
217 public boolean doIt() throws SQLException { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
218 prepareStatement(SQL_COLLECTION_ITEM_ID_NEXTVAL); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
219 result = stmnt.executeQuery(); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
220 if (!result.next()) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
221 return false; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
222 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
223 int ciId = result.getInt(1); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
224 reset(); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
225 prepareStatement(SQL_INSERT_COLLECTION_ITEM); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
226 stmnt.setInt(1, ciId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
227 stmnt.setInt(2, collectionId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
228 stmnt.setInt(3, artifactId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
229 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
230 conn.commit(); |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
231 return true; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
232 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
233 }; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
234 |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
235 if (!exec.runWrite()) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
236 log.error("storing of collection item failed."); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
237 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
238 } |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
239 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
240 protected Integer getCollectionId( |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
241 final String collectionId, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
242 final Integer ownerId, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
243 final String collectionName |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
244 ) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
245 Integer c = getId(collections, collectionId, SQL_COLLECTION_BY_GID); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
246 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
247 if (c != null) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
248 return c; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
249 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
250 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
251 final Integer [] res = new Integer[1]; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
252 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
253 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
254 @Override |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
255 public boolean doIt() throws SQLException { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
256 prepareStatement(SQL_COLLECTION_ID_NEXTVAL); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
257 result = stmnt.executeQuery(); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
258 if (!result.next()) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
259 return false; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
260 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
261 res[0] = result.getInt(1); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
262 reset(); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
263 prepareStatement(SQL_INSERT_COLLECTION); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
264 stmnt.setInt (1, res[0]); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
265 stmnt.setString(2, collectionId); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
266 stmnt.setInt (3, ownerId); |
1009
fc5fca0c33b3
Datacage: Set the name of the collections at initial scan, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1008
diff
changeset
|
267 setString(stmnt, 4, collectionName); |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
268 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
269 conn.commit(); |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
270 return true; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
271 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
272 }; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
273 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
274 if (exec.runWrite()) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
275 collections.put(collectionId, res[0]); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
276 return res[0]; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
277 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
278 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
279 return null; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
280 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
281 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
282 protected Integer getUserId(final String userId) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
283 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
284 Integer u = getId(users, userId, SQL_USER_BY_GID); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
285 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
286 if (u != null) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
287 return u; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
288 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
289 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
290 final Integer [] res = new Integer[1]; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
291 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
292 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
293 @Override |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
294 public boolean doIt() throws SQLException { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
295 prepareStatement(SQL_USER_ID_NEXTVAL); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
296 result = stmnt.executeQuery(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
297 if (!result.next()) { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
298 return false; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
299 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
300 res[0] = result.getInt(1); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
301 reset(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
302 prepareStatement(SQL_INSERT_USER); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
303 stmnt.setInt (1, res[0]); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
304 stmnt.setString(2, userId); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
305 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
306 conn.commit(); |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
307 return true; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
308 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
309 }; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
310 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
311 if (exec.runWrite()) { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
312 users.put(userId, res[0]); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
313 return res[0]; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
314 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
315 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
316 return null; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
317 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
318 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
319 public boolean scan(ArtifactDatabase adb) { |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
320 log.debug("scan"); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
321 try { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
322 adb.loadAllArtifacts(this); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
323 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
324 catch (ArtifactDatabaseException ade) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
325 log.error(ade); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
326 return false; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
327 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
328 return true; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
329 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
330 } // class InitialScan |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
331 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
332 |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
333 public Datacage() { |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
334 } |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
336 @Override |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
337 public void setup(Document document) { |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
338 log.debug("setup"); |
983
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
339 DBConfig config = DBConfig.getInstance(); |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
340 setupSQL(config.getSQL()); |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
341 sqlExecutor = new SQLExecutor(config.getDBConnection()); |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
342 } |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
343 |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
344 protected void setupSQL(SQL sql) { |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
345 SQL_DELETE_ALL_USERS = sql.get(SQL_DELETE_ALL_USERS); |
996
f61fe8b561d2
Datacage: delete artifacts at initial scan, too. Fixed problem with writing content of state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
995
diff
changeset
|
346 SQL_DELETE_ALL_ARTIFACTS = sql.get(SQL_DELETE_ALL_ARTIFACTS); |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
347 SQL_USER_ID_NEXTVAL = sql.get(SQL_USER_ID_NEXTVAL); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
348 SQL_USER_BY_GID = sql.get(SQL_USER_BY_GID); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
349 SQL_INSERT_USER = sql.get(SQL_INSERT_USER); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
350 SQL_COLLECTION_BY_GID = sql.get(SQL_COLLECTION_BY_GID); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
351 SQL_COLLECTION_ID_NEXTVAL = sql.get(SQL_COLLECTION_ID_NEXTVAL); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
352 SQL_INSERT_COLLECTION = sql.get(SQL_INSERT_COLLECTION); |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
353 SQL_ARTIFACT_BY_GID = sql.get(SQL_ARTIFACT_BY_GID); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
354 SQL_COLLECTION_ITEM_ID_NEXTVAL = |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
355 sql.get(SQL_COLLECTION_ITEM_ID_NEXTVAL); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
356 SQL_INSERT_COLLECTION_ITEM = |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
357 sql.get(SQL_INSERT_COLLECTION_ITEM); |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
358 SQL_ARTIFACT_ID_NEXTVAL = sql.get(SQL_ARTIFACT_ID_NEXTVAL); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
359 SQL_INSERT_ARTIFACT = sql.get(SQL_INSERT_ARTIFACT); |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
360 SQL_ARTIFACT_DATA_ID_NEXTVAL = sql.get(SQL_ARTIFACT_DATA_ID_NEXTVAL); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
361 SQL_INSERT_ARTIFACT_DATA = sql.get(SQL_INSERT_ARTIFACT_DATA); |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
362 SQL_OUT_ID_NEXTVALUE = sql.get(SQL_OUT_ID_NEXTVALUE); |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
363 SQL_INSERT_OUT = sql.get(SQL_INSERT_OUT); |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
364 SQL_FACET_ID_NEXTVAL = sql.get(SQL_FACET_ID_NEXTVAL); |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
365 SQL_INSERT_FACET = sql.get(SQL_INSERT_FACET); |
1003
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
366 SQL_UPDATE_COLLECTION_NAME = sql.get(SQL_UPDATE_COLLECTION_NAME); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
367 SQL_DELETE_ARTIFACT_FROM_COLLECTION = |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
368 sql.get(SQL_DELETE_ARTIFACT_FROM_COLLECTION); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
369 SQL_DELETE_COLLECTION_BY_GID = sql.get(SQL_DELETE_COLLECTION_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
370 SQL_DELETE_USER_BY_GID = sql.get(SQL_DELETE_USER_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
371 SQL_DELETE_ARTIFACT_DATA_BY_ARTIFACT_ID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
372 sql.get(SQL_DELETE_ARTIFACT_DATA_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
373 SQL_DELETE_OUTS_BY_ARTIFACT_ID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
374 sql.get(SQL_DELETE_OUTS_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
375 SQL_DELETE_FACETS_BY_ARTIFACT_ID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
376 sql.get(SQL_DELETE_FACETS_BY_ARTIFACT_ID); |
1010
d419c9904825
Datacage: Forgot to fetch dialect dependent SQL statement for deleting artifacts by uuid.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1009
diff
changeset
|
377 SQL_DELETE_ARTIFACT_BY_GID = |
d419c9904825
Datacage: Forgot to fetch dialect dependent SQL statement for deleting artifacts by uuid.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1009
diff
changeset
|
378 sql.get(SQL_DELETE_ARTIFACT_BY_GID); |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
379 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
380 |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
381 protected static final int numFacets(List<Output> outs) { |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
382 int sum = 0; |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
383 for (Output out: outs) { |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
384 sum += out.getFacets().size(); |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
385 } |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
386 return sum; |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
387 } |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
388 |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
389 protected static final void setString( |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
390 PreparedStatement stmnt, |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
391 int index, |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
392 Object value |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
393 ) |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
394 throws SQLException |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
395 { |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
396 if (value == null) { |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
397 stmnt.setNull(index, Types.VARCHAR); |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
398 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
399 else { |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
400 stmnt.setString(index, value.toString()); |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
401 } |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
402 } |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
403 |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
404 @Override |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
405 public void systemUp(GlobalContext context) { |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
406 log.debug("systemUp entered"); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
407 initialScan(context); |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
408 context.put(DATACAGE_KEY, this); |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
409 log.debug("systemUp leaved"); |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
410 } |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
411 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
412 protected void initialScan(GlobalContext context) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
413 log.debug("initialScan"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
414 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
415 Object adbObject = context.get(ARTEFACT_DATABASE_KEY); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
416 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
417 if (!(adbObject instanceof ArtifactDatabase)) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
418 log.error("missing artefact database. Cannot scan"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
419 return; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
420 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
421 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
422 ArtifactDatabase adb = (ArtifactDatabase)adbObject; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
423 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
424 if (!cleanDatabase()) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
425 log.error("cleaning database failed"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
426 return; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
427 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
428 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
429 InitialScan is = new InitialScan(context); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
430 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
431 if (!is.scan(adb)) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
432 log.error("initial scan failed"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
433 return; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
434 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
435 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
436 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
437 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
438 protected boolean cleanDatabase() { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
439 |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
440 log.debug("cleanDatabase"); |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
441 |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
442 boolean success = sqlExecutor.new Instance() { |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
443 @Override |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
444 public boolean doIt() throws SQLException { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
445 prepareStatement(SQL_DELETE_ALL_USERS); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
446 stmnt.execute(); |
996
f61fe8b561d2
Datacage: delete artifacts at initial scan, too. Fixed problem with writing content of state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
995
diff
changeset
|
447 prepareStatement(SQL_DELETE_ALL_ARTIFACTS); |
f61fe8b561d2
Datacage: delete artifacts at initial scan, too. Fixed problem with writing content of state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
995
diff
changeset
|
448 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
449 conn.commit(); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
450 return true; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
451 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
452 }.runWrite(); |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
453 |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
454 log.debug("after runWrite(): " + success); |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
455 |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
456 return success; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
457 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
458 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
459 |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
460 @Override |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
461 public void systemDown(GlobalContext context) { |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
462 log.debug("systemDown"); |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
463 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
464 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
465 public void setup(GlobalContext globalContext) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
466 log.debug("setup"); |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
467 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
468 |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
469 public void createdArtifact( |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
470 Artifact artifact, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
471 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
472 GlobalContext context |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
473 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
474 log.debug("createdArtifact"); |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
475 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
476 if (!(artifact instanceof FLYSArtifact)) { |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
477 log.warn("need FLYSArtifact here"); |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
478 return; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
479 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
480 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
481 final FLYSArtifact flys = (FLYSArtifact)artifact; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
482 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
483 final int [] res = new int[1]; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
484 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
485 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
486 @Override |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
487 public boolean doIt() throws SQLException { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
488 prepareStatement(SQL_ARTIFACT_ID_NEXTVAL); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
489 result = stmnt.executeQuery(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
490 if (!result.next()) { |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
491 log.error("id generation for artifact failed"); |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
492 return false; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
493 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
494 res[0] = result.getInt(1); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
495 reset(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
496 prepareStatement(SQL_INSERT_ARTIFACT); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
497 stmnt.setInt (1, res[0]); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
498 stmnt.setString(2, flys.identifier()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
499 stmnt.setString(3, flys.getCurrentStateId()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
500 stmnt.execute(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
501 conn.commit(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
502 return true; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
503 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
504 }; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
505 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
506 if (!exec.runWrite()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
507 log.error("storing of artifact failed."); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
508 return; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
509 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
510 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
511 storeData(res[0], flys); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
512 storeOuts(res[0], flys, context); |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
513 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
514 |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
515 public void storedArtifact( |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
516 Artifact artifact, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
517 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
518 GlobalContext context |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
519 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
520 log.debug("storedArtifact"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
521 if (!(artifact instanceof FLYSArtifact)) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
522 log.warn("need FLYSArtifact here"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
523 return; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
524 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
525 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
526 final FLYSArtifact flys = (FLYSArtifact)artifact; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
527 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
528 final Integer [] res = new Integer[1]; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
529 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
530 // check first if artifact already exists |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
531 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
532 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
533 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
534 prepareStatement(SQL_ARTIFACT_BY_GID); |
1007
ed918497873b
Datacage: Fixed two NPEs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1006
diff
changeset
|
535 stmnt.setString(1, flys.identifier()); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
536 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
537 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
538 // new artifact |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
539 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
540 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
541 res[0] = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
542 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
543 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
544 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
545 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
546 if (!exec.runRead()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
547 log.error("querying artifact failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
548 return; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
549 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
550 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
551 if (res[0] == null) { // new artifact |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
552 createdArtifact(artifact, backend, context); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
553 return; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
554 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
555 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
556 // artifact already exists -> delete old data |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
557 exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
558 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
559 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
560 prepareStatement(SQL_DELETE_ARTIFACT_DATA_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
561 stmnt.setInt(1, res[0]); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
562 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
563 prepareStatement(SQL_DELETE_FACETS_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
564 stmnt.setInt(1, res[0]); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
565 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
566 prepareStatement(SQL_DELETE_OUTS_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
567 stmnt.setInt(1, res[0]); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
568 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
569 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
570 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
571 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
572 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
573 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
574 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
575 log.error("deleting old artifact data failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
576 return; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
577 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
578 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
579 // write new data |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
580 storeData(res[0], flys); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
581 storeOuts(res[0], flys, context); |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
582 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
583 |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
584 public void createdUser( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
585 final User user, |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
586 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
587 GlobalContext context |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
588 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
589 log.debug("createdUser"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
590 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
591 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
592 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
593 prepareStatement(SQL_USER_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
594 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
595 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
596 log.error("id generation for user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
597 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
598 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
599 int uId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
600 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
601 prepareStatement(SQL_INSERT_USER); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
602 stmnt.setInt(1, uId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
603 stmnt.setString(2, user.identifier()); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
604 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
605 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
606 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
607 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
608 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
609 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
610 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
611 log.error("create user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
612 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
613 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
614 |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
615 public void deletedUser( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
616 final String identifier, |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
617 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
618 GlobalContext context |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
619 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
620 log.debug("deletedUser"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
621 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
622 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
623 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
624 prepareStatement(SQL_DELETE_USER_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
625 stmnt.setString(1, identifier); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
626 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
627 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
628 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
629 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
630 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
631 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
632 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
633 log.error("delete user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
634 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
635 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
636 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
637 public void createdCollection( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
638 final ArtifactCollection collection, |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
639 Backend backend, |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
640 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
641 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
642 log.debug("createdCollection"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
643 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
644 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
645 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
646 String userId = collection.getUser().identifier(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
647 prepareStatement(SQL_USER_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
648 stmnt.setString(1, userId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
649 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
650 int uId; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
651 if (result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
652 uId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
653 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
654 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
655 else { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
656 // need to create user first |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
657 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
658 prepareStatement(SQL_USER_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
659 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
660 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
661 log.error("id generation for user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
662 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
663 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
664 uId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
665 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
666 prepareStatement(SQL_INSERT_USER); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
667 stmnt.setInt(1, uId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
668 stmnt.setString(2, userId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
669 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
670 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
671 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
672 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
673 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
674 prepareStatement(SQL_COLLECTION_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
675 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
676 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
677 log.error("id generation for collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
678 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
679 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
680 int cId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
681 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
682 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
683 String identifier = collection.identifier(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
684 String name = collection.getName(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
685 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
686 prepareStatement(SQL_INSERT_COLLECTION); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
687 stmnt.setInt(1, cId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
688 stmnt.setString(2, identifier); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
689 stmnt.setInt(3, uId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
690 setString(stmnt, 4, name); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
691 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
692 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
693 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
694 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
695 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
696 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
697 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
698 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
699 log.error("create collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
700 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
701 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
702 |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
703 public void deletedCollection( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
704 final String identifier, |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
705 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
706 GlobalContext context |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
707 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
708 log.debug("deletedCollection"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
709 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
710 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
711 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
712 prepareStatement(SQL_DELETE_COLLECTION_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
713 stmnt.setString(1, identifier); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
714 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
715 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
716 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
717 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
718 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
719 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
720 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
721 log.error("delete collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
722 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
723 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
724 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
725 public void changedCollectionAttribute( |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
726 String identifier, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
727 Document document, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
728 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
729 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
730 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
731 log.debug("changedCollectionAttribute"); |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
732 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
733 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
734 public void changedCollectionItemAttribute( |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
735 String collectionId, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
736 String artifactId, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
737 Document document, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
738 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
739 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
740 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
741 log.debug("changedCollectionItemAttribute"); |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
742 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
743 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
744 public void addedArtifactToCollection( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
745 final String artifactId, |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
746 final String collectionId, |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
747 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
748 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
749 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
750 log.debug("addedArtifactToCollection"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
751 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
752 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
753 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
754 prepareStatement(SQL_ARTIFACT_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
755 stmnt.setString(1, artifactId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
756 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
757 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
758 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
759 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
760 int aId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
761 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
762 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
763 prepareStatement(SQL_COLLECTION_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
764 stmnt.setString(1, collectionId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
765 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
766 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
767 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
768 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
769 int cId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
770 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
771 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
772 prepareStatement(SQL_COLLECTION_ITEM_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
773 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
774 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
775 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
776 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
777 int ciId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
778 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
779 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
780 prepareStatement(SQL_INSERT_COLLECTION_ITEM); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
781 stmnt.setInt(1, ciId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
782 stmnt.setInt(2, cId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
783 stmnt.setInt(3, aId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
784 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
785 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
786 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
787 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
788 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
789 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
790 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
791 log.error("added artifact to collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
792 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
793 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
794 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
795 public void removedArtifactFromCollection( |
1003
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
796 final String artifactId, |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
797 final String collectionId, |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
798 Backend backend, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
799 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
800 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
801 log.debug("removedArtifactFromCollection"); |
1003
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
802 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
803 @Override |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
804 public boolean doIt() throws SQLException { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
805 prepareStatement(SQL_ARTIFACT_BY_GID); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
806 stmnt.setString(1, artifactId); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
807 result = stmnt.executeQuery(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
808 if (!result.next()) { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
809 return false; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
810 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
811 int aId = result.getInt(1); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
812 reset(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
813 prepareStatement(SQL_COLLECTION_BY_GID); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
814 stmnt.setString(1, collectionId); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
815 result = stmnt.executeQuery(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
816 if (!result.next()) { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
817 return false; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
818 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
819 int cId = result.getInt(1); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
820 reset(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
821 prepareStatement(SQL_DELETE_ARTIFACT_FROM_COLLECTION); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
822 stmnt.setInt(1, cId); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
823 stmnt.setInt(2, aId); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
824 stmnt.execute(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
825 conn.commit(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
826 return true; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
827 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
828 }; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
829 if (!exec.runWrite()) { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
830 log.error("removing artifact from collection failed"); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
831 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
832 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
833 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
834 public void setCollectionName( |
1003
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
835 final String collectionId, |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
836 final String name, |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
837 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
838 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
839 log.debug("setCollectionName"); |
1003
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
840 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
841 @Override |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
842 public boolean doIt() throws SQLException { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
843 prepareStatement(SQL_UPDATE_COLLECTION_NAME); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
844 stmnt.setString(1, name); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
845 stmnt.setString(2, collectionId); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
846 stmnt.execute(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
847 conn.commit(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
848 return true; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
849 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
850 }; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
851 if (!exec.runWrite()) { |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
852 log.error("changing name failed"); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
853 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
854 } |
1002
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
855 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
856 protected void storeData( |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
857 final int artifactId, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
858 FLYSArtifact artifact |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
859 ) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
860 final Collection<StateData> data = artifact.getAllData(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
861 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
862 if (data.isEmpty()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
863 return; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
864 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
865 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
866 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
867 @Override |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
868 public boolean doIt() throws SQLException { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
869 int [] ids = new int[data.size()]; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
870 prepareStatement(SQL_ARTIFACT_DATA_ID_NEXTVAL); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
871 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
872 for (int i = 0; i < ids.length; ++i) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
873 result = stmnt.executeQuery(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
874 if (!result.next()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
875 log.error("generating id for artifact data failed"); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
876 return false; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
877 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
878 ids[i] = result.getInt(1); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
879 result.close(); result = null; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
880 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
881 reset(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
882 prepareStatement(SQL_INSERT_ARTIFACT_DATA); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
883 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
884 int i = 0; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
885 for (StateData sd: data) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
886 int id = ids[i++]; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
887 stmnt.setInt(1, id); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
888 stmnt.setInt(2, artifactId); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
889 // XXX: Where come the nulls from? |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
890 String type = sd.getType(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
891 if (type == null) type = "String"; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
892 stmnt.setString(3, type); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
893 stmnt.setString(4, sd.getName()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
894 setString(stmnt, 5, sd.getValue()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
895 stmnt.execute(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
896 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
897 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
898 conn.commit(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
899 return true; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
900 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
901 }; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
902 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
903 if (!exec.runWrite()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
904 log.error("storing artifact data failed"); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
905 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
906 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
907 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
908 protected void storeOuts( |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
909 final int artifactId, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
910 final FLYSArtifact artifact, |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
911 GlobalContext context |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
912 ) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
913 final List<Output> outs = artifact.getCurrentOutputs(context); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
914 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
915 if (outs.isEmpty()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
916 return; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
917 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
918 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
919 final int [] outIds = new int[outs.size()]; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
920 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
921 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
922 @Override |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
923 public boolean doIt() throws SQLException { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
924 prepareStatement(SQL_OUT_ID_NEXTVALUE); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
925 for (int i = 0; i < outIds.length; ++i) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
926 result = stmnt.executeQuery(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
927 if (!result.next()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
928 log.error("generation of out ids failed"); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
929 return false; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
930 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
931 outIds[i] = result.getInt(1); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
932 result.close(); result = null; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
933 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
934 reset(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
935 prepareStatement(SQL_INSERT_OUT); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
936 for (int i = 0; i < outIds.length; ++i) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
937 Output out = outs.get(i); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
938 stmnt.setInt(1, outIds[i]); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
939 stmnt.setInt(2, artifactId); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
940 stmnt.setString(3, out.getName()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
941 setString(stmnt, 4, out.getDescription()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
942 setString(stmnt, 5, out.getType()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
943 stmnt.execute(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
944 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
945 conn.commit(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
946 return true; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
947 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
948 }; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
949 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
950 if (!exec.runWrite()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
951 log.error("storing artifact outs failed"); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
952 return; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
953 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
954 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
955 final int FACETS = numFacets(outs); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
956 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
957 if (FACETS == 0) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
958 return; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
959 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
960 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
961 exec = sqlExecutor.new Instance() { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
962 @Override |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
963 public boolean doIt() throws SQLException { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
964 int [] facetIds = new int[FACETS]; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
965 prepareStatement(SQL_FACET_ID_NEXTVAL); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
966 for (int i = 0; i < facetIds.length; ++i) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
967 result = stmnt.executeQuery(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
968 if (!result.next()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
969 log.error("generation of facet ids failed"); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
970 return false; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
971 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
972 facetIds[i] = result.getInt(1); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
973 result.close(); result = null; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
974 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
975 reset(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
976 prepareStatement(SQL_INSERT_FACET); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
977 int index = 0; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
978 for (int i = 0, N = outs.size(); i < N; ++i) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
979 Output out = outs.get(i); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
980 int outId = outIds[i]; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
981 for (Facet facet: out.getFacets()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
982 stmnt.setInt(1, facetIds[index]); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
983 stmnt.setInt(2, outId); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
984 stmnt.setString(3, facet.getName()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
985 stmnt.setInt(4, facet.getIndex()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
986 stmnt.setString(5, "XXX"); // TODO: handle states |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
987 setString(stmnt, 6, facet.getDescription()); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
988 stmnt.execute(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
989 ++index; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
990 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
991 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
992 conn.commit(); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
993 return true; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
994 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
995 }; |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
996 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
997 if (!exec.runWrite()) { |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
998 log.error("storing facets failed"); |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
999 } |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
1000 } |
1006
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1001 |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1002 public void killedCollections( |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1003 final List<String> identifiers, |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1004 GlobalContext context |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1005 ) { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1006 log.debug("killedCollections"); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1007 |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1008 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1009 @Override |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1010 public boolean doIt() throws SQLException { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1011 prepareStatement(SQL_DELETE_COLLECTION_BY_GID); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1012 for (String identifier: identifiers) { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1013 stmnt.setString(1, identifier); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1014 stmnt.execute(); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1015 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1016 conn.commit(); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1017 return true; |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1018 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1019 }; |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1020 |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1021 if (!exec.runWrite()) { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1022 log.error("killing collections failed"); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1023 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1024 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1025 |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1026 public void killedArtifacts( |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1027 final List<String> identifiers, |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1028 GlobalContext context |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1029 ) { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1030 log.debug("killedArtifacts"); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1031 |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1032 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1033 @Override |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1034 public boolean doIt() throws SQLException { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1035 prepareStatement(SQL_DELETE_ARTIFACT_BY_GID); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1036 for (String identifier: identifiers) { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1037 stmnt.setString(1, identifier); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1038 stmnt.execute(); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1039 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1040 conn.commit(); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1041 return true; |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1042 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1043 }; |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1044 |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1045 if (!exec.runWrite()) { |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1046 log.error("killing artifacts failed"); |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1047 } |
1917f32701dc
Forwarded kill collections and artifacts events to datacage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1004
diff
changeset
|
1048 } |
982
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1049 } |
66b3f2f064de
Added the datacage as lifetime listener to the artifact database to create the initial index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1050 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |