Changeset 15803 for gsdl


Ignore:
Timestamp:
2008-05-29T15:52:50+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding dynamic classifiers) Added new get_documents_with_metadata_value() function, for use by the dynamic classifiers.

Location:
gsdl/trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/lib/sqldbclass.h

    r15796 r15803  
    4242  // These functions MUST be implemented by subclasses, as they are database-specific
    4343
     44  // returns array of document OIDs
     45  virtual text_tarray get_documents_with_metadata_value (const text_t &metadata_element_name,
     46                             const text_t &metadata_value) = 0;
     47
    4448  // returns array of values
    4549  virtual text_tarray get_metadata_values (const text_t &metadata_element_name) = 0;
  • gsdl/trunk/lib/sqlitedbclass.cpp

    r15800 r15803  
    9797
    9898
     99// returns array of document OIDs
     100text_tarray sqlitedbclass::get_documents_with_metadata_value (const text_t &metadata_element_name,
     101                                  const text_t &metadata_value)
     102{
     103  text_tarray document_OIDs;
     104
     105  // Check a metadata element and value has been specified
     106  if (metadata_element_name == "" || metadata_value == "")
     107  {
     108    return document_OIDs;
     109  }
     110
     111  // Get the entries in the "document_metadata" table where the element and value matches those specified
     112  text_t sql_cmd = "SELECT docOID FROM document_metadata WHERE element='" + metadata_element_name + "' AND value='" + metadata_value + "'";
     113  vector<text_tmap> sql_results;
     114  if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0)
     115  {
     116    return document_OIDs;
     117  }
     118
     119  // Iterate through the documents and add them to the array to be returned
     120  vector<text_tmap>::iterator sql_results_iterator = sql_results.begin();
     121  while (sql_results_iterator != sql_results.end())
     122  {
     123    text_tmap sql_result = (*sql_results_iterator);
     124    document_OIDs.push_back(sql_result["docOID"]);
     125    sql_results_iterator++;
     126  }
     127
     128  return document_OIDs;
     129}
     130
     131
    99132// returns file extension string
    100133text_t sqlitedbclass::getfileextension ()
     
    157190  }
    158191
    159   // Get the entries in the "value" column of the "document_metadata" table where the element matches
     192  // Get the entries in the "document_metadata" table where the element matches that specified
    160193  text_t sql_cmd = "SELECT value FROM document_metadata WHERE element='" + metadata_element_name + "'";
    161194  vector<text_tmap> sql_results;
  • gsdl/trunk/lib/sqlitedbclass.h

    r15796 r15803  
    4545  void deletekey (const text_t &key);
    4646
     47  // returns array of document OIDs
     48  text_tarray get_documents_with_metadata_value (const text_t &metadata_element_name,
     49                         const text_t &metadata_value);
     50
    4751  // returns file extension string
    4852  text_t getfileextension ();
Note: See TracChangeset for help on using the changeset viewer.