Changeset 15326 for greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
- Timestamp:
- 2008-05-01T13:59:09+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r15208 r15326 27 27 import org.greenstone.gsdl3.util.GS2MacroResolver; 28 28 import org.greenstone.gsdl3.util.GSConstants; 29 import org.greenstone.gsdl3.util. GDBMWrapper;29 import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 30 30 import org.greenstone.gsdl3.util.DBInfo; 31 31 // XML classes … … 59 59 protected String index_stem = null; 60 60 61 protected GDBMWrapper gdbm_src= null;61 protected SimpleCollectionDatabase coll_db = null; 62 62 63 63 … … 65 65 protected AbstractGS2DocumentRetrieve() 66 66 { 67 this.gdbm_src = new GDBMWrapper();68 this.macro_resolver = new GS2MacroResolver(this.gdbm_src);69 67 } 70 68 71 69 public void cleanUp() { 72 73 this.gdbm_src.closeDatabase();70 super.cleanUp(); 71 this.coll_db.closeDatabase(); 74 72 } 75 73 /** configure this service */ … … 93 91 } 94 92 95 // Open GDBM database for querying 96 String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem); 97 if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) { 98 logger.error("Could not open GDBM database!"); 93 // find out what kind of database we have 94 Element database_type_elem = (Element) GSXML.getChildByTagName(info, GSXML.DATABASE_TYPE_ELEM); 95 String database_type = null; 96 if (database_type_elem != null) { 97 database_type = database_type_elem.getAttribute(GSXML.NAME_ATT); 98 } 99 if (database_type == null || database_type.equals("")) { 100 database_type = "gdbm"; // the default 101 } 102 coll_db = new SimpleCollectionDatabase(database_type); 103 if (coll_db == null) { 104 logger.error("Couldn't create the collection database of type "+database_type); 105 return false; 106 } 107 108 // Open database for querying 109 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, this.index_stem, database_type); 110 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 111 logger.error("Could not open collection database!"); 99 112 return false; 100 113 } 114 this.macro_resolver = new GS2MacroResolver(this.coll_db); 101 115 102 116 return true; … … 105 119 /** if id ends in .fc, .pc etc, then translate it to the correct id */ 106 120 protected String translateId(String node_id) { 107 return this. gdbm_src.translateOID(node_id);121 return this.coll_db.translateOID(node_id); 108 122 } 109 123 … … 111 125 it to a greenstone one*/ 112 126 protected String translateExternalId(String node_id){ 113 return this. gdbm_src.externalId2OID(node_id);127 return this.coll_db.externalId2OID(node_id); 114 128 } 115 129 … … 120 134 /** returns a list of the child ids in order, null if no children */ 121 135 protected ArrayList getChildrenIds(String node_id) { 122 DBInfo info = this. gdbm_src.getInfo(node_id);136 DBInfo info = this.coll_db.getInfo(node_id); 123 137 if (info == null) { 124 138 return null; … … 156 170 throws GSException { 157 171 Element metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 158 DBInfo info = this. gdbm_src.getInfo(node_id);172 DBInfo info = this.coll_db.getInfo(node_id); 159 173 if (info == null) { 160 174 return null; … … 211 225 } 212 226 213 DBInfo info = this. gdbm_src.getInfo(parent_id);227 DBInfo info = this.coll_db.getInfo(parent_id); 214 228 if (info==null) { 215 229 return "-1"; … … 235 249 236 250 protected int getNumChildren(String node_id) { 237 DBInfo info = this. gdbm_src.getInfo(node_id);251 DBInfo info = this.coll_db.getInfo(node_id); 238 252 if (info == null) { 239 253 return 0; … … 254 268 */ 255 269 protected String getDocType(String node_id) { 256 DBInfo info = this. gdbm_src.getInfo(node_id);270 DBInfo info = this.coll_db.getInfo(node_id); 257 271 if (info == null) { 258 272 return GSXML.DOC_TYPE_SIMPLE; … … 275 289 // now we just check the top node 276 290 if (!is_top) { // we need to look at the top info 277 info = this. gdbm_src.getInfo(top_id);291 info = this.coll_db.getInfo(top_id); 278 292 } 279 293 if (info == null) { … … 370 384 relation_info = info; 371 385 } else { 372 relation_info = this. gdbm_src.getInfo(relation_id);386 relation_info = this.coll_db.getInfo(relation_id); 373 387 } 374 388 if (relation_info == null) { … … 405 419 relation_id = OID.getParent(current_id); 406 420 while (!relation_id.equals(current_id)) { 407 relation_info = this. gdbm_src.getInfo(relation_id);421 relation_info = this.coll_db.getInfo(relation_id); 408 422 if (relation_info == null) return result.toString(); 409 423 if (!multiple) { … … 427 441 428 442 429 /** needs to get info from gdbmdatabase - if the calling code gets it already it may pay to pass it in instead */443 /** needs to get info from collection database - if the calling code gets it already it may pay to pass it in instead */ 430 444 protected String resolveTextMacros(String doc_content, String doc_id, String lang) 431 445 { … … 452 466 value="-1"; 453 467 } else { 454 DBInfo info = this. gdbm_src.getInfo(parent_id);468 DBInfo info = this.coll_db.getInfo(parent_id); 455 469 if (info==null) { 456 470 value ="-1"; … … 478 492 479 493 protected String getHrefOID(String href_url){ 480 return this. gdbm_src.docnum2OID(href_url);494 return this.coll_db.docnum2OID(href_url); 481 495 } 482 496
Note:
See TracChangeset
for help on using the changeset viewer.