Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ExtractText.java |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | } |
41 | 41 | |
42 | 42 | @Override |
43 | | - protected TextStoreBuilder createStore() throws IOException, PersistenceException { |
| 43 | + protected TextStoreBuilder createStore() throws IOException, PersistenceException {... |
44 | 44 | if (args.isSet("stream")) { |
45 | 45 | String n = args.getOption("stream", null); |
46 | 46 | OutputStream out; |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildConceptInfo.java |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | |
30 | 30 | @Override |
31 | 31 | protected ConceptInfoStoreBuilder<? extends WikiWordConcept> createStore(DataSource db) throws PersistenceException { |
32 | | - return createConceptStoreBuilder(db).getConceptInfoStoreBuilder(); |
| 32 | + return createConceptStoreBuilder(db).getConceptInfoStoreBuilder(); ... |
33 | 33 | } |
34 | 34 | |
35 | 35 | @Override |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportDump.java |
— | — | @@ -111,9 +111,9 @@ |
112 | 112 | if (args.isSet("showstats")) args.setOption("buildstats", true); |
113 | 113 | |
114 | 114 | section("-- dbstats --------------------------------------------------"); |
115 | | - store.dumpTableStats(getLogOutput()); |
| 115 | + dumpTableStats(); |
116 | 116 | |
117 | | - int w = store.getNumberOfWarnings(); //XXX: warnings per root-task! |
| 117 | + int w = getNumberOfWarnings(); //XXX: warnings per root-task! |
118 | 118 | if (w==0) info("no warnings"); |
119 | 119 | else warn("******* NOTE: "+w+" warnings collected! *******"); |
120 | 120 | } |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildThesaurus.java |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | } |
38 | 38 | |
39 | 39 | @Override |
40 | | - protected GlobalConceptStoreBuilder createStore(DataSource db) throws PersistenceException { |
| 40 | + protected GlobalConceptStoreBuilder createStore(DataSource db) throws PersistenceException {... |
41 | 41 | try { |
42 | 42 | String lang = args.getStringOption("languages", null); |
43 | 43 | Connection connection = null; |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportConcepts.java |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | |
30 | 30 | @Override |
31 | 31 | protected void afterImport() throws PersistenceException { |
32 | | - store.getStatisticsStoreBuilder().clear(); |
| 32 | + conceptStore.getStatisticsStoreBuilder().clear(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | @Override |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/WalkCats.java |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | |
24 | 24 | @Override |
25 | 25 | protected void run() throws Exception { |
26 | | - DatabaseWikiWordConceptStoreBuilder st = ((DatabaseWikiWordConceptStoreBuilder)this.store); |
| 26 | + DatabaseWikiWordConceptStoreBuilder st = ((DatabaseWikiWordConceptStoreBuilder)this.conceptStore); |
27 | 27 | |
28 | 28 | section("-- deleting cycles --------------------------------------------------"); |
29 | 29 | long t = System.currentTimeMillis(); |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildStatistics.java |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | @Override |
29 | 29 | protected StatisticsStoreBuilder createStore(DataSource db) throws PersistenceException { |
30 | 30 | conceptStore = createConceptStoreBuilder(db); |
31 | | - return conceptStore.getStatisticsStoreBuilder(); |
| 31 | + return conceptStore.getStatisticsStoreBuilder();... |
32 | 32 | } |
33 | 33 | |
34 | 34 | @Override |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ConceptImporter.java |
— | — | @@ -48,25 +48,25 @@ |
49 | 49 | |
50 | 50 | @Override |
51 | 51 | 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(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | @Override |
58 | 58 | public void finish() throws PersistenceException { |
59 | 59 | if (beginTask("ConceptImporter.finish", "finishImport")) { |
60 | | - store.finishImport(); |
| 60 | + store.finalizeImport(); |
61 | 61 | endTask("ConceptImporter.finish", "finishImport"); |
62 | 62 | } |
63 | 63 | |
64 | 64 | if (beginTask("ConceptImporter.finish", "finishImport")) { |
65 | | - propertyStore.finishImport(); |
| 65 | + propertyStore.finalizeImport(); |
66 | 66 | endTask("ConceptImporter.finish", "finishImport"); |
67 | 67 | } |
68 | 68 | |
69 | 69 | if (beginTask("ConceptImporter.finish", "finishImport")) { |
70 | | - textStore.finishImport(); |
| 70 | + textStore.finalizeImport(); |
71 | 71 | endTask("ConceptImporter.finish", "finishImport"); |
72 | 72 | } |
73 | 73 | |
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 @@ |
503 | 503 | |
504 | 504 | /** |
505 | 505 | * @throws PersistenceException |
506 | | - * @see de.brightbyte.wikiword.store.builder.LocalConceptStoreBuilder#prepare() |
| 506 | + * @see de.brightbyte.wikiword.store.builder.LocalConceptStoreBuilder#prepareImport() |
507 | 507 | */ |
508 | | - public void prepare() throws PersistenceException, PersistenceException { |
| 508 | + public void prepareImport() throws PersistenceException, PersistenceException { |
509 | 509 | if (getAgenda().beginTask("DatabaseLocalConceptStore.prepare", "prepare")) { |
510 | 510 | try { |
511 | 511 | database.disableKeys(); |
— | — | @@ -515,7 +515,7 @@ |
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
519 | | - public void finishImport() throws PersistenceException { |
| 519 | + public void finalizeImport() throws PersistenceException { |
520 | 520 | try { |
521 | 521 | flush(); |
522 | 522 | if (beginTask("DatabaseLocalConceptStore.finishImport", "enableKeys")) { |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/WikiWordStoreBuilder.java |
— | — | @@ -9,6 +9,10 @@ |
10 | 10 | |
11 | 11 | public abstract void initialize(boolean purge, boolean dropAll) throws PersistenceException; |
12 | 12 | |
| 13 | + public abstract void prepareImport() throws PersistenceException; |
| 14 | + public void finalizeImport() throws PersistenceException; |
| 15 | + |
| 16 | + |
13 | 17 | public abstract void close(boolean flush) throws PersistenceException; |
14 | 18 | |
15 | 19 | public abstract void open() throws PersistenceException; |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/FauxStoreBuilder.java |
— | — | @@ -7,11 +7,17 @@ |
8 | 8 | import de.brightbyte.application.Agenda; |
9 | 9 | import de.brightbyte.io.Output; |
10 | 10 | import de.brightbyte.util.PersistenceException; |
| 11 | +import de.brightbyte.wikiword.DatasetIdentifier; |
11 | 12 | |
12 | 13 | public abstract class FauxStoreBuilder implements WikiWordStoreBuilder { |
13 | 14 | |
14 | 15 | protected int logLevel = LOG_INFO; |
15 | 16 | private Agenda agenda; |
| 17 | + private DatasetIdentifier dataset; |
| 18 | + |
| 19 | + public FauxStoreBuilder(DatasetIdentifier dataset) { |
| 20 | + this.dataset = dataset; |
| 21 | + } |
16 | 22 | |
17 | 23 | public void deleteDataAfter(int rcId, boolean inclusive) throws PersistenceException { |
18 | 24 | throw new UnsupportedOperationException(); |
— | — | @@ -33,9 +39,13 @@ |
34 | 40 | //noop |
35 | 41 | } |
36 | 42 | |
37 | | - public void prepare() throws PersistenceException { |
| 43 | + public void prepareImport() throws PersistenceException { |
38 | 44 | //noop |
39 | 45 | } |
| 46 | + |
| 47 | + public void finalizeImport() throws PersistenceException { |
| 48 | + flush(); |
| 49 | + } |
40 | 50 | |
41 | 51 | public void finish() throws PersistenceException { |
42 | 52 | flush(); |
— | — | @@ -92,5 +102,9 @@ |
93 | 103 | // noop |
94 | 104 | } |
95 | 105 | |
| 106 | + |
| 107 | + public DatasetIdentifier getDatasetIdentifier() { |
| 108 | + return dataset; |
| 109 | + } |
96 | 110 | |
97 | 111 | } |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/PlainTextOutput.java |
— | — | @@ -4,6 +4,7 @@ |
5 | 5 | import java.io.OutputStream; |
6 | 6 | |
7 | 7 | import de.brightbyte.util.PersistenceException; |
| 8 | +import de.brightbyte.wikiword.DatasetIdentifier; |
8 | 9 | import de.brightbyte.wikiword.ResourceType; |
9 | 10 | |
10 | 11 | public class PlainTextOutput extends FauxStoreBuilder implements TextStoreBuilder { |
— | — | @@ -11,7 +12,9 @@ |
12 | 13 | protected OutputStream out; |
13 | 14 | protected String encoding; |
14 | 15 | |
15 | | - public PlainTextOutput(OutputStream out, String enc) { |
| 16 | + public PlainTextOutput(DatasetIdentifier dataset, OutputStream out, String enc) { |
| 17 | + super(dataset); |
| 18 | + |
16 | 19 | if (out==null) throw new NullPointerException(); |
17 | 20 | if (enc==null) throw new NullPointerException(); |
18 | 21 | |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/LocalConceptStoreBuilder.java |
— | — | @@ -76,7 +76,6 @@ |
77 | 77 | |
78 | 78 | public abstract void deleteDataAfter(int rcId, boolean inclusive) throws PersistenceException; |
79 | 79 | |
80 | | - public abstract void prepare() throws PersistenceException; |
81 | 80 | |
82 | 81 | //public abstract Agenda getAgenda() throws PersistenceException; |
83 | 82 | |
— | — | @@ -88,7 +87,6 @@ |
89 | 88 | |
90 | 89 | //public LogPoint getLastLogPoint() throws SQLException; |
91 | 90 | |
92 | | - public void finishImport() throws PersistenceException; |
93 | 91 | public void finishSections() throws PersistenceException; |
94 | 92 | public void finishBadLinks() throws PersistenceException; |
95 | 93 | public void finishMissingConcepts() throws PersistenceException; |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseTextStoreBuilder.java |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | * The TweakSet supplied to the constructur is used by |
24 | 24 | * {@link de.brightbyte.wikiword.store.DatabaseTextStore}, see there. |
25 | 25 | */ |
26 | | -public class DatabaseTextStoreBuilder extends DatabaseLocalStoreBuilder implements TextStoreBuilder { |
| 26 | +public class DatabaseTextStoreBuilder extends DatabaseIncrementalStoreBuilder implements TextStoreBuilder { |
27 | 27 | |
28 | 28 | protected LocalConceptStoreSchema localConceptDatabase; |
29 | 29 | |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabasePropertyStoreBuilder.java |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | import de.brightbyte.wikiword.schema.LocalConceptStoreSchema; |
14 | 14 | import de.brightbyte.wikiword.schema.PropertyStoreSchema; |
15 | 15 | |
16 | | -public class DatabasePropertyStoreBuilder extends DatabaseLocalStoreBuilder implements PropertyStoreBuilder { |
| 16 | +public class DatabasePropertyStoreBuilder extends DatabaseIncrementalStoreBuilder implements PropertyStoreBuilder { |
17 | 17 | |
18 | 18 | protected RelationTable propertyTable; |
19 | 19 | protected Inserter propertyInserter; |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DebugLocalConceptStoreBuilder.java |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | import de.brightbyte.util.PersistenceException; |
17 | 17 | import de.brightbyte.wikiword.ConceptType; |
18 | 18 | import de.brightbyte.wikiword.Corpus; |
| 19 | +import de.brightbyte.wikiword.DatasetIdentifier; |
19 | 20 | import de.brightbyte.wikiword.ExtractionRule; |
20 | 21 | import de.brightbyte.wikiword.ResourceType; |
21 | 22 | import de.brightbyte.wikiword.model.LocalConcept; |
— | — | @@ -99,7 +100,19 @@ |
100 | 101 | public boolean isComplete() throws PersistenceException { |
101 | 102 | return true; |
102 | 103 | } |
| 104 | + |
| 105 | + public void finalizeImport() throws PersistenceException { |
| 106 | + log("* finalizeImport *"); |
| 107 | + } |
| 108 | + |
| 109 | + public void prepareImport() throws PersistenceException { |
| 110 | + log("* prepareImport *"); |
| 111 | + } |
103 | 112 | |
| 113 | + public DatasetIdentifier getDatasetIdentifier() { |
| 114 | + return dataset; |
| 115 | + } |
| 116 | + |
104 | 117 | } |
105 | 118 | |
106 | 119 | public class DebugPropertyStoreBuilder implements PropertyStoreBuilder { |
— | — | @@ -108,6 +121,15 @@ |
109 | 122 | log("* finishAliases *"); |
110 | 123 | } |
111 | 124 | |
| 125 | + |
| 126 | + public void finalizeImport() throws PersistenceException { |
| 127 | + log("* finalizeImport *"); |
| 128 | + } |
| 129 | + |
| 130 | + public void prepareImport() throws PersistenceException { |
| 131 | + log("* prepareImport *"); |
| 132 | + } |
| 133 | + |
112 | 134 | public void storeProperty(int resourceId, int conceptId, String concept, String property, String value) throws PersistenceException { |
113 | 135 | log("* storeProperty("+resourceId+", "+conceptId+", "+concept+", "+property+", "+value+") *"); |
114 | 136 | } |
— | — | @@ -176,10 +198,23 @@ |
177 | 199 | return null; |
178 | 200 | } |
179 | 201 | |
| 202 | + public DatasetIdentifier getDatasetIdentifier() { |
| 203 | + return dataset; |
| 204 | + } |
| 205 | + |
180 | 206 | } |
181 | 207 | |
182 | 208 | public class DebugStatisticsStoreBuilder implements StatisticsStoreBuilder { |
183 | 209 | |
| 210 | + |
| 211 | + public void finalizeImport() throws PersistenceException { |
| 212 | + log("* finalizeImport *"); |
| 213 | + } |
| 214 | + |
| 215 | + public void prepareImport() throws PersistenceException { |
| 216 | + log("* prepareImport *"); |
| 217 | + } |
| 218 | + |
184 | 219 | public void buildStatistics() throws PersistenceException { |
185 | 220 | log("* buildStatistics *"); |
186 | 221 | } |
— | — | @@ -249,11 +284,24 @@ |
250 | 285 | public boolean isComplete() throws PersistenceException { |
251 | 286 | return true; |
252 | 287 | } |
| 288 | + public DatasetIdentifier getDatasetIdentifier() { |
| 289 | + return dataset; |
| 290 | + } |
| 291 | + |
253 | 292 | } |
254 | 293 | |
255 | 294 | public class DebugConceptInfoStoreBuilder implements |
256 | 295 | ConceptInfoStoreBuilder<LocalConcept> { |
257 | 296 | |
| 297 | + |
| 298 | + public void finalizeImport() throws PersistenceException { |
| 299 | + log("* finalizeImport *"); |
| 300 | + } |
| 301 | + |
| 302 | + public void prepareImport() throws PersistenceException { |
| 303 | + log("* prepareImport *"); |
| 304 | + } |
| 305 | + |
258 | 306 | public void buildConceptInfo() throws PersistenceException { |
259 | 307 | log("* buildConceptInfo *"); |
260 | 308 | } |
— | — | @@ -319,6 +367,10 @@ |
320 | 368 | return true; |
321 | 369 | } |
322 | 370 | |
| 371 | + public DatasetIdentifier getDatasetIdentifier() { |
| 372 | + return dataset; |
| 373 | + } |
| 374 | + |
323 | 375 | } |
324 | 376 | |
325 | 377 | public class DebugAgendaPersistor extends Agenda.TransientPersistor { |
— | — | @@ -357,6 +409,7 @@ |
358 | 410 | protected int sectionCounter = 0; |
359 | 411 | |
360 | 412 | private Agenda agenda; |
| 413 | + private DatasetIdentifier dataset = DatasetIdentifier.forName("DEBUG", "dummy"); |
361 | 414 | |
362 | 415 | public DebugLocalConceptStoreBuilder(Output out) { |
363 | 416 | super(); |
— | — | @@ -411,7 +464,7 @@ |
412 | 465 | log("* open *"); |
413 | 466 | } |
414 | 467 | |
415 | | - public void prepare() { |
| 468 | + public void prepareImport() { |
416 | 469 | log("* prepare *"); |
417 | 470 | } |
418 | 471 | |
— | — | @@ -563,7 +616,7 @@ |
564 | 617 | log("* finishIdReferences *"); |
565 | 618 | } |
566 | 619 | |
567 | | - public void finishImport() throws PersistenceException { |
| 620 | + public void finalizeImport() throws PersistenceException { |
568 | 621 | log("* finishImport *"); |
569 | 622 | } |
570 | 623 | |
— | — | @@ -637,5 +690,9 @@ |
638 | 691 | trace("+ storeAbout: resource = "+resource+", concept = "+concept+", conceptName = "+conceptName); |
639 | 692 | return -1; |
640 | 693 | } |
| 694 | + |
| 695 | + public DatasetIdentifier getDatasetIdentifier() { |
| 696 | + return dataset; |
| 697 | + } |
641 | 698 | |
642 | 699 | } |
\ No newline at end of file |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/TsvPropertyOutput.java |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | import de.brightbyte.util.PersistenceException; |
12 | 12 | import de.brightbyte.wikiword.ConceptType; |
13 | 13 | import de.brightbyte.wikiword.Corpus; |
| 14 | +import de.brightbyte.wikiword.DatasetIdentifier; |
14 | 15 | import de.brightbyte.wikiword.ResourceType; |
15 | 16 | import de.brightbyte.wikiword.schema.AliasScope; |
16 | 17 | |
— | — | @@ -24,11 +25,12 @@ |
25 | 26 | |
26 | 27 | //FIXME: use multiple TsvWriters |
27 | 28 | |
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)); |
30 | 31 | } |
31 | 32 | |
32 | | - public TsvPropertyOutput(Corpus corpus, Writer out) { |
| 33 | + public TsvPropertyOutput(DatasetIdentifier dataset, Corpus corpus, Writer out) { |
| 34 | + super(dataset); |
33 | 35 | this.corpus = corpus; |
34 | 36 | this.out = out; |
35 | 37 | } |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java |
— | — | @@ -477,5 +477,13 @@ |
478 | 478 | |
479 | 479 | return executeChunkedUpdate("resolveRedirects", table.getName()+"."+relNameField+"+"+relIdField, sql, where, aliasTable, "source", chunkFactor); |
480 | 480 | } |
| 481 | + |
| 482 | + public void finalizeImport() throws PersistenceException { |
| 483 | + flush(); |
| 484 | + } |
| 485 | + |
| 486 | + public void prepareImport() throws PersistenceException { |
| 487 | + //noop |
| 488 | + } |
481 | 489 | |
482 | 490 | } |
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 @@ |
39 | 39 | import de.brightbyte.wikiword.store.DatabaseLocalConceptStore; |
40 | 40 | import de.brightbyte.wikiword.store.DatabaseWikiWordConceptStore; |
41 | 41 | import de.brightbyte.wikiword.store.WikiWordConceptStore; |
42 | | -import de.brightbyte.wikiword.store.WikiWordStore; |
43 | 42 | import de.brightbyte.wikiword.store.DatabaseWikiWordConceptStore.DatabaseStatisticsStore; |
44 | 43 | |
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> { |
46 | 45 | |
47 | 46 | protected RdfPlatform<V, R, A, W> platform; |
48 | 47 | protected RdfOutput<V, R, A, W> output; |
— | — | @@ -72,7 +71,7 @@ |
73 | 72 | warn(GENERIC_QUALIFIER_WARNING); |
74 | 73 | } |
75 | 74 | |
76 | | - if (!isDatasetLocal() && !identifiers.globalConceptBaseURI(getDataset()).matches(".*\\d.*")) { |
| 75 | + if (!isDatasetLocal() && !identifiers.globalConceptBaseURI(getStoreDataset()).matches(".*\\d.*")) { |
77 | 76 | warn(GENERIC_COLLECTION_WARNING); |
78 | 77 | } |
79 | 78 | |
— | — | @@ -214,7 +213,7 @@ |
215 | 214 | protected LocalConceptProvider aquireLocalConceptProvider(String lang) throws RdfException { |
216 | 215 | LocalConceptProvider p = providers.get(lang); |
217 | 216 | if (p==null) { |
218 | | - Corpus c = Corpus.forName(getCollectionName(), lang, tweaks); |
| 217 | + Corpus c = Corpus.forName(getConfiguredCollectionName(), lang, tweaks); |
219 | 218 | p = new LocalConceptProvider(c, nameField); |
220 | 219 | providers.put(lang, p); |
221 | 220 | } |
— | — | @@ -257,7 +256,7 @@ |
258 | 257 | protected Corpus aquireCorpus(String lang) { |
259 | 258 | Corpus c = corpora.get(lang); |
260 | 259 | if (c==null) { |
261 | | - c = Corpus.forName(getCollectionName(), lang, tweaks); |
| 260 | + c = Corpus.forName(getConfiguredCollectionName(), lang, tweaks); |
262 | 261 | corpora.put(lang, c); |
263 | 262 | } |
264 | 263 | |
— | — | @@ -411,7 +410,7 @@ |
412 | 411 | writeStringProperty(concept, ww.displayLabel, name, language); |
413 | 412 | |
414 | 413 | int t = DatabaseUtil.asInt(rs.getObject("type")); |
415 | | - ConceptType type = ((WikiWordConceptStore)store).getConceptType(((Number)t).intValue()); |
| 414 | + ConceptType type = conceptStore.getConceptType(((Number)t).intValue()); |
416 | 415 | |
417 | 416 | R r = platform.newResource(WikiWordIdentifiers.conceptTypeBaseURI(), type.getName()); |
418 | 417 | output.writeStatement(concept, ww.type, r); |
— | — | @@ -654,10 +653,10 @@ |
655 | 654 | platform.addNamespace(c.getURL().toString(), c.getLanguage()+"wiki"); //documents |
656 | 655 | } |
657 | 656 | else { |
658 | | - DatasetIdentifier ds = getDataset(); |
| 657 | + DatasetIdentifier ds = getStoreDataset(); |
659 | 658 | platform.setBaseURI(identifiers.globalConceptBaseURI(ds)); |
660 | 659 | |
661 | | - DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) store; //global concepts |
| 660 | + DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) conceptStore; //global concepts |
662 | 661 | Corpus[] cc = st.getLanguages(); |
663 | 662 | for (Corpus c: cc) { |
664 | 663 | platform.addNamespace(identifiers.localConceptBaseURI(c), c.getLanguage()); //local concepts |
— | — | @@ -665,12 +664,12 @@ |
666 | 665 | } |
667 | 666 | } |
668 | 667 | |
669 | | - output = new RdfOutput<V, R, A, W>(identifiers, platform, w, getDataset()); |
| 668 | + output = new RdfOutput<V, R, A, W>(identifiers, platform, w, getStoreDataset()); |
670 | 669 | output.startDocument(); |
671 | 670 | |
672 | 671 | |
673 | 672 | if (isDatasetLocal()) { |
674 | | - DatabaseLocalConceptStore st = (DatabaseLocalConceptStore) store; |
| 673 | + DatabaseLocalConceptStore st = (DatabaseLocalConceptStore) conceptStore; |
675 | 674 | LocalConceptProvider provider = new LocalConceptProvider(st.getCorpus(), CONCEPT_IDENTITY_FIELD); |
676 | 675 | LocalConceptProvider other = new LocalConceptProvider(st.getCorpus(), CONCEPT_OTHER_FIELD); |
677 | 676 | R scheme = platform.newResource(WikiWordIdentifiers.base.toString(), identifiers.datasetLName(st.getDatasetIdentifier())); |
— | — | @@ -680,7 +679,7 @@ |
681 | 680 | dumpConceptsLocal(st, provider); |
682 | 681 | } |
683 | 682 | else { |
684 | | - DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) store; |
| 683 | + DatabaseGlobalConceptStore st = (DatabaseGlobalConceptStore) conceptStore; |
685 | 684 | GlobalConceptProvider provider = new GlobalConceptProvider(st.getDatasetIdentifier(), CONCEPT_IDENTITY_FIELD); |
686 | 685 | GlobalConceptProvider other = new GlobalConceptProvider(st.getDatasetIdentifier(), CONCEPT_OTHER_FIELD); |
687 | 686 | R scheme = platform.newResource(WikiWordIdentifiers.base.toString(), identifiers.datasetLName(st.getDatasetIdentifier())); |
— | — | @@ -941,7 +940,7 @@ |
942 | 941 | } |
943 | 942 | |
944 | 943 | 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); |
946 | 945 | DatabaseTable t = db.getTable(chunkTable); |
947 | 946 | |
948 | 947 | info("dumping relation: "+name+"; chunking on "+chunkTable+"."+chunkField); |
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/ConsoleApp.java |
— | — | @@ -7,9 +7,11 @@ |
8 | 8 | |
9 | 9 | import de.brightbyte.io.Prompt; |
10 | 10 | 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; |
12 | 14 | |
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>> > { |
14 | 16 | |
15 | 17 | protected Prompt prompt; |
16 | 18 | |
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/CliApp.java |
— | — | @@ -19,19 +19,16 @@ |
20 | 20 | import de.brightbyte.io.Output; |
21 | 21 | import de.brightbyte.util.PersistenceException; |
22 | 22 | import de.brightbyte.util.SystemUtils; |
23 | | -import de.brightbyte.wikiword.model.WikiWordConcept; |
24 | | -import de.brightbyte.wikiword.model.WikiWordConceptReference; |
25 | 23 | import de.brightbyte.wikiword.rdf.WikiWordIdentifiers; |
26 | 24 | import de.brightbyte.wikiword.store.DatabaseConceptStores; |
27 | 25 | import de.brightbyte.wikiword.store.DatabaseWikiWordStore; |
28 | 26 | import de.brightbyte.wikiword.store.WikiWordConceptStore; |
29 | 27 | import de.brightbyte.wikiword.store.WikiWordLocalStore; |
30 | | -import de.brightbyte.wikiword.store.WikiWordStore; |
31 | 28 | |
32 | 29 | /** |
33 | 30 | * This is the base class for entry points to WikiWord. |
34 | 31 | */ |
35 | | -public abstract class CliApp<S extends WikiWordStore> { |
| 32 | +public abstract class CliApp<S extends WikiWordConceptStore> { |
36 | 33 | |
37 | 34 | public static final String VERSION_INFO = "WikiWord by Daniel Kinzler, brightbyte.de, 2007-2008"; |
38 | 35 | public static final String LICENSE_INFO = "Developed at the University of Leipzig. Free Software, GNU GPL"; |
— | — | @@ -43,9 +40,9 @@ |
44 | 41 | protected int logLevel; |
45 | 42 | protected int exitCode; |
46 | 43 | |
47 | | - protected S store; |
48 | | - protected DatasetIdentifier dataset; |
49 | | - protected DataSource dataSource; |
| 44 | + protected S conceptStore; |
| 45 | + //protected DatasetIdentifier dataset; |
| 46 | + //protected DataSource dataSource; |
50 | 47 | |
51 | 48 | protected TweakSet tweaks; |
52 | 49 | protected WikiWordIdentifiers identifiers; |
— | — | @@ -165,10 +162,13 @@ |
166 | 163 | } |
167 | 164 | |
168 | 165 | public Corpus getCorpus() { |
| 166 | + DatasetIdentifier dataset = getStoreDataset(); |
| 167 | + if (dataset==null) dataset = getConfiguredDataset(); |
| 168 | + |
169 | 169 | if (dataset==null) return null; |
170 | 170 | if (!(dataset instanceof Corpus)) { |
171 | | - if (store instanceof WikiWordLocalStore) { |
172 | | - dataset = ((WikiWordLocalStore)store).getCorpus(); |
| 171 | + if (conceptStore instanceof WikiWordLocalStore) { |
| 172 | + dataset = ((WikiWordLocalStore)conceptStore).getCorpus(); |
173 | 173 | } |
174 | 174 | else { |
175 | 175 | throw new IllegalStateException("this application uses a non-corpus dataset!"); |
— | — | @@ -177,9 +177,7 @@ |
178 | 178 | return (Corpus)dataset; |
179 | 179 | } |
180 | 180 | |
181 | | - public String getCollectionName() { |
182 | | - if (dataset!=null) return dataset.getCollection(); |
183 | | - |
| 181 | + protected String getConfiguredCollectionName() { |
184 | 182 | String s = args.getParameter(0); |
185 | 183 | int idx = s.indexOf(':'); |
186 | 184 | |
— | — | @@ -190,9 +188,7 @@ |
191 | 189 | return s.substring(0, idx); |
192 | 190 | } |
193 | 191 | |
194 | | - public String getDatasetName() { |
195 | | - if (dataset!=null) return dataset.getName(); |
196 | | - |
| 192 | + public String getConfiguredDatasetName() { |
197 | 193 | String s = args.getParameter(0); |
198 | 194 | int idx = s.indexOf(':'); |
199 | 195 | |
— | — | @@ -206,11 +202,16 @@ |
207 | 203 | return s; |
208 | 204 | } |
209 | 205 | |
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; |
212 | 213 | |
213 | | - String c = getCollectionName(); |
214 | | - String n = getDatasetName(); |
| 214 | + String c = getConfiguredCollectionName(); |
| 215 | + String n = getConfiguredDatasetName(); |
215 | 216 | |
216 | 217 | if (!allowGlobalStore) { |
217 | 218 | if (!allowLocalStore) throw new RuntimeException("bad setup: nither global nor local stores allowed for this app!"); |
— | — | @@ -224,9 +225,13 @@ |
225 | 226 | } |
226 | 227 | |
227 | 228 | 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 | + |
229 | 234 | if (dataset!=null && dataset instanceof Corpus) return true; |
230 | | - return getDataset() instanceof Corpus; |
| 235 | + return false; |
231 | 236 | } |
232 | 237 | |
233 | 238 | public void exit(int code) { |
— | — | @@ -269,19 +274,20 @@ |
270 | 275 | |
271 | 276 | //DriverManager.setLogStream(out); |
272 | 277 | |
273 | | - dataset = getDataset(); |
274 | 278 | identifiers = new WikiWordIdentifiers(tweaks); |
275 | 279 | |
| 280 | + DatasetIdentifier dataset = getConfiguredDataset(); |
276 | 281 | section("*** DATASET: "+dataset.getQName()+" ***"); |
277 | 282 | |
278 | | - store = createStore(); |
| 283 | + createStores(); |
| 284 | + if (conceptStore==null) throw new RuntimeException("createStores() failed to initialize conceptStore"); |
279 | 285 | |
280 | 286 | exitCode = 23; |
281 | 287 | |
282 | 288 | prepareApp(); |
283 | 289 | |
284 | 290 | try { |
285 | | - store.open(); |
| 291 | + openStores(); |
286 | 292 | |
287 | 293 | if (args.isSet("dbtest")) { |
288 | 294 | section("-- db test --------------------------------------------------"); |
— | — | @@ -294,13 +300,13 @@ |
295 | 301 | t = "\u00c4 \u00d6 \u00dc - \ud800\udf30"; |
296 | 302 | } |
297 | 303 | |
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")); |
299 | 305 | |
300 | 306 | if (s.equals(t)) { |
301 | 307 | info("DB TEST OK: "+t); |
302 | 308 | } |
303 | 309 | else { |
304 | | - store.close(true); |
| 310 | + closeStores(true); |
305 | 311 | warn("DB TEST FAILED: "+t+" != "+s+" !"); |
306 | 312 | exit(5); |
307 | 313 | return; |
— | — | @@ -309,7 +315,7 @@ |
310 | 316 | |
311 | 317 | execute(); |
312 | 318 | |
313 | | - store.close(true); |
| 319 | + closeStores(true); |
314 | 320 | |
315 | 321 | section("-- DONE --------------------------------------------------"); |
316 | 322 | exitCode = 0; |
— | — | @@ -317,13 +323,21 @@ |
318 | 324 | } |
319 | 325 | catch (Throwable ex) { |
320 | 326 | error("uncaught throwable", ex); |
321 | | - store.close(false); |
| 327 | + closeStores(false); |
322 | 328 | } |
323 | 329 | finally { |
324 | 330 | exit(exitCode); |
325 | 331 | } |
326 | 332 | } |
327 | 333 | |
| 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 | + |
328 | 342 | protected void prepareApp() throws Exception { |
329 | 343 | // noop |
330 | 344 | } |
— | — | @@ -336,29 +350,25 @@ |
337 | 351 | this.dataSource = dataSource; |
338 | 352 | } |
339 | 353 | |
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 { |
343 | 358 | //TODO: make this more abstract. we may not be storing into a DB at all! |
344 | 359 | if (dataSource==null) { |
345 | 360 | File dbf = getDatabaseFile(); |
346 | 361 | dataSource = new DatabaseConnectionInfo(dbf); |
347 | 362 | } |
348 | | - |
349 | | - store = (S)createStore(dataSource); |
350 | | - |
351 | | - dataset = ((DatabaseWikiWordStore)store).getDatasetIdentifier(); |
352 | | - return store; |
353 | 363 | } |
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(); |
358 | 367 | } |
359 | 368 | |
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 { |
361 | 371 | 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); |
363 | 373 | return store; |
364 | 374 | } |
365 | 375 | |
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/WikiWordStore.java |
— | — | @@ -4,6 +4,7 @@ |
5 | 5 | |
6 | 6 | import de.brightbyte.io.Output; |
7 | 7 | import de.brightbyte.util.PersistenceException; |
| 8 | +import de.brightbyte.wikiword.DatasetIdentifier; |
8 | 9 | |
9 | 10 | public interface WikiWordStore { |
10 | 11 | public abstract Map<String, ? extends Number> getTableStats() |
— | — | @@ -21,4 +22,6 @@ |
22 | 23 | //public abstract boolean isComplete(String app) throws PersistenceException; |
23 | 24 | |
24 | 25 | public abstract boolean isComplete() throws PersistenceException; |
| 26 | + |
| 27 | + public DatasetIdentifier getDatasetIdentifier(); |
25 | 28 | } |
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/query/QueryConsole.java |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | import de.brightbyte.wikiword.store.WikiWordConceptStore; |
32 | 32 | import de.brightbyte.wikiword.store.WikiWordStore; |
33 | 33 | |
34 | | -public class QueryConsole extends ConsoleApp<WikiWordStore> { |
| 34 | +public class QueryConsole extends ConsoleApp<WikiWordConcept> { |
35 | 35 | |
36 | 36 | public QueryConsole() { |
37 | 37 | super(true, true); |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | String n = r.getName(); |
196 | 196 | |
197 | 197 | if (n==null && c < maxAutoResolve) { |
198 | | - WikiWordConcept x = ((WikiWordConceptStore)store).getConcept(id); |
| 198 | + WikiWordConcept x = ((WikiWordConceptStore)conceptStore).getConcept(id); |
199 | 199 | r = x.getReference(); |
200 | 200 | n = r.getName(); |
201 | 201 | a = r; |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | out = new ConceptDumper(wr); |
246 | 246 | } |
247 | 247 | 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()); |
249 | 249 | ((RdfOutput)out).startDocument(); |
250 | 250 | } |
251 | 251 | else { |
— | — | @@ -321,15 +321,15 @@ |
322 | 322 | } |
323 | 323 | |
324 | 324 | protected GlobalConceptStore getGlobalConceptStore() { |
325 | | - return (GlobalConceptStore)store; |
| 325 | + return (GlobalConceptStore)conceptStore; |
326 | 326 | } |
327 | 327 | |
328 | 328 | protected LocalConceptStore getLocalConceptStore() { |
329 | | - return (LocalConceptStore)store; |
| 329 | + return (LocalConceptStore)conceptStore; |
330 | 330 | } |
331 | 331 | |
332 | 332 | 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(); |
334 | 334 | |
335 | 335 | List<String> nn = new ArrayList<String>(m.keySet()); |
336 | 336 | Collections.sort(nn); |
— | — | @@ -340,33 +340,28 @@ |
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | | - @Override |
345 | | - protected WikiWordConceptStore<? extends WikiWordConcept, ? extends WikiWordConceptReference<? extends WikiWordConcept>> createStore(DataSource db) throws PersistenceException { |
346 | | - return createConceptStore(db); |
347 | | - } |
348 | | - |
349 | 344 | public void listConcepts(ConsoleOutput out) throws PersistenceException { |
350 | | - DataSet<LocalConcept> meanings = ((WikiWordConceptStore)store).getConceptInfoStore().getAllConcepts(); |
| 345 | + DataSet<LocalConcept> meanings = getLocalConceptStore().getConceptInfoStore().getAllConcepts(); |
351 | 346 | out.writeConcepts(meanings); |
352 | 347 | } |
353 | 348 | |
354 | 349 | public void listMeaningsLocal(String term, ConsoleOutput out) throws PersistenceException { |
355 | | - DataSet<LocalConcept> meanings = ((LocalConceptStore)store).getMeanings(term); |
| 350 | + DataSet<LocalConcept> meanings = getLocalConceptStore().getMeanings(term); |
356 | 351 | out.writeConcepts(meanings); |
357 | 352 | } |
358 | 353 | |
359 | 354 | 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); |
361 | 356 | out.writeConcepts(meanings); |
362 | 357 | } |
363 | 358 | |
364 | 359 | public void showConcept(int id, ConsoleOutput out) throws PersistenceException { |
365 | | - WikiWordConcept c = ((WikiWordConceptStore)store).getConcept(id); |
| 360 | + WikiWordConcept c = conceptStore.getConcept(id); |
366 | 361 | out.writeConcept(c); |
367 | 362 | } |
368 | 363 | |
369 | 364 | public void showConcept(int id, String lang, ConsoleOutput out) throws PersistenceException { |
370 | | - GlobalConcept c = ((GlobalConceptStore)store).getConcept(id); |
| 365 | + GlobalConcept c = getGlobalConceptStore().getConcept(id); |
371 | 366 | out.writeConcept(c); |
372 | 367 | |
373 | 368 | LocalConcept lc = c.getLocalConcept(lang); |
— | — | @@ -381,7 +376,7 @@ |
382 | 377 | } |
383 | 378 | |
384 | 379 | 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)); |
386 | 381 | |
387 | 382 | LocalConcept lc = lstore.getConcept(id); |
388 | 383 | if (out.getOutput() instanceof ConceptDumper) { |