Set<String> allowedCats0, Set<String> allowedPages0, int depth,
Map<String, Set<String>> templateTree,
Map<String, Set<String>> includeTree,
Map<String, Set<String>> referenceTree,
PrintStream msgOut, boolean normalised) throws RuntimeException {
SQLiteConnection db = null;
try {
db = WikiDumpPrepareSQLiteForScalarisHandler.openDB(dbFileName, true);
db.exec("CREATE TEMPORARY TABLE currentPages(id INTEGER PRIMARY KEY ASC);");
SiteInfo siteInfo = readSiteInfo(db);
MyNamespace namespace = new MyNamespace(siteInfo);
ArrayList<String> allowedCats = new ArrayList<String>(allowedCats0.size());
MyWikiModel.normalisePageTitles(allowedCats0, namespace, allowedCats);
Set<String> allowedCatsFull = getSubCategories(allowedCats0, allowedCats, db,
templateTree, includeTree, referenceTree, msgOut, namespace);
ArrayList<String> allowedPages = new ArrayList<String>(allowedPages0.size());
MyWikiModel.normalisePageTitles(allowedPages0, namespace, allowedPages);
Set<String> currentPages = new HashSet<String>();
currentPages.addAll(allowedPages);
currentPages.addAll(allowedCatsFull);
currentPages.addAll(getPagesDirectlyInCategories(allowedCatsFull, db));
Set<String> normalisedPages = getRecursivePages(currentPages, depth, db,
templateTree, includeTree, referenceTree, msgOut);
// no need to drop table - we set temporary tables to be in-memory only
// db.exec("DROP TABLE currentPages;");
// note: need to sort case-sensitively (wiki is only case-insensitive at the first char)
final TreeSet<String> pages = new TreeSet<String>();
if (normalised) {
pages.addAll(normalisedPages);
} else {
MyWikiModel.denormalisePageTitles(normalisedPages, namespace, pages);
}
return pages;
} catch (SQLiteException e) {
System.err.println("read of pages in categories failed (sqlite error: " + e.toString() + ")");
throw new RuntimeException(e);
} finally {
if (db != null) {
db.dispose();
}
}
}