Changeset 7312
- Timestamp:
- 2004-05-12T14:04:09+12: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
r6517 r7312 31 31 32 32 33 /** 33 /** The content retrieval class for GS3 building 34 34 * 35 35 * @author <a href="mailto:[email protected]">Katherine Don</a> … … 38 38 39 39 public class GS3MGRetrieve 40 extends GS3Retrieve { 41 40 extends ServiceRack { 41 // the services on offer 42 protected static final String DOCUMENT_CONTENT_RETRIEVE_SERVICE = "DocumentContentRetrieve"; 43 42 44 // Parameters used 43 45 private static final String INDEX_PARAM = "index"; … … 47 49 48 50 private MGWrapper mg_src = null; 51 protected SQLQuery database = null; 52 53 protected Element config_info = null; // the xml from the config file 49 54 50 55 private String default_index = null; 51 52 56 53 57 /** constructor */ 54 58 public GS3MGRetrieve() 55 59 { 60 this.database = new SQLQuery(); 56 61 this.mg_src = new MGWrapper(); 57 62 } … … 61 66 public boolean configure(Element info, Element extra_info) 62 67 { 68 this.config_info = info; 63 69 // Do specific configuration 64 70 System.out.println("Configuring GS3MGRetrieve..."); … … 75 81 return false; 76 82 } 83 77 84 // System.out.println("Default index: " + this.default_index); 78 79 // Do generic configuration 80 return super.configure(info, extra_info); 81 } 82 83 85 Element dcr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 86 dcr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 87 dcr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE); 88 this.short_service_info.appendChild(dcr_service); 89 90 // check that site_home is set 91 if (this.site_home == null || this.site_home.equals("")) { 92 System.err.println("GS3Retrieve Error: site_home is not set, so cannot work out the site name and cannot determine the database name"); 93 return false; 94 } 95 String site_name = this.site_home.substring(this.site_home.lastIndexOf(File.separator)+1); 96 if (site_name.equals("")) { 97 System.err.println("GS3Retrieve Error: Cannot extract the site name from site home: "+this.site_home); 98 return false; 99 } 100 if (!database.setDatabase(site_name+"_"+this.cluster_name)) { 101 System.err.println("GS3Retrieve Error: Could not open SQL database!"); 102 return false; 103 } 104 105 // look for document display format 106 String path = GSPath.appendLink(GSXML.DISPLAY_ELEM, GSXML.FORMAT_ELEM); 107 Element display_format = (Element)GSXML.getNodeByPath(extra_info, path); 108 if (display_format != null) { 109 this.format_info_map.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, this.doc.importNode(display_format, true)); 110 // should we make a copy? 111 } 112 113 return true; 114 } 115 116 protected Element getServiceDescription(String service_id, String lang, String subset) { 117 if (service_id.equals(DOCUMENT_CONTENT_RETRIEVE_SERVICE)) { 118 Element dcr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 119 dcr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 120 dcr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE); 121 return dcr_service; 122 } 123 124 return null; 125 } 84 126 /** Retrieve the content of a document */ 85 127 protected Element processDocumentContentRetrieve(Element request) … … 117 159 //ystem.out.println("getting doc id "+doc_ids[i]); 118 160 String doc_id = doc_ids[i]; 119 if ( OID.needsTranslating(doc_id)) {161 if (GS3OID.needsTranslating(doc_id)) { 120 162 //doc_id = this.gdbm_src.translateOID(doc_id); 121 doc_id = translateOID(doc_id);163 doc_id = GS3OID.translateOID(doc_id); 122 164 //ystem.out.println("translated id = "+doc_id); 123 165 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGSearch.java
r6517 r7312 49 49 50 50 private MGWrapper mg_src = null; 51 52 51 53 52 /** constructor */ … … 140 139 for (int d = 0; d < docs.size(); d++) { 141 140 long docnum = ((MGDocInfo) docs.elementAt(d)).num_; 142 String mg_id = index+"."+docnum; 141 ////String mg_id = index+"."+docnum; 142 String mg_id = this.base_index_prefix+"."+docnum; 143 143 String doc_id = database.MGNum2OID(mg_id); 144 // hack !!! 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); 149 } 150 144 151 //String doc_id = this.gdbm_src.docnum2Oid(docnum); 145 152 Element doc_node = createDocumentNodeElement(doc_id); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Retrieve.java
r6871 r7312 37 37 import java.util.ArrayList; 38 38 39 /** Implements the generic retrieval and classifier services for GS339 /** Implements the generic structure and metadata retrieval and classifier services for GS3 40 40 * collections. 41 41 * … … 45 45 */ 46 46 47 public abstractclass GS3Retrieve47 public class GS3Retrieve 48 48 extends ServiceRack { 49 49 … … 52 52 protected static final String DOCUMENT_STRUCTURE_RETRIEVE_SERVICE = "DocumentStructureRetrieve"; 53 53 protected static final String DOCUMENT_METADATA_RETRIEVE_SERVICE = "DocumentMetadataRetrieve"; 54 protected static final String DOCUMENT_CONTENT_RETRIEVE_SERVICE = "DocumentContentRetrieve";55 56 54 57 55 // the browsing services - now in here, these will only be advertised if classifiers have been specified in the config file … … 76 74 protected static final int CLASSIFIER=2; 77 75 78 //protected GDBMWrapper gdbm_src = null;79 76 protected SQLQuery database = null; 80 77 … … 82 79 83 80 /** constructor */ 84 p rotectedGS3Retrieve()81 public GS3Retrieve() 85 82 { 86 //this.gdbm_src = new GDBMWrapper();87 83 this.database = new SQLQuery(); 88 84 } … … 105 101 dmr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE); 106 102 this.short_service_info.appendChild(dmr_service); 107 108 Element dcr_service = this.doc.createElement(GSXML.SERVICE_ELEM);109 dcr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);110 dcr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE);111 this.short_service_info.appendChild(dcr_service);112 103 113 104 // open the database for querying … … 186 177 } 187 178 188 // look for document display format189 String path = GSPath.appendLink(GSXML.DISPLAY_ELEM, GSXML.FORMAT_ELEM);190 Element display_format = (Element)GSXML.getNodeByPath(extra_info, path);191 if (display_format != null) {192 this.format_info_map.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, this.doc.importNode(display_format, true));193 // should we make a copy?194 }195 179 return true; 196 180 } … … 272 256 dmr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE); 273 257 return dmr_service; 274 }275 276 if (service_id.equals(DOCUMENT_CONTENT_RETRIEVE_SERVICE)) {277 Element dcr_service = this.doc.createElement(GSXML.SERVICE_ELEM);278 dcr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE);279 dcr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE);280 return dcr_service;281 258 } 282 259 … … 598 575 599 576 if (GS3OID.needsTranslating(doc_id)) { 600 doc_id = translateOID(doc_id);577 doc_id = GS3OID.translateOID(doc_id); 601 578 } 602 579 if (type==DOCUMENT && GS3OID.isDocTop(doc_id)) { … … 756 733 if (GS3OID.needsTranslating(node_id)) { 757 734 //node_id = this.gdbm_src.translateOID(node_id); 758 node_id = translateOID(node_id);735 node_id = GS3OID.translateOID(node_id); 759 736 } 760 737 … … 866 843 // } 867 844 868 /** Retrieve the content of a document - implemented by concrete subclasses */869 protected abstract Element processDocumentContentRetrieve(Element request);870 845 871 846 /** needs to get info from gdbm database - if the calling code gets it already it may pay to pass it in instead */ … … 930 905 // } 931 906 932 protected String translateOID(String oid) {933 934 int p = oid.lastIndexOf('.');935 if (p != oid.length()-3) {936 System.out.println("translateoid error: '.' is not the third to last char!!");937 return oid;938 }939 940 String top = oid.substring(0, p);941 String suff = oid.substring(p+1);942 if (suff.equals("pr")) {943 return GS3OID.getParent(top);944 } else if (suff.equals("rt")) {945 return GS3OID.getTop(top);946 }947 return oid;948 949 }950 907 951 908 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Search.java
r6871 r7312 32 32 /** 33 33 * 34 * @author <a href="mailto:[email protected]">Michael Dewsnip</a>34 * @author Katherine Don 35 35 * @version $Revision$ 36 36 */ … … 74 74 /** the default index */ 75 75 protected String default_index = null; 76 76 /** the base index prefix */ 77 protected String base_index_prefix = null; 77 78 78 79 /** constructor */ … … 80 81 { 81 82 this.database = new SQLQuery(); 82 //this.gdbm_src = new GDBMWrapper();83 83 } 84 84 … … 101 101 } 102 102 103 // get the base prefix 104 def = (Element) GSXML.getChildByTagName(info, "baseIndexPrefix"); 105 if (def != null) { 106 this.base_index_prefix = def.getAttribute(GSXML.NAME_ATT); 107 } 108 if (this.base_index_prefix == null || this.base_index_prefix.equals("")) { 109 System.err.println("Error: base index prefix not specified!"); 110 return false; 111 } 103 112 // these entries should reflect the build config file - some services may not be available depending on how the collection was built. 104 113 // set up short_service_info_ - for now just has id and type. the name (lang dependent) will be added in if the list is requested. … … 108 117 this.short_service_info.appendChild(tq_service); 109 118 110 111 // Open GDBM database for querying112 //String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name);113 //if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {114 // System.err.println("Error: Could not open GDBM database!");115 // return false;116 //}117 119 // open the database for querying 118 120 // the database name is a combination of site name and collection name
Note:
See TracChangeset
for help on using the changeset viewer.