- Timestamp:
- 2011-08-12T16:40:17+12:00 (13 years ago)
- Location:
- gs3-extensions/audioDB/trunk/src/src/java/org/greenstone/gsdl3/service
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/audioDB/trunk/src/src/java/org/greenstone/gsdl3/service/GS2AudioDBSearch.java
r24352 r24398 38 38 import org.apache.log4j.*; 39 39 40 public class GS2AudioDBSearch extends AbstractGS2 Search {40 public class GS2AudioDBSearch extends AbstractGS2AudioSearch { 41 41 42 42 static Logger logger = Logger.getLogger (org.greenstone.gsdl3.service.GS2AudioDBSearch.class.getName ()); … … 48 48 49 49 protected static final String AUDIODB_DEFAULT_DIRECTORY = "audioDB"; 50 protected static final String ADB_FILENAME = "l hs-features.adb";50 protected static final String ADB_FILENAME = "lsh-features.adb"; 51 51 52 52 protected AudioDBWrapper audiodb_src = null; … … 60 60 61 61 /** do the actual query */ 62 protected Element process TextQuery (Element request) {62 protected Element processAudioQuery (Element request) { 63 63 // MG needs to be synchronized (this inspiration for this class) 64 64 // Since it is not known how concurrent audioDB can be, play it safe for … … 68 68 // Create a new (empty) result message ('doc' is in ServiceRack.java) 69 69 Element result = this.doc.createElement (GSXML.RESPONSE_ELEM); 70 result.setAttribute (GSXML.FROM_ATT, TEXT_QUERY_SERVICE); // Result looks the same as a text query 70 71 // Rather than QUERY_SERVICE use "TextQuery" 72 // => makes the result looks the same as a text query 73 result.setAttribute (GSXML.FROM_ATT, "TextQuery"); 71 74 result.setAttribute (GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 72 75 … … 74 77 Element param_list = (Element) GSXML.getChildByTagName (request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 75 78 if (param_list == null) { 76 logger.error ("AudioDB TextQuery request had no paramList.");79 logger.error ("AudioDB AudioQuery request had no paramList."); 77 80 return result; // Return the empty result 78 81 } … … 86 89 return result; // Return the empty result 87 90 } 88 91 89 92 // If an index hasn't been specified, use the default 90 93 String index = (String) params.get (INDEX_PARAM); … … 94 97 95 98 // The location of the audioDB index 96 String index_dir = GSFile.collectionIndexDir (this.site_home, this.cluster_name) + File.separatorChar + index; 97 99 String toplevel_index_dir = GSFile.collectionIndexDir (this.site_home, this.cluster_name); 100 String audioDB_index_dir = toplevel_index_dir + File.separatorChar + index; 101 String assoc_index_dir = toplevel_index_dir + File.separatorChar + "assoc"; 102 98 103 // set the audioDB query parameters to the values the user has specified 99 104 setStandardQueryParams (params); 100 105 101 this.audiodb_src.runQuery ( index_dir, ADB_FILENAME, query);106 this.audiodb_src.runQuery (audioDB_index_dir, ADB_FILENAME, assoc_index_dir, query); 102 107 Vector docs = this.audiodb_src.getQueryResult (); 103 108 104 109 if (docs.isEmpty()) { 105 110 // something has gone wrong 106 GSXML.addError (this.doc, result, "Couldn't query the mgdatabase", GSXML.ERROR_TYPE_SYSTEM);111 GSXML.addError (this.doc, result, "Couldn't query the audioDB database", GSXML.ERROR_TYPE_SYSTEM); 107 112 return result; 108 113 } … … 129 134 result.appendChild (document_list); 130 135 for (int d = 0; d < docs.size (); d++) { 131 String doc_id = ((AudioDBDocInfo) docs.elementAt (d)).oid_; 132 float rank = ((AudioDBDocInfo) docs.elementAt (d)).rank_; 133 Element doc_node = createDocNode (doc_id, Float.toString (rank)); 136 AudioDBDocInfo adb_doc = (AudioDBDocInfo) docs.elementAt(d); 137 138 String doc_id = adb_doc.getDocID(); 139 double rank = adb_doc.getTopRank(); 140 String offsets = adb_doc.getOffsetList(); 141 142 Element doc_node = createDocNode (doc_id, Double.toString (rank)); 143 doc_node.setAttribute("frameOffset", offsets); 144 134 145 document_list.appendChild (doc_node); 135 146 }
Note:
See TracChangeset
for help on using the changeset viewer.