Ignore:
Timestamp:
2011-08-12T16:40:17+12:00 (13 years ago)
Author:
davidb
Message:

Latest round of changes to code, in preparing for demo to Goldsmiths

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  
    3838import org.apache.log4j.*;
    3939
    40 public class GS2AudioDBSearch extends AbstractGS2Search {
     40public class GS2AudioDBSearch extends AbstractGS2AudioSearch {
    4141
    4242    static Logger logger = Logger.getLogger (org.greenstone.gsdl3.service.GS2AudioDBSearch.class.getName ());
     
    4848
    4949    protected static final String AUDIODB_DEFAULT_DIRECTORY = "audioDB";
    50     protected static final String ADB_FILENAME = "lhs-features.adb";
     50    protected static final String ADB_FILENAME = "lsh-features.adb";
    5151   
    5252    protected AudioDBWrapper audiodb_src = null;
     
    6060   
    6161     /** do the actual query */
    62     protected Element processTextQuery (Element request) {
     62    protected Element processAudioQuery (Element request) {
    6363    // MG needs to be synchronized (this inspiration for this class)
    6464    // Since it is not known how concurrent audioDB can be, play it safe for
     
    6868        // Create a new (empty) result message ('doc' is in ServiceRack.java)
    6969        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");
    7174        result.setAttribute (GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
    7275       
     
    7477        Element param_list = (Element) GSXML.getChildByTagName (request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    7578        if (param_list == null) {
    76         logger.error ("AudioDB TextQuery request had no paramList.");
     79        logger.error ("AudioDB AudioQuery request had no paramList.");
    7780        return result;  // Return the empty result
    7881        }
     
    8689        return result;  // Return the empty result
    8790        }
    88        
     91
    8992        // If an index hasn't been specified, use the default
    9093        String index = (String) params.get (INDEX_PARAM);
     
    9497       
    9598        // 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
    98103        // set the audioDB query parameters to the values the user has specified
    99104        setStandardQueryParams (params);
    100105       
    101         this.audiodb_src.runQuery (index_dir, ADB_FILENAME, query);
     106        this.audiodb_src.runQuery (audioDB_index_dir, ADB_FILENAME, assoc_index_dir, query);
    102107        Vector docs = this.audiodb_src.getQueryResult ();
    103108
    104109        if (docs.isEmpty()) {
    105110        // something has gone wrong
    106         GSXML.addError (this.doc, result, "Couldn't query the mg database", GSXML.ERROR_TYPE_SYSTEM);
     111        GSXML.addError (this.doc, result, "Couldn't query the audioDB database", GSXML.ERROR_TYPE_SYSTEM);
    107112        return result;
    108113        }
     
    129134        result.appendChild (document_list);
    130135        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
    134145            document_list.appendChild (doc_node);
    135146        }
Note: See TracChangeset for help on using the changeset viewer.