Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java @ 1005:52949da92f7a
The signature of BackendListener in artifactdatabase has changed.
flys-artifacts/trunk@2446 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 02 Aug 2011 11:20:18 +0000 |
parents | 0e8c03b69627 |
children | 1917f32701dc |
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 = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
79 "delete.facets.by.artifacts.id"; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
80 |
983
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
81 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
|
82 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
83 public class InitialScan |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
84 implements ArtifactDatabase.ArtifactLoadedCallback |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
85 { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
86 protected LRUCache<String, Integer> users; |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
87 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
|
88 protected LRUCache<String, Integer> artifacts; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
89 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
90 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
|
91 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
92 public InitialScan() { |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
93 users = new LRUCache<String, Integer>(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
94 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
|
95 artifacts = new LRUCache<String, Integer>(); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
96 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
97 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
98 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
|
99 this(); |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
100 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
|
101 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
102 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
103 @Override |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
104 public void artifactLoaded( |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
105 String userId, |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
106 String collectionId, |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
107 String artifactId, |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
108 Artifact artifact |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
109 ) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
110 if (!(artifact instanceof FLYSArtifact)) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
111 log.warn("ignoring none FLYS artifacts"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
112 return; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
113 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
114 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
115 FLYSArtifact flysArtifact = (FLYSArtifact)artifact; |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
116 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
117 Integer uId = getUserId(userId); |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
118 // TODO: We need the name of the collection |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
119 Integer cId = getCollectionId(collectionId, uId, "XXX"); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
120 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
121 storeArtifact(artifactId, cId, flysArtifact); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
122 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
123 |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
124 protected Integer getId( |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
125 LRUCache<String, Integer> cache, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
126 final String idString, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
127 final String selectById |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
128 ) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
129 Integer id = cache.get(idString); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
130 if (id != null) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
131 return id; |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
132 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
133 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
134 final Integer [] res = new Integer[1]; |
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 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
137 @Override |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
138 public boolean doIt() throws SQLException { |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
139 prepareStatement(selectById); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
140 stmnt.setString(1, idString); |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
141 result = stmnt.executeQuery(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
142 if (!result.next()) { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
143 return false; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
144 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
145 res[0] = result.getInt(1); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
146 return true; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
147 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
148 }; |
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 if (exec.runRead()) { |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
151 cache.put(idString, res[0]); |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
152 return res[0]; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
153 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
154 |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
155 return null; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
156 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
157 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
158 protected void storeArtifact( |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
159 final String artifactId, |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
160 Integer collectionId, |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
161 final FLYSArtifact artifact |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
162 ) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
163 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
|
164 |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
165 if (aId != null) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
166 // 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
|
167 storeCollectionItem(collectionId, aId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
168 return; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
169 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
170 // 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
|
171 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
172 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
|
173 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
174 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
|
175 @Override |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
176 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
|
177 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
|
178 result = stmnt.executeQuery(); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
179 if (!result.next()) { |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
180 return false; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
181 } |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
182 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
|
183 reset(); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
184 prepareStatement(SQL_INSERT_ARTIFACT); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
185 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
|
186 stmnt.setString(2, artifactId); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
187 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
|
188 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
189 conn.commit(); |
989
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
190 return true; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
191 } |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
192 }; |
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 if (!exec.runWrite()) { |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
195 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
|
196 return; |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
197 } |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
198 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
199 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
|
200 |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
201 storeCollectionItem(collectionId, aId); |
f3be883325ce
Add artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
988
diff
changeset
|
202 |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
203 storeData(aId, artifact); |
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
204 |
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
|
205 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
|
206 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
207 |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
208 |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
209 protected void storeCollectionItem( |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
210 final Integer collectionId, |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
211 final Integer artifactId |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
212 ) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
213 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
|
214 @Override |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
215 public boolean doIt() throws SQLException { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
216 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
|
217 result = stmnt.executeQuery(); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
218 if (!result.next()) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
219 return false; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
220 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
221 int ciId = result.getInt(1); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
222 reset(); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
223 prepareStatement(SQL_INSERT_COLLECTION_ITEM); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
224 stmnt.setInt(1, ciId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
225 stmnt.setInt(2, collectionId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
226 stmnt.setInt(3, artifactId); |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
227 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
228 conn.commit(); |
988
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
229 return true; |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
230 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
231 }; |
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 if (!exec.runWrite()) { |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
234 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
|
235 } |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
236 } |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
237 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
238 protected Integer getCollectionId( |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
239 final String collectionId, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
240 final Integer ownerId, |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
241 final String collectionName |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
242 ) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
243 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
|
244 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
245 if (c != null) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
246 return c; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
247 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
248 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
249 final Integer [] res = new Integer[1]; |
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 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
252 @Override |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
253 public boolean doIt() throws SQLException { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
254 prepareStatement(SQL_COLLECTION_ID_NEXTVAL); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
255 result = stmnt.executeQuery(); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
256 if (!result.next()) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
257 return false; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
258 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
259 res[0] = result.getInt(1); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
260 reset(); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
261 prepareStatement(SQL_INSERT_COLLECTION); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
262 stmnt.setInt (1, res[0]); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
263 stmnt.setString(2, collectionId); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
264 stmnt.setInt (3, ownerId); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
265 stmnt.setString(4, collectionName); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
266 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
267 conn.commit(); |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
268 return true; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
269 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
270 }; |
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 if (exec.runWrite()) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
273 collections.put(collectionId, res[0]); |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
274 return res[0]; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
275 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
276 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
277 return null; |
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 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
280 protected Integer getUserId(final String userId) { |
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 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
|
283 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
284 if (u != null) { |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
285 return u; |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
286 } |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
287 |
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
288 final Integer [] res = new Integer[1]; |
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 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
|
291 @Override |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
292 public boolean doIt() throws SQLException { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
293 prepareStatement(SQL_USER_ID_NEXTVAL); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
294 result = stmnt.executeQuery(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
295 if (!result.next()) { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
296 return false; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
297 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
298 res[0] = result.getInt(1); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
299 reset(); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
300 prepareStatement(SQL_INSERT_USER); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
301 stmnt.setInt (1, res[0]); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
302 stmnt.setString(2, userId); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
303 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
304 conn.commit(); |
986
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
305 return true; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
306 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
307 }; |
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 if (exec.runWrite()) { |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
310 users.put(userId, res[0]); |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
311 return res[0]; |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
312 } |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
313 |
70545233f8ee
Datacage: Add users at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
984
diff
changeset
|
314 return null; |
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 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
317 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
|
318 log.debug("scan"); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
319 try { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
320 adb.loadAllArtifacts(this); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
321 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
322 catch (ArtifactDatabaseException ade) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
323 log.error(ade); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
324 return false; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
325 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
326 return true; |
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 } // class InitialScan |
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 |
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
|
331 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
|
332 } |
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 |
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 @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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 } |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
341 |
4ea5f5a2284e
Ajusted datacage to use the SQL infrastructure from the artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
982
diff
changeset
|
342 protected void setupSQL(SQL sql) { |
987
82ef338fee91
Datacage: Add collections at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
986
diff
changeset
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 SQL_COLLECTION_ITEM_ID_NEXTVAL = |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
353 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
|
354 SQL_INSERT_COLLECTION_ITEM = |
dbe39e1fb5e7
Datacage: Add collection items at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
987
diff
changeset
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 SQL_INSERT_OUT = sql.get(SQL_INSERT_OUT); |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
362 SQL_FACET_ID_NEXTVAL = sql.get(SQL_FACET_ID_NEXTVAL); |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
363 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
|
364 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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 SQL_DELETE_ARTIFACT_DATA_BY_ARTIFACT_ID = |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
370 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
|
371 SQL_DELETE_OUTS_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_OUTS_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
373 SQL_DELETE_FACETS_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_FACETS_BY_ARTIFACT_ID); |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
375 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
376 |
992
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
377 protected static final int numFacets(List<Output> outs) { |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
378 int sum = 0; |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
379 for (Output out: outs) { |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
380 sum += out.getFacets().size(); |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
381 } |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
382 return sum; |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
383 } |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
384 |
5b467bc27eda
Datacage: Store
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
991
diff
changeset
|
385 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
|
386 PreparedStatement stmnt, |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
387 int index, |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
388 Object value |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
389 ) |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
390 throws SQLException |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
391 { |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
392 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
|
393 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
|
394 } |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
395 else { |
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
396 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
|
397 } |
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
|
398 } |
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
|
399 |
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
|
400 @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
|
401 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
|
402 log.debug("systemUp entered"); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
403 initialScan(context); |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
404 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
|
405 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
|
406 } |
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
|
407 |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
408 protected void initialScan(GlobalContext context) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
409 log.debug("initialScan"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
410 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
411 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
|
412 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
413 if (!(adbObject instanceof ArtifactDatabase)) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
414 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
|
415 return; |
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 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
418 ArtifactDatabase adb = (ArtifactDatabase)adbObject; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
419 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
420 if (!cleanDatabase()) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
421 log.error("cleaning database failed"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
422 return; |
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 |
991
c675b4a87201
Store outs of artifacts into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
990
diff
changeset
|
425 InitialScan is = new InitialScan(context); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
426 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
427 if (!is.scan(adb)) { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
428 log.error("initial scan failed"); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
429 return; |
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 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
432 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
433 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
434 protected boolean cleanDatabase() { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
435 |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
436 log.debug("cleanDatabase"); |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
437 |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
438 boolean success = sqlExecutor.new Instance() { |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
439 @Override |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
440 public boolean doIt() throws SQLException { |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
441 prepareStatement(SQL_DELETE_ALL_USERS); |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
442 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
|
443 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
|
444 stmnt.execute(); |
990
e573c4715d81
Add artifacts data into datacage db at initial scan.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
989
diff
changeset
|
445 conn.commit(); |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
446 return true; |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
447 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
448 }.runWrite(); |
993
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
449 |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
450 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
|
451 |
aabcca7aeb6c
Fixed datacage db scheme. add some debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
992
diff
changeset
|
452 return success; |
984
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
453 } |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
454 |
2b05c4a0c6fd
Datacage: clear database before initial scan
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
983
diff
changeset
|
455 |
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
|
456 @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
|
457 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
|
458 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
|
459 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
460 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
461 public void setup(GlobalContext globalContext) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
462 log.debug("setup"); |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
463 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
464 |
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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
470 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
|
471 |
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 if (!(artifact instanceof FLYSArtifact)) { |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
473 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
|
474 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
|
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 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
477 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
|
478 |
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 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
|
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 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
|
482 @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
|
483 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
|
484 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
|
485 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
|
486 if (!result.next()) { |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
487 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
|
488 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
|
489 } |
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 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
|
491 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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 } |
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 }; |
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 |
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 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
|
503 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
|
504 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
|
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 |
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 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
|
508 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
|
509 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
510 |
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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
516 log.debug("storedArtifact"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
517 if (!(artifact instanceof FLYSArtifact)) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
518 log.warn("need FLYSArtifact here"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
519 return; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
520 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
521 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
522 final FLYSArtifact flys = (FLYSArtifact)artifact; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
523 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
524 final Integer [] res = new Integer[1]; |
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 // check first if artifact already exists |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
527 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
528 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
529 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
530 prepareStatement(SQL_ARTIFACT_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
531 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
532 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
533 // new artifact |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
534 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
535 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
536 res[0] = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
537 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
538 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
539 }; |
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 if (!exec.runRead()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
542 log.error("querying artifact failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
543 return; |
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 (res[0] == null) { // new artifact |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
547 createdArtifact(artifact, backend, context); |
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 // artifact already exists -> delete old data |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
552 exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
553 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
554 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
555 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
|
556 stmnt.setInt(1, res[0]); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
557 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
558 prepareStatement(SQL_DELETE_FACETS_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
559 stmnt.setInt(1, res[0]); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
560 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
561 prepareStatement(SQL_DELETE_OUTS_BY_ARTIFACT_ID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
562 stmnt.setInt(1, res[0]); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
563 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
564 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
565 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
566 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
567 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
568 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
569 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
570 log.error("deleting old artifact data failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
571 return; |
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 // write new data |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
575 storeData(res[0], flys); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
576 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
|
577 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
578 |
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
|
579 public void createdUser( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
580 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
|
581 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
|
582 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
|
583 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
584 log.debug("createdUser"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
585 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
586 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
587 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
588 prepareStatement(SQL_USER_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
589 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
590 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
591 log.error("id generation for user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
592 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
593 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
594 int uId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
595 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
596 prepareStatement(SQL_INSERT_USER); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
597 stmnt.setInt(1, uId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
598 stmnt.setString(2, user.identifier()); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
599 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
600 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
601 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
602 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
603 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
604 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
605 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
606 log.error("create user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
607 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
608 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
609 |
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
|
610 public void deletedUser( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
615 log.debug("deletedUser"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
616 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
617 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
618 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
619 prepareStatement(SQL_DELETE_USER_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
620 stmnt.setString(1, identifier); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
621 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
622 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
623 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
624 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
625 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
626 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
627 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
628 log.error("delete user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
629 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
630 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
631 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
632 public void createdCollection( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
633 final ArtifactCollection collection, |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
634 Backend backend, |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
635 GlobalContext context |
999
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 log.debug("createdCollection"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
638 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
639 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
640 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
641 String userId = collection.getUser().identifier(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
642 prepareStatement(SQL_USER_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
643 stmnt.setString(1, userId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
644 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
645 int uId; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
646 if (result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
647 uId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
648 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
649 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
650 else { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
651 // need to create user first |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
652 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
653 prepareStatement(SQL_USER_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
654 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
655 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
656 log.error("id generation for user failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
657 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
658 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
659 uId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
660 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
661 prepareStatement(SQL_INSERT_USER); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
662 stmnt.setInt(1, uId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
663 stmnt.setString(2, userId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
664 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
665 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
666 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
667 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
668 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
669 prepareStatement(SQL_COLLECTION_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
670 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
671 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
672 log.error("id generation for collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
673 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
674 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
675 int cId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
676 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
677 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
678 String identifier = collection.identifier(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
679 String name = collection.getName(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
680 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
681 prepareStatement(SQL_INSERT_COLLECTION); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
682 stmnt.setInt(1, cId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
683 stmnt.setString(2, identifier); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
684 stmnt.setInt(3, uId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
685 setString(stmnt, 4, name); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
686 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
687 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
688 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
689 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
690 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
691 }; |
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 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
694 log.error("create collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
695 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
696 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
697 |
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
|
698 public void deletedCollection( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
699 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
|
700 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
|
701 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
|
702 ) { |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
703 log.debug("deletedCollection"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
704 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
705 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
706 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
707 prepareStatement(SQL_DELETE_COLLECTION_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
708 stmnt.setString(1, identifier); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
709 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
710 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
711 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
712 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
713 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
714 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
715 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
716 log.error("delete collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
717 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
718 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
719 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
720 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
|
721 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
|
722 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
|
723 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
|
724 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
725 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
726 log.debug("changedCollectionAttribute"); |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
727 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
728 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
729 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
|
730 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
|
731 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
|
732 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
|
733 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
|
734 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
735 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
736 log.debug("changedCollectionItemAttribute"); |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
737 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
738 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
739 public void addedArtifactToCollection( |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
740 final String artifactId, |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
741 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
|
742 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
|
743 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
744 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
745 log.debug("addedArtifactToCollection"); |
1004
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
746 SQLExecutor.Instance exec = sqlExecutor.new Instance() { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
747 @Override |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
748 public boolean doIt() throws SQLException { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
749 prepareStatement(SQL_ARTIFACT_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
750 stmnt.setString(1, artifactId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
751 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
752 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
753 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
754 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
755 int aId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
756 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
757 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
758 prepareStatement(SQL_COLLECTION_BY_GID); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
759 stmnt.setString(1, collectionId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
760 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
761 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
762 return false; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
763 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
764 int cId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
765 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
766 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
767 prepareStatement(SQL_COLLECTION_ITEM_ID_NEXTVAL); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
768 result = stmnt.executeQuery(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
769 if (!result.next()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
770 return false; |
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 int ciId = result.getInt(1); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
773 reset(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
774 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
775 prepareStatement(SQL_INSERT_COLLECTION_ITEM); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
776 stmnt.setInt(1, ciId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
777 stmnt.setInt(2, cId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
778 stmnt.setInt(3, aId); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
779 stmnt.execute(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
780 |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
781 conn.commit(); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
782 return true; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
783 } |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
784 }; |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
785 if (!exec.runWrite()) { |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
786 log.error("added artifact to collection failed"); |
0e8c03b69627
Datacage: completed backend listener stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1003
diff
changeset
|
787 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
788 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
789 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
790 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
|
791 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
|
792 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
|
793 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
|
794 GlobalContext context |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
795 ) { |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
796 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
|
797 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
|
798 @Override |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 return false; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
805 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
806 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
|
807 reset(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
808 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
|
809 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
|
810 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
|
811 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
|
812 return false; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
813 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
814 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
|
815 reset(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
816 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
|
817 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
|
818 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
|
819 stmnt.execute(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
820 conn.commit(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
821 return true; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
822 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
823 }; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
824 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
|
825 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
|
826 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
827 } |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
828 |
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
829 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
|
830 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
|
831 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
|
832 GlobalContext context |
999
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 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
|
835 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
|
836 @Override |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
837 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
|
838 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
|
839 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
|
840 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
|
841 stmnt.execute(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
842 conn.commit(); |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
843 return true; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
844 } |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
845 }; |
c58da6dd15ed
Datacage: Update collection names on change. Remove artifacts from collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1002
diff
changeset
|
846 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
|
847 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
|
848 } |
999
b0218f21c664
Wire datacage with backend of artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
996
diff
changeset
|
849 } |
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
|
850 |
db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
999
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 ) { |
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 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
|
856 |
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 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
|
858 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
|
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 |
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 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
|
862 @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
|
863 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
|
864 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
|
865 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
|
866 |
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 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
|
868 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
|
869 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
|
870 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
|
871 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
|
872 } |
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 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
|
874 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
|
875 } |
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 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
|
877 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
|
878 |
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 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
|
880 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
|
881 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
|
882 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
|
883 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
|
884 // 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
|
885 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
|
886 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
|
887 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
|
888 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
|
889 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
|
890 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
|
891 } |
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 |
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 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
|
894 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
|
895 } |
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 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
|
899 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
|
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 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
|
904 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
|
905 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
|
906 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
|
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 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
|
909 |
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 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
|
911 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
|
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 |
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 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
|
915 |
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 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
|
917 @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
|
918 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
|
919 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
|
920 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
|
921 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
|
922 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
|
923 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
|
924 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
|
925 } |
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 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
|
927 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
|
928 } |
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 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
|
930 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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 } |
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 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
|
941 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
|
942 } |
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 }; |
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 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
|
946 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
|
947 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
|
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 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
|
951 |
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 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
|
953 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
|
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 |
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 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
|
957 @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
|
958 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
|
959 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
|
960 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
|
961 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
|
962 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
|
963 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
|
964 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
|
965 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
|
966 } |
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 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
|
968 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
|
969 } |
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 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
|
971 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
|
972 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
|
973 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
|
974 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
|
975 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
|
976 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
|
977 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
|
978 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
|
979 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
|
980 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
|
981 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
|
982 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
|
983 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
|
984 ++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
|
985 } |
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 } |
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 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
|
988 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
|
989 } |
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 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
|
993 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
|
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 } |
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
|
996 } |
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
|
997 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |