r46758 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46757‎ | r46758 | r46759 >
Date:10:17, 3 February 2009
Author:daniel
Status:deferred
Tags:
Comment:
init all stores (WORK IN PROGRESS)
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/CliApp.java (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/ConsoleApp.java (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/query/QueryConsole.java (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/rdf/ExportRdf.java (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/WikiWordStore.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildConceptInfo.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildStatistics.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildThesaurus.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ConceptImporter.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ExtractText.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportConcepts.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportDump.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/WalkCats.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseIncrementalStoreBuilder.java (added) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalStoreBuilder.java (deleted) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabasePropertyStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseTextStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DebugLocalConceptStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/FauxStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/LocalConceptStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/PlainTextOutput.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/TsvPropertyOutput.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/WikiWordStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ExtractText.java
@@ -39,7 +39,7 @@
4040 }
4141
4242 @Override
43 - protected TextStoreBuilder createStore() throws IOException, PersistenceException {
 43+ protected TextStoreBuilder createStore() throws IOException, PersistenceException {...
4444 if (args.isSet("stream")) {
4545 String n = args.getOption("stream", null);
4646 OutputStream out;
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildConceptInfo.java
@@ -28,7 +28,7 @@
2929
3030 @Override
3131 protected ConceptInfoStoreBuilder<? extends WikiWordConcept> createStore(DataSource db) throws PersistenceException {
32 - return createConceptStoreBuilder(db).getConceptInfoStoreBuilder();
 32+ return createConceptStoreBuilder(db).getConceptInfoStoreBuilder(); ...
3333 }
3434
3535 @Override
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportDump.java
@@ -111,9 +111,9 @@
112112 if (args.isSet("showstats")) args.setOption("buildstats", true);
113113
114114 section("-- dbstats --------------------------------------------------");
115 - store.dumpTableStats(getLogOutput());
 115+ dumpTableStats();
116116
117 - int w = store.getNumberOfWarnings(); //XXX: warnings per root-task!
 117+ int w = getNumberOfWarnings(); //XXX: warnings per root-task!
118118 if (w==0) info("no warnings");
119119 else warn("******* NOTE: "+w+" warnings collected! *******");
120120 }
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildThesaurus.java
@@ -36,7 +36,7 @@
3737 }
3838
3939 @Override
40 - protected GlobalConceptStoreBuilder createStore(DataSource db) throws PersistenceException {
 40+ protected GlobalConceptStoreBuilder createStore(DataSource db) throws PersistenceException {...
4141 try {
4242 String lang = args.getStringOption("languages", null);
4343 Connection connection = null;
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportConcepts.java
@@ -28,7 +28,7 @@
2929
3030 @Override
3131 protected void afterImport() throws PersistenceException {
32 - store.getStatisticsStoreBuilder().clear();
 32+ conceptStore.getStatisticsStoreBuilder().clear();
3333 }
3434
3535 @Override
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/WalkCats.java
@@ -22,7 +22,7 @@
2323
2424 @Override
2525 protected void run() throws Exception {
26 - DatabaseWikiWordConceptStoreBuilder st = ((DatabaseWikiWordConceptStoreBuilder)this.store);
 26+ DatabaseWikiWordConceptStoreBuilder st = ((DatabaseWikiWordConceptStoreBuilder)this.conceptStore);
2727
2828 section("-- deleting cycles --------------------------------------------------");
2929 long t = System.currentTimeMillis();
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildStatistics.java
@@ -27,7 +27,7 @@
2828 @Override
2929 protected StatisticsStoreBuilder createStore(DataSource db) throws PersistenceException {
3030 conceptStore = createConceptStoreBuilder(db);
31 - return conceptStore.getStatisticsStoreBuilder();
 31+ return conceptStore.getStatisticsStoreBuilder();...
3232 }
3333
3434 @Override
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ConceptImporter.java
@@ -48,25 +48,25 @@
4949
5050 @Override
5151 public void prepare() throws PersistenceException {
52 - store.prepare();
53 - if (storeProperties) propertyStore.prepare();
54 - if (storeFlatText) textStore.prepare();
 52+ store.prepareImport();
 53+ if (storeProperties) propertyStore.prepareImport();
 54+ if (storeFlatText) textStore.prepareImport();
5555 }
5656
5757 @Override
5858 public void finish() throws PersistenceException {
5959 if (beginTask("ConceptImporter.finish", "finishImport")) {
60 - store.finishImport();
 60+ store.finalizeImport();
6161 endTask("ConceptImporter.finish", "finishImport");
6262 }
6363
6464 if (beginTask("ConceptImporter.finish", "finishImport")) {
65 - propertyStore.finishImport();
 65+ propertyStore.finalizeImport();
6666 endTask("ConceptImporter.finish", "finishImport");
6767 }
6868
6969 if (beginTask("ConceptImporter.finish", "finishImport")) {
70 - textStore.finishImport();
 70+ textStore.finalizeImport();
7171 endTask("ConceptImporter.finish", "finishImport");
7272 }
7373
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalStoreBuilder.java
@@ -1,29 +0,0 @@
2 -package de.brightbyte.wikiword.store.builder;
3 -
4 -import java.sql.SQLException;
5 -
6 -import de.brightbyte.util.PersistenceException;
7 -import de.brightbyte.wikiword.TweakSet;
8 -import de.brightbyte.wikiword.schema.WikiWordStoreSchema;
9 -
10 -public abstract class DatabaseLocalStoreBuilder extends DatabaseWikiWordStoreBuilder implements IncrementalStoreBuilder {
11 -
12 - public DatabaseLocalStoreBuilder(WikiWordStoreSchema database, TweakSet tweaks) throws SQLException {
13 - super(database, tweaks);
14 - }
15 -
16 - protected abstract void deleteDataFrom(int rcId, String op) throws PersistenceException;
17 -
18 -
19 - public void deleteDataFrom(int rcId) throws PersistenceException {
20 - log("deleting data from "+rcId);
21 - deleteDataFrom(rcId, "=");
22 - }
23 -
24 - public void deleteDataAfter(int rcId, boolean inclusive) throws PersistenceException {
25 - String op = inclusive ? ">=" : ">";
26 - log("deleting data from with id "+op+" "+rcId);
27 - deleteDataFrom(rcId, op);
28 - }
29 -
30 -}
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java
@@ -502,9 +502,9 @@
503503
504504 /**
505505 * @throws PersistenceException
506 - * @see de.brightbyte.wikiword.store.builder.LocalConceptStoreBuilder#prepare()
 506+ * @see de.brightbyte.wikiword.store.builder.LocalConceptStoreBuilder#prepareImport()
507507 */
508 - public void prepare() throws PersistenceException, PersistenceException {
 508+ public void prepareImport() throws PersistenceException, PersistenceException {
509509 if (getAgenda().beginTask("DatabaseLocalConceptStore.prepare", "prepare")) {
510510 try {
511511 database.disableKeys();
@@ -515,7 +515,7 @@
516516 }
517517 }
518518
519 - public void finishImport() throws PersistenceException {
 519+ public void finalizeImport() throws PersistenceException {
520520 try {
521521 flush();
522522 if (beginTask("DatabaseLocalConceptStore.finishImport", "enableKeys")) {
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/WikiWordStoreBuilder.java
@@ -9,6 +9,10 @@
1010
1111 public abstract void initialize(boolean purge, boolean dropAll) throws PersistenceException;
1212
 13+ public abstract void prepareImport() throws PersistenceException;
 14+ public void finalizeImport() throws PersistenceException;
 15+
 16+
1317 public abstract void close(boolean flush) throws PersistenceException;
1418
1519 public abstract void open() throws PersistenceException;
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/FauxStoreBuilder.java
@@ -7,11 +7,17 @@
88 import de.brightbyte.application.Agenda;
99 import de.brightbyte.io.Output;
1010 import de.brightbyte.util.PersistenceException;
 11+import de.brightbyte.wikiword.DatasetIdentifier;
1112
1213 public abstract class FauxStoreBuilder implements WikiWordStoreBuilder {
1314
1415 protected int logLevel = LOG_INFO;
1516 private Agenda agenda;
 17+ private DatasetIdentifier dataset;
 18+
 19+ public FauxStoreBuilder(DatasetIdentifier dataset) {
 20+ this.dataset = dataset;
 21+ }
1622
1723 public void deleteDataAfter(int rcId, boolean inclusive) throws PersistenceException {
1824 throw new UnsupportedOperationException();
@@ -33,9 +39,13 @@
3440 //noop
3541 }
3642
37 - public void prepare() throws PersistenceException {
 43+ public void prepareImport() throws PersistenceException {
3844 //noop
3945 }
 46+
 47+ public void finalizeImport() throws PersistenceException {
 48+ flush();
 49+ }
4050
4151 public void finish() throws PersistenceException {
4252 flush();
@@ -92,5 +102,9 @@
93103 // noop
94104 }
95105
 106+
 107+ public DatasetIdentifier getDatasetIdentifier() {
 108+ return dataset;
 109+ }
96110
97111 }
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/PlainTextOutput.java
@@ -4,6 +4,7 @@
55 import java.io.OutputStream;
66
77 import de.brightbyte.util.PersistenceException;
 8+import de.brightbyte.wikiword.DatasetIdentifier;
89 import de.brightbyte.wikiword.ResourceType;
910
1011 public class PlainTextOutput extends FauxStoreBuilder implements TextStoreBuilder {
@@ -11,7 +12,9 @@
1213 protected OutputStream out;
1314 protected String encoding;
1415
15 - public PlainTextOutput(OutputStream out, String enc) {
 16+ public PlainTextOutput(DatasetIdentifier dataset, OutputStream out, String enc) {
 17+ super(dataset);
 18+
1619 if (out==null) throw new NullPointerException();
1720 if (enc==null) throw new NullPointerException();
1821
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/LocalConceptStoreBuilder.java
@@ -76,7 +76,6 @@
7777
7878 public abstract void deleteDataAfter(int rcId, boolean inclusive) throws PersistenceException;
7979
80 - public abstract void prepare() throws PersistenceException;
8180
8281 //public abstract Agenda getAgenda() throws PersistenceException;
8382
@@ -88,7 +87,6 @@
8988
9089 //public LogPoint getLastLogPoint() throws SQLException;
9190
92 - public void finishImport() throws PersistenceException;
9391 public void finishSections() throws PersistenceException;
9492 public void finishBadLinks() throws PersistenceException;
9593 public void finishMissingConcepts() throws PersistenceException;
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseTextStoreBuilder.java
@@ -22,7 +22,7 @@
2323 * The TweakSet supplied to the constructur is used by
2424 * {@link de.brightbyte.wikiword.store.DatabaseTextStore}, see there.
2525 */
26 -public class DatabaseTextStoreBuilder extends DatabaseLocalStoreBuilder implements TextStoreBuilder {
 26+public class DatabaseTextStoreBuilder extends DatabaseIncrementalStoreBuilder implements TextStoreBuilder {
2727
2828 protected LocalConceptStoreSchema localConceptDatabase;
2929
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabasePropertyStoreBuilder.java
@@ -12,7 +12,7 @@
1313 import de.brightbyte.wikiword.schema.LocalConceptStoreSchema;
1414 import de.brightbyte.wikiword.schema.PropertyStoreSchema;
1515
16 -public class DatabasePropertyStoreBuilder extends DatabaseLocalStoreBuilder implements PropertyStoreBuilder {
 16+public class DatabasePropertyStoreBuilder extends DatabaseIncrementalStoreBuilder implements PropertyStoreBuilder {
1717
1818 protected RelationTable propertyTable;
1919 protected Inserter propertyInserter;
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DebugLocalConceptStoreBuilder.java
@@ -15,6 +15,7 @@
1616 import de.brightbyte.util.PersistenceException;
1717 import de.brightbyte.wikiword.ConceptType;
1818 import de.brightbyte.wikiword.Corpus;
 19+import de.brightbyte.wikiword.DatasetIdentifier;
1920 import de.brightbyte.wikiword.ExtractionRule;
2021 import de.brightbyte.wikiword.ResourceType;
2122 import de.brightbyte.wikiword.model.LocalConcept;
@@ -99,7 +100,19 @@
100101 public boolean isComplete() throws PersistenceException {
101102 return true;
102103 }
 104+
 105+ public void finalizeImport() throws PersistenceException {
 106+ log("* finalizeImport *");
 107+ }
 108+
 109+ public void prepareImport() throws PersistenceException {
 110+ log("* prepareImport *");
 111+ }
103112
 113+ public DatasetIdentifier getDatasetIdentifier() {
 114+ return dataset;
 115+ }
 116+
104117 }
105118
106119 public class DebugPropertyStoreBuilder implements PropertyStoreBuilder {
@@ -108,6 +121,15 @@
109122 log("* finishAliases *");
110123 }
111124
 125+
 126+ public void finalizeImport() throws PersistenceException {
 127+ log("* finalizeImport *");
 128+ }
 129+
 130+ public void prepareImport() throws PersistenceException {
 131+ log("* prepareImport *");
 132+ }
 133+
112134 public void storeProperty(int resourceId, int conceptId, String concept, String property, String value) throws PersistenceException {
113135 log("* storeProperty("+resourceId+", "+conceptId+", "+concept+", "+property+", "+value+") *");
114136 }
@@ -176,10 +198,23 @@
177199 return null;
178200 }
179201
 202+ public DatasetIdentifier getDatasetIdentifier() {
 203+ return dataset;
 204+ }
 205+
180206 }
181207
182208 public class DebugStatisticsStoreBuilder implements StatisticsStoreBuilder {
183209
 210+
 211+ public void finalizeImport() throws PersistenceException {
 212+ log("* finalizeImport *");
 213+ }
 214+
 215+ public void prepareImport() throws PersistenceException {
 216+ log("* prepareImport *");
 217+ }
 218+
184219 public void buildStatistics() throws PersistenceException {
185220 log("* buildStatistics *");
186221 }
@@ -249,11 +284,24 @@
250285 public boolean isComplete() throws PersistenceException {
251286 return true;
252287 }
 288+ public DatasetIdentifier getDatasetIdentifier() {
 289+ return dataset;
 290+ }
 291+
253292 }
254293
255294 public class DebugConceptInfoStoreBuilder implements
256295 ConceptInfoStoreBuilder<LocalConcept> {
257296
 297+
 298+ public void finalizeImport() throws PersistenceException {
 299+ log("* finalizeImport *");
 300+ }
 301+
 302+ public void prepareImport() throws PersistenceException {
 303+ log("* prepareImport *");
 304+ }
 305+
258306 public void buildConceptInfo() throws PersistenceException {
259307 log("* buildConceptInfo *");
260308 }
@@ -319,6 +367,10 @@
320368 return true;
321369 }
322370
 371+ public DatasetIdentifier getDatasetIdentifier() {
 372+ return dataset;
 373+ }
 374+
323375 }
324376
325377 public class DebugAgendaPersistor extends Agenda.TransientPersistor {
@@ -357,6 +409,7 @@
358410 protected int sectionCounter = 0;
359411
360412 private Agenda agenda;
 413+ private DatasetIdentifier dataset = DatasetIdentifier.forName("DEBUG", "dummy");
361414
362415 public DebugLocalConceptStoreBuilder(Output out) {
363416 super();
@@ -411,7 +464,7 @@
412465 log("* open *");
413466 }
414467
415 - public void prepare() {
 468+ public void prepareImport() {
416469 log("* prepare *");
417470 }
418471
@@ -563,7 +616,7 @@
564617 log("* finishIdReferences *");
565618 }
566619
567 - public void finishImport() throws PersistenceException {
 620+ public void finalizeImport() throws PersistenceException {
568621 log("* finishImport *");
569622 }
570623
@@ -637,5 +690,9 @@
638691 trace("+ storeAbout: resource = "+resource+", concept = "+concept+", conceptName = "+conceptName);
639692 return -1;
640693 }
 694+
 695+ public DatasetIdentifier getDatasetIdentifier() {
 696+ return dataset;
 697+ }
641698
642699 }
\ No newline at end of file
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/TsvPropertyOutput.java
@@ -10,6 +10,7 @@
1111 import de.brightbyte.util.PersistenceException;
1212 import de.brightbyte.wikiword.ConceptType;
1313 import de.brightbyte.wikiword.Corpus;
 14+import de.brightbyte.wikiword.DatasetIdentifier;
1415 import de.brightbyte.wikiword.ResourceType;
1516 import de.brightbyte.wikiword.schema.AliasScope;
1617
@@ -24,11 +25,12 @@
2526
2627 //FIXME: use multiple TsvWriters
2728
28 - public TsvPropertyOutput(Corpus corpus, OutputStream out, String enc) throws UnsupportedEncodingException {
29 - this(corpus, new OutputStreamWriter(out, enc));
 29+ public TsvPropertyOutput(DatasetIdentifier dataset, Corpus corpus, OutputStream out, String enc) throws UnsupportedEncodingException {
 30+ this(dataset, corpus, new OutputStreamWriter(out, enc));
3031 }
3132
32 - public TsvPropertyOutput(Corpus corpus, Writer out) {
 33+ public TsvPropertyOutput(DatasetIdentifier dataset, Corpus corpus, Writer out) {
 34+ super(dataset);
3335 this.corpus = corpus;
3436 this.out = out;
3537 }
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java
@@ -477,5 +477,13 @@
478478
479479 return executeChunkedUpdate("resolveRedirects", table.getName()+"."+relNameField+"+"+relIdField, sql, where, aliasTable, "source", chunkFactor);
480480 }
 481+
 482+ public void finalizeImport() throws PersistenceException {
 483+ flush();
 484+ }
 485+
 486+ public void prepareImport() throws PersistenceException {
 487+ //noop
 488+ }
481489
482490 }
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseIncrementalStoreBuilder.java
@@ -0,0 +1,54 @@
 2+package de.brightbyte.wikiword.store.builder;
 3+
 4+import java.sql.SQLException;
 5+
 6+import de.brightbyte.util.PersistenceException;
 7+import de.brightbyte.wikiword.TweakSet;
 8+import de.brightbyte.wikiword.schema.WikiWordStoreSchema;
 9+
 10+public abstract class DatabaseIncrementalStoreBuilder extends DatabaseWikiWordStoreBuilder implements IncrementalStoreBuilder {
 11+
 12+ public DatabaseIncrementalStoreBuilder(WikiWordStoreSchema database, TweakSet tweaks) throws SQLException {
 13+ super(database, tweaks);
 14+ }
 15+
 16+ protected abstract void deleteDataFrom(int rcId, String op) throws PersistenceException;
 17+
 18+
 19+ public void deleteDataFrom(int rcId) throws PersistenceException {
 20+ log("deleting data from "+rcId);
 21+ deleteDataFrom(rcId, "=");
 22+ }
 23+
 24+ public void deleteDataAfter(int rcId, boolean inclusive) throws PersistenceException {
 25+ String op = inclusive ? ">=" : ">";
 26+ log("deleting data from with id "+op+" "+rcId);
 27+ deleteDataFrom(rcId, op);
 28+ }
 29+
 30+ @Override
 31+ public void prepareImport() throws PersistenceException, PersistenceException {
 32+ if (getAgenda().beginTask("DatabaseLocalConceptStore.prepare", "prepare")) {
 33+ try {
 34+ database.disableKeys();
 35+ getAgenda().endTask("DatabaseLocalConceptStore.prepare", "prepare");
 36+ } catch (SQLException e) {
 37+ throw new PersistenceException(e);
 38+ }
 39+ }
 40+ }
 41+
 42+ @Override
 43+ public void finalizeImport() throws PersistenceException {
 44+ try {
 45+ flush();
 46+ if (beginTask("DatabaseLocalConceptStore.finishImport", "enableKeys")) {
 47+ database.enableKeys();
 48+ endTask("DatabaseLocalConceptStore.finishImport", "enableKeys");
 49+ }
 50+ } catch (SQLException e) {
 51+ throw new PersistenceException(e);
 52+ }
 53+ }
 54+
 55+}
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/rdf/ExportRdf.java
@@ -38,10 +38,9 @@
3939 import de.brightbyte.wikiword.store.DatabaseLocalConceptStore;
4040 import de.brightbyte.wikiword.store.DatabaseWikiWordConceptStore;
4141 import de.brightbyte.wikiword.store.WikiWordConceptStore;
42 -import de.brightbyte.wikiword.store.WikiWordStore;
4342 import de.brightbyte.wikiword.store.DatabaseWikiWordConceptStore.DatabaseStatisticsStore;
4443
45 -public class ExportRdf<V, R extends V, A, W> extends CliApp<WikiWordStore> {
 44+public class ExportRdf<V, R extends V, A, W> extends CliApp<WikiWordConceptStore> {
4645
4746 protected RdfPlatform<V, R, A, W> platform;
4847 protected RdfOutput<V, R, A, W> output;
@@ -72,7 +71,7 @@
7372 warn(GENERIC_QUALIFIER_WARNING);
7473 }
7574
76 - if (!isDatasetLocal() && !identifiers.globalConceptBaseURI(getDataset()).matches(".*\\d.*")) {
 75+ if (!isDatasetLocal() && !identifiers.globalConceptBaseURI(getStoreDataset()).matches(".*\\d.*")) {
7776 warn(GENERIC_COLLECTION_WARNING);
7877 }
7978
@@ -214,7 +213,7 @@
215214 protected LocalConceptProvider aquireLocalConceptProvider(String lang) throws RdfException {
216215 LocalConceptProvider p = providers.get(lang);
217216 if (p==null) {
218 - Corpus c = Corpus.forName(getCollectionName(), lang, tweaks);
 217+ Corpus c = Corpus.forName(getConfiguredCollectionName(), lang, tweaks);
219218 p = new LocalConceptProvider(c, nameField);
220219 providers.put(lang, p);
221220 }
@@ -257,7 +256,7 @@
258257 protected Corpus aquireCorpus(String lang) {
259258 Corpus c = corpora.get(lang);
260259 if (c==null) {
261 - c = Corpus.forName(getCollectionName(), lang, tweaks);
 260+ c = Corpus.forName(getConfiguredCollectionName(), lang, tweaks);
262261 corpora.put(lang, c);
263262 }
264263
@@ -411,7 +410,7 @@
412411 writeStringProperty(concept, ww.displayLabel, name, language);
413412
414413 int t = DatabaseUtil.asInt(rs.getObject("type"));
415 - ConceptType type = ((WikiWordConceptStore)store).getConceptType(((Number)t).intValue());
 414+ ConceptType type = conceptStore.getConceptType(((Number)t).intValue());
416415
417416 R r = platform.newResource(WikiWordIdentifiers.conceptTypeBaseURI(), type.getName());
418417 output.writeStatement(concept, ww.type, r);
@@ -654,10 +653,10 @@
655654 platform.addNamespace(c.getURL().toString(), c.getLanguage()+"wiki"); //documents
656655 }
657656 else {
658 - DatasetIdentifier ds = getDataset();
 657+ DatasetIdentifier ds = getStoreDataset();
659658 platform.setBaseURI(identifiers.globalConceptBaseURI(ds));
660659
661 - DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) store; //global concepts
 660+ DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) conceptStore; //global concepts
662661 Corpus[] cc = st.getLanguages();
663662 for (Corpus c: cc) {
664663 platform.addNamespace(identifiers.localConceptBaseURI(c), c.getLanguage()); //local concepts
@@ -665,12 +664,12 @@
666665 }
667666 }
668667
669 - output = new RdfOutput<V, R, A, W>(identifiers, platform, w, getDataset());
 668+ output = new RdfOutput<V, R, A, W>(identifiers, platform, w, getStoreDataset());
670669 output.startDocument();
671670
672671
673672 if (isDatasetLocal()) {
674 - DatabaseLocalConceptStore st = (DatabaseLocalConceptStore) store;
 673+ DatabaseLocalConceptStore st = (DatabaseLocalConceptStore) conceptStore;
675674 LocalConceptProvider provider = new LocalConceptProvider(st.getCorpus(), CONCEPT_IDENTITY_FIELD);
676675 LocalConceptProvider other = new LocalConceptProvider(st.getCorpus(), CONCEPT_OTHER_FIELD);
677676 R scheme = platform.newResource(WikiWordIdentifiers.base.toString(), identifiers.datasetLName(st.getDatasetIdentifier()));
@@ -680,7 +679,7 @@
681680 dumpConceptsLocal(st, provider);
682681 }
683682 else {
684 - DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) store;
 683+ DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) conceptStore;
685684 GlobalConceptProvider provider = new GlobalConceptProvider(st.getDatasetIdentifier(), CONCEPT_IDENTITY_FIELD);
686685 GlobalConceptProvider other = new GlobalConceptProvider(st.getDatasetIdentifier(), CONCEPT_OTHER_FIELD);
687686 R scheme = platform.newResource(WikiWordIdentifiers.base.toString(), identifiers.datasetLName(st.getDatasetIdentifier()));
@@ -941,7 +940,7 @@
942941 }
943942
944943 protected void dumpRelation(String name, String sql, String where, String rest, WikiWordStoreSchema db, String chunkTable, String chunkField, int factor, Processor<ResultSet> processor) throws PersistenceException {
945 - DatabaseWikiWordConceptStore dbstore = ((DatabaseWikiWordConceptStore)store);
 944+ DatabaseWikiWordConceptStore dbstore = ((DatabaseWikiWordConceptStore)conceptStore);
946945 DatabaseTable t = db.getTable(chunkTable);
947946
948947 info("dumping relation: "+name+"; chunking on "+chunkTable+"."+chunkField);
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/ConsoleApp.java
@@ -7,9 +7,11 @@
88
99 import de.brightbyte.io.Prompt;
1010 import de.brightbyte.util.PersistenceException;
11 -import de.brightbyte.wikiword.store.WikiWordStore;
 11+import de.brightbyte.wikiword.model.WikiWordConcept;
 12+import de.brightbyte.wikiword.model.WikiWordConceptReference;
 13+import de.brightbyte.wikiword.store.WikiWordConceptStore;
1214
13 -public abstract class ConsoleApp<S extends WikiWordStore> extends CliApp<S> {
 15+public abstract class ConsoleApp<C extends WikiWordConcept> extends CliApp< WikiWordConceptStore<C, WikiWordConceptReference<C>> > {
1416
1517 protected Prompt prompt;
1618
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/CliApp.java
@@ -19,19 +19,16 @@
2020 import de.brightbyte.io.Output;
2121 import de.brightbyte.util.PersistenceException;
2222 import de.brightbyte.util.SystemUtils;
23 -import de.brightbyte.wikiword.model.WikiWordConcept;
24 -import de.brightbyte.wikiword.model.WikiWordConceptReference;
2523 import de.brightbyte.wikiword.rdf.WikiWordIdentifiers;
2624 import de.brightbyte.wikiword.store.DatabaseConceptStores;
2725 import de.brightbyte.wikiword.store.DatabaseWikiWordStore;
2826 import de.brightbyte.wikiword.store.WikiWordConceptStore;
2927 import de.brightbyte.wikiword.store.WikiWordLocalStore;
30 -import de.brightbyte.wikiword.store.WikiWordStore;
3128
3229 /**
3330 * This is the base class for entry points to WikiWord.
3431 */
35 -public abstract class CliApp<S extends WikiWordStore> {
 32+public abstract class CliApp<S extends WikiWordConceptStore> {
3633
3734 public static final String VERSION_INFO = "WikiWord by Daniel Kinzler, brightbyte.de, 2007-2008";
3835 public static final String LICENSE_INFO = "Developed at the University of Leipzig. Free Software, GNU GPL";
@@ -43,9 +40,9 @@
4441 protected int logLevel;
4542 protected int exitCode;
4643
47 - protected S store;
48 - protected DatasetIdentifier dataset;
49 - protected DataSource dataSource;
 44+ protected S conceptStore;
 45+ //protected DatasetIdentifier dataset;
 46+ //protected DataSource dataSource;
5047
5148 protected TweakSet tweaks;
5249 protected WikiWordIdentifiers identifiers;
@@ -165,10 +162,13 @@
166163 }
167164
168165 public Corpus getCorpus() {
 166+ DatasetIdentifier dataset = getStoreDataset();
 167+ if (dataset==null) dataset = getConfiguredDataset();
 168+
169169 if (dataset==null) return null;
170170 if (!(dataset instanceof Corpus)) {
171 - if (store instanceof WikiWordLocalStore) {
172 - dataset = ((WikiWordLocalStore)store).getCorpus();
 171+ if (conceptStore instanceof WikiWordLocalStore) {
 172+ dataset = ((WikiWordLocalStore)conceptStore).getCorpus();
173173 }
174174 else {
175175 throw new IllegalStateException("this application uses a non-corpus dataset!");
@@ -177,9 +177,7 @@
178178 return (Corpus)dataset;
179179 }
180180
181 - public String getCollectionName() {
182 - if (dataset!=null) return dataset.getCollection();
183 -
 181+ protected String getConfiguredCollectionName() {
184182 String s = args.getParameter(0);
185183 int idx = s.indexOf(':');
186184
@@ -190,9 +188,7 @@
191189 return s.substring(0, idx);
192190 }
193191
194 - public String getDatasetName() {
195 - if (dataset!=null) return dataset.getName();
196 -
 192+ public String getConfiguredDatasetName() {
197193 String s = args.getParameter(0);
198194 int idx = s.indexOf(':');
199195
@@ -206,11 +202,16 @@
207203 return s;
208204 }
209205
210 - public DatasetIdentifier getDataset() {
211 - if (dataset!=null) return dataset;
 206+ public DatasetIdentifier getStoreDataset() {
 207+ if (conceptStore==null) return null;
 208+ return conceptStore.getDatasetIdentifier();
 209+ }
 210+
 211+ public DatasetIdentifier getConfiguredDataset() {
 212+ DatasetIdentifier dataset;
212213
213 - String c = getCollectionName();
214 - String n = getDatasetName();
 214+ String c = getConfiguredCollectionName();
 215+ String n = getConfiguredDatasetName();
215216
216217 if (!allowGlobalStore) {
217218 if (!allowLocalStore) throw new RuntimeException("bad setup: nither global nor local stores allowed for this app!");
@@ -224,9 +225,13 @@
225226 }
226227
227228 public boolean isDatasetLocal() {
228 - if (store!=null && store instanceof WikiWordLocalStore) return true;
 229+ if (conceptStore!=null && conceptStore instanceof WikiWordLocalStore) return true;
 230+
 231+ DatasetIdentifier dataset = getStoreDataset();
 232+ if (dataset==null) dataset = getConfiguredDataset();
 233+
229234 if (dataset!=null && dataset instanceof Corpus) return true;
230 - return getDataset() instanceof Corpus;
 235+ return false;
231236 }
232237
233238 public void exit(int code) {
@@ -269,19 +274,20 @@
270275
271276 //DriverManager.setLogStream(out);
272277
273 - dataset = getDataset();
274278 identifiers = new WikiWordIdentifiers(tweaks);
275279
 280+ DatasetIdentifier dataset = getConfiguredDataset();
276281 section("*** DATASET: "+dataset.getQName()+" ***");
277282
278 - store = createStore();
 283+ createStores();
 284+ if (conceptStore==null) throw new RuntimeException("createStores() failed to initialize conceptStore");
279285
280286 exitCode = 23;
281287
282288 prepareApp();
283289
284290 try {
285 - store.open();
 291+ openStores();
286292
287293 if (args.isSet("dbtest")) {
288294 section("-- db test --------------------------------------------------");
@@ -294,13 +300,13 @@
295301 t = "\u00c4 \u00d6 \u00dc - \ud800\udf30";
296302 }
297303
298 - String s = ((DatabaseSchema)((DatabaseWikiWordStore)store).getDatabaseAccess()).echo(t, args.getStringOption("dbcharset", "binary"));
 304+ String s = ((DatabaseSchema)((DatabaseWikiWordStore)conceptStore).getDatabaseAccess()).echo(t, args.getStringOption("dbcharset", "binary"));
299305
300306 if (s.equals(t)) {
301307 info("DB TEST OK: "+t);
302308 }
303309 else {
304 - store.close(true);
 310+ closeStores(true);
305311 warn("DB TEST FAILED: "+t+" != "+s+" !");
306312 exit(5);
307313 return;
@@ -309,7 +315,7 @@
310316
311317 execute();
312318
313 - store.close(true);
 319+ closeStores(true);
314320
315321 section("-- DONE --------------------------------------------------");
316322 exitCode = 0;
@@ -317,13 +323,21 @@
318324 }
319325 catch (Throwable ex) {
320326 error("uncaught throwable", ex);
321 - store.close(false);
 327+ closeStores(false);
322328 }
323329 finally {
324330 exit(exitCode);
325331 }
326332 }
327333
 334+ protected void openStores() throws PersistenceException {
 335+ conceptStore.open();
 336+ }
 337+
 338+ protected void closeStores(boolean flush) throws PersistenceException {
 339+ conceptStore.close(flush);
 340+ }
 341+
328342 protected void prepareApp() throws Exception {
329343 // noop
330344 }
@@ -336,29 +350,25 @@
337351 this.dataSource = dataSource;
338352 }
339353
340 - protected S createStore() throws IOException, PersistenceException {
341 - S store;
342 -
 354+ protected DataSource getDataSource() throws IOException, PersistenceException {
 355+
 356+ }
 357+ protected DataSource getDataSource() throws IOException, PersistenceException {
343358 //TODO: make this more abstract. we may not be storing into a DB at all!
344359 if (dataSource==null) {
345360 File dbf = getDatabaseFile();
346361 dataSource = new DatabaseConnectionInfo(dbf);
347362 }
348 -
349 - store = (S)createStore(dataSource);
350 -
351 - dataset = ((DatabaseWikiWordStore)store).getDatasetIdentifier();
352 - return store;
353363 }
354 -
355 - @SuppressWarnings("unchecked")
356 - protected S createStore(DataSource db) throws PersistenceException {
357 - return (S)createConceptStore(db);
 364+
 365+ protected void createStores() throws IOException, PersistenceException {
 366+ conceptStore = createConceptStore();
358367 }
359368
360 - protected WikiWordConceptStore<? extends WikiWordConcept, ? extends WikiWordConceptReference<? extends WikiWordConcept>> createConceptStore(DataSource db) throws PersistenceException {
 369+ @SuppressWarnings("unchecked")
 370+ protected S createConceptStore(DataSource db) throws PersistenceException {
361371 DatasetIdentifier ds = getDataset();
362 - WikiWordConceptStore<? extends WikiWordConcept, ? extends WikiWordConceptReference<? extends WikiWordConcept>> store = DatabaseConceptStores.createConceptStore(db, ds, tweaks, allowLocalStore, allowGlobalStore);
 372+ S store = (S)DatabaseConceptStores.createConceptStore(db, ds, tweaks, allowLocalStore, allowGlobalStore);
363373 return store;
364374 }
365375
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/WikiWordStore.java
@@ -4,6 +4,7 @@
55
66 import de.brightbyte.io.Output;
77 import de.brightbyte.util.PersistenceException;
 8+import de.brightbyte.wikiword.DatasetIdentifier;
89
910 public interface WikiWordStore {
1011 public abstract Map<String, ? extends Number> getTableStats()
@@ -21,4 +22,6 @@
2223 //public abstract boolean isComplete(String app) throws PersistenceException;
2324
2425 public abstract boolean isComplete() throws PersistenceException;
 26+
 27+ public DatasetIdentifier getDatasetIdentifier();
2528 }
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/query/QueryConsole.java
@@ -30,7 +30,7 @@
3131 import de.brightbyte.wikiword.store.WikiWordConceptStore;
3232 import de.brightbyte.wikiword.store.WikiWordStore;
3333
34 -public class QueryConsole extends ConsoleApp<WikiWordStore> {
 34+public class QueryConsole extends ConsoleApp<WikiWordConcept> {
3535
3636 public QueryConsole() {
3737 super(true, true);
@@ -194,7 +194,7 @@
195195 String n = r.getName();
196196
197197 if (n==null && c < maxAutoResolve) {
198 - WikiWordConcept x = ((WikiWordConceptStore)store).getConcept(id);
 198+ WikiWordConcept x = ((WikiWordConceptStore)conceptStore).getConcept(id);
199199 r = x.getReference();
200200 n = r.getName();
201201 a = r;
@@ -244,7 +244,7 @@
245245 out = new ConceptDumper(wr);
246246 }
247247 else if (format.equals("rdf") || format.equals("turtle") || format.equals("n3")) {
248 - out = new RdfOutput(identifiers, "default", wr, "turtle", getDataset());
 248+ out = new RdfOutput(identifiers, "default", wr, "turtle", getStoreDataset());
249249 ((RdfOutput)out).startDocument();
250250 }
251251 else {
@@ -321,15 +321,15 @@
322322 }
323323
324324 protected GlobalConceptStore getGlobalConceptStore() {
325 - return (GlobalConceptStore)store;
 325+ return (GlobalConceptStore)conceptStore;
326326 }
327327
328328 protected LocalConceptStore getLocalConceptStore() {
329 - return (LocalConceptStore)store;
 329+ return (LocalConceptStore)conceptStore;
330330 }
331331
332332 public void dumpStats() throws PersistenceException {
333 - Map<String, ? extends Number> m = ((WikiWordConceptStore)store).getStatisticsStore().getStatistics();
 333+ Map<String, ? extends Number> m = ((WikiWordConceptStore)conceptStore).getStatisticsStore().getStatistics();
334334
335335 List<String> nn = new ArrayList<String>(m.keySet());
336336 Collections.sort(nn);
@@ -340,33 +340,28 @@
341341 }
342342 }
343343
344 - @Override
345 - protected WikiWordConceptStore<? extends WikiWordConcept, ? extends WikiWordConceptReference<? extends WikiWordConcept>> createStore(DataSource db) throws PersistenceException {
346 - return createConceptStore(db);
347 - }
348 -
349344 public void listConcepts(ConsoleOutput out) throws PersistenceException {
350 - DataSet<LocalConcept> meanings = ((WikiWordConceptStore)store).getConceptInfoStore().getAllConcepts();
 345+ DataSet<LocalConcept> meanings = getLocalConceptStore().getConceptInfoStore().getAllConcepts();
351346 out.writeConcepts(meanings);
352347 }
353348
354349 public void listMeaningsLocal(String term, ConsoleOutput out) throws PersistenceException {
355 - DataSet<LocalConcept> meanings = ((LocalConceptStore)store).getMeanings(term);
 350+ DataSet<LocalConcept> meanings = getLocalConceptStore().getMeanings(term);
356351 out.writeConcepts(meanings);
357352 }
358353
359354 public void listMeaningsGlobal(String lang, String term, ConsoleOutput out) throws PersistenceException {
360 - DataSet<GlobalConcept> meanings = ((GlobalConceptStore)store).getMeanings(lang, term);
 355+ DataSet<GlobalConcept> meanings = getGlobalConceptStore().getMeanings(lang, term);
361356 out.writeConcepts(meanings);
362357 }
363358
364359 public void showConcept(int id, ConsoleOutput out) throws PersistenceException {
365 - WikiWordConcept c = ((WikiWordConceptStore)store).getConcept(id);
 360+ WikiWordConcept c = conceptStore.getConcept(id);
366361 out.writeConcept(c);
367362 }
368363
369364 public void showConcept(int id, String lang, ConsoleOutput out) throws PersistenceException {
370 - GlobalConcept c = ((GlobalConceptStore)store).getConcept(id);
 365+ GlobalConcept c = getGlobalConceptStore().getConcept(id);
371366 out.writeConcept(c);
372367
373368 LocalConcept lc = c.getLocalConcept(lang);
@@ -381,7 +376,7 @@
382377 }
383378
384379 public void showConcept(String lang, int id, ConsoleOutput out) throws PersistenceException {
385 - LocalConceptStore lstore = ((GlobalConceptStore)store).getLocalConceptStore(Corpus.forName(getDataset().getCollection(), lang, tweaks));
 380+ LocalConceptStore lstore = getGlobalConceptStore().getLocalConceptStore(Corpus.forName(getStoreDataset().getCollection(), lang, tweaks));
386381
387382 LocalConcept lc = lstore.getConcept(id);
388383 if (out.getOutput() instanceof ConceptDumper) {

Status & tagging log