Changeset 8439 for trunk/gsdl3/src
- Timestamp:
- 2004-11-03T14:46:37+13:00 (20 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGRetrieve.java
r7312 r8439 164 164 //ystem.out.println("translated id = "+doc_id); 165 165 } 166 if (GS3OID.isDocTop(doc_id)) { 167 System.out.println("adding the structure bit to doc id"); 168 doc_id = GS3OID.createOID(doc_id, "1"); 166 if (GS3OID.isDocTop(doc_id) && database.isHierarchicalDocument(doc_id)) { 167 // if we have a whole doc id, and the document is hierarchical, 168 // we want to change the id to be the top id of the section 169 // hierarchy 170 doc_id = GS3OID.createOID(doc_id, "1"); 169 171 } 170 String doc_num = this.database.OID2MGNum(doc_id); 171 172 //long doc_num = this.gdbm_src.oid2Docnum(doc_id); 173 System.out.println("mg doc num = "+doc_num); 172 String doc_num = this.database.OID2MGNum(doc_id); 174 173 // doc nums have the index prefixed 175 174 doc_num = doc_num.substring(doc_num.indexOf(".")+1); 176 175 int doc_int = Integer.parseInt(doc_num); 177 System.out.println("actual mg doc num="+doc_int);176 178 177 String doc_content = ""; 179 178 try { 180 179 doc_content = this.mg_src.getDocument(basedir, textdir, doc_int); 181 180 } catch (Exception e) { 182 183 181 System.out.println("exception happended with mg_src.getDocument()"); 182 doc_content = "this is the content for section hash id "+ doc_id+", mg doc num "+doc_int+"\n"; 184 183 } 185 184 //ystem.out.println("Doc content: " + doc_content + "|"); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGSearch.java
r7312 r8439 144 144 // hack !!! 145 145 if (doc_id.endsWith("-All")) { 146 System.err.print("replacing doc id "+doc_id+" with ");147 doc_id =doc_id.replaceAll("All","1");148 System.err.println(doc_id);146 // get rid of the All bit 147 doc_id = doc_id.substring(0,doc_id.length()-4); 148 //doc_id=doc_id.replaceAll("All","1"); 149 149 } 150 150 151 //String doc_id = this.gdbm_src.docnum2Oid(docnum);152 151 Element doc_node = createDocumentNodeElement(doc_id); 153 152 document_list.appendChild(doc_node); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Retrieve.java
r7312 r8439 313 313 * child is true is it definitely is a child of something - just for efficiency purposes */ 314 314 protected Element createDocNode(String node_id, boolean parent, boolean child) { 315 // Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM);316 // node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");317 // node.setAttribute(GSXML.NODE_ID_ATT, node_id);318 // return node;319 315 320 316 Element node; 321 317 if (isClassifier(node_id)) { 322 318 node = this.doc.createElement(GSXML.CLASS_NODE_ELEM); 319 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 320 return node; 321 323 322 //String childtype = info.getInfo("childtype"); 324 323 //String orientation=""; … … 329 328 //} 330 329 //node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation); 330 } 331 // a doc node 332 node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 333 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 334 boolean hierarchical = false; 335 if (parent || child || !GS3OID.isDocTop(node_id) || database.isHierarchicalDocument(node_id) ) { 336 hierarchical = true; 337 } 338 // what about paged??? 339 if (!hierarchical) { 340 // a simple document 341 node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 331 342 } else { 332 333 node = this.doc.createElement(GSXML.DOC_NODE_ELEM);334 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); // need to work this out dynamically335 336 if ( GS3OID.isTop(node_id)) {343 // a hierarchical doc 344 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 345 346 347 if (!child && GS3OID.isTop(node_id)) { 337 348 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 338 } else if ( database.documentHasChildren(node_id)){349 } else if (parent || database.documentHasChildren(node_id)){ 339 350 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 340 351 } else { 341 352 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 342 353 } 343 // String top_id = GS3OID.getTop(node_id); 344 // boolean is_top = (top_id.equals(node_id) ? true : false); 345 346 // String children = info.getInfo("contains"); 347 // boolean is_leaf = (children.equals("") ? true : false); 348 349 // // set teh node type att 350 // if (is_top) { 351 // node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 352 // } else if (is_leaf) { 353 // node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 354 // } else { 355 // node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 356 // } 357 358 // // set teh doc type att 359 // if (is_top && is_leaf) { // a single section document 360 // node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 361 362 // } else { 363 364 // if (!is_top) { // we need to look at the top info 365 // info = this.gdbm_src.getInfo(top_id); 366 // } 367 368 // String childtype = info.getInfo("childtype"); 369 // if (childtype.equals("Paged")) { 370 // node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 371 // } else { 372 // node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 373 // } 374 // } 375 376 } 377 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 354 } 378 355 return node; 379 380 }356 } 357 381 358 /** Returns the parent of a specified documentID, or null if none exists */ 382 359 protected Element getParent(String doc_id) … … 414 391 for (int i=0; i<documents.size(); i++) { 415 392 String child_id = (String) documents.get(i); 416 Element child = createDocNode(child_id, false, true);393 Element child = createDocNode(child_id, false, false); 417 394 doc.appendChild(child); 418 395 } … … 577 554 doc_id = GS3OID.translateOID(doc_id); 578 555 } 556 // this doesn't work for single section docs 557 // but we shouldn't be asking for structure from them 579 558 if (type==DOCUMENT && GS3OID.isDocTop(doc_id)) { 580 doc_id = GS3OID.createOID(doc_id, "1");559 doc_id = GS3OID.createOID(doc_id, "1"); 581 560 } 582 561 // Add the document to the list … … 715 694 param = (Element) param.getNextSibling(); 716 695 } 717 718 696 Element node_list = this.doc.createElement(node_name+GSXML.LIST_MODIFIER); 719 697 result.appendChild(node_list); … … 724 702 System.err.println("Error: DocumentMetadataRetrieve request had no "+node_name+"List.\n"); 725 703 return result; 726 } 727 704 } 705 728 706 NodeList request_nodes = request_node_list.getChildNodes(); 729 707 for (int i = 0; i < request_nodes.getLength(); i++) { 730 708 Element request_node = (Element) request_nodes.item(i); 731 709 String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 732 733 710 if (GS3OID.needsTranslating(node_id)) { 734 711 //node_id = this.gdbm_src.translateOID(node_id); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Search.java
r7993 r8439 271 271 Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 272 272 doc_node.setAttribute(GSXML.NODE_ID_ATT, node_id); 273 274 String top_id = OID.getTop(node_id); 275 boolean is_top = (top_id.equals(node_id) ? true : false); 276 277 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 278 279 if (GS3OID.isTop(node_id)) { 280 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 281 } else if (database.documentHasChildren(node_id)){ 282 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 273 274 if (GS3OID.isDocTop(node_id) && !database.isHierarchicalDocument(node_id) ) { 275 // a simple document 276 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 283 277 } else { 284 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 278 // what about paged?? 279 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 280 281 if (GS3OID.isTop(node_id)) { 282 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 283 } else if (database.documentHasChildren(node_id)){ 284 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 285 } else { 286 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 287 } 285 288 } 286 289 287 290 return doc_node; 288 291 } 289 // DBInfo info = this.gdbm_src.getInfo(node_id);290 // if (info == null) { // make it up - cant query the gdbm db291 // doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");292 // return doc_node;293 // }294 // String children = info.getInfo("contains");295 // boolean is_leaf = (children.equals("") ? true : false);296 297 // // check for simple doc types298 // if (is_top && is_leaf) { // a single section document299 // doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");300 // return doc_node;301 // }302 // // set teh node type att303 // if (is_top) {304 // doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);305 // } else if (is_leaf) {306 // doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);307 // } else {308 // doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR);309 // }310 311 // if (!is_top) { // we need to look at the top info312 // info = this.gdbm_src.getInfo(top_id);313 // }314 315 // String childtype = info.getInfo("childtype");316 // if (childtype.equals("Paged")) {317 // doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "paged");318 // } else {319 // doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy");320 // }321 // return doc_node;322 // }323 324 /** returns the document type of a node - if the node is a subnode, it returns teh type of teh top document node. for now, only does paged and hierarchical, but eventually will have more types */325 // protected String getDocType(String node_id) {326 327 // String doc_id = OID.getTop(node_id);328 // DBInfo info = this.gdbm_src.getInfo(doc_id);329 // String child_type = info.getInfo("childtype");330 // if (child_type.equals("Paged")) {331 // return "paged";332 // }333 // return "hierarchy";334 335 // }336 337 /** Returns true if the OID specifies a leaf node, false otherwise338 Note: this makes a request to the GDBM database so it may not be cheap */339 // protected boolean isLeafNode(String oid)340 // {341 // DBInfo info = this.gdbm_src.getInfo(oid);342 // String children = info.getInfo("contains");343 // return (children.equals(""));344 // }345 346 292 347 293 /** Process a text query - implemented by concrete subclasses */
Note:
See TracChangeset
for help on using the changeset viewer.