Changeset 15836
- Timestamp:
- 2008-05-30T16:00:47+12:00 (16 years ago)
- Location:
- gsdl/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/lib/sqldbclass.h
r15803 r15836 44 44 // returns array of document OIDs 45 45 virtual text_tarray get_documents_with_metadata_value (const text_t &metadata_element_name, 46 const text_t &metadata_value) = 0; 46 const text_t &metadata_value, 47 const text_t &sort_by_metadata_element_name) = 0; 47 48 48 49 // returns array of values -
gsdl/trunk/lib/sqlitedbclass.cpp
r15811 r15836 100 100 // returns array of document OIDs 101 101 text_tarray sqlitedbclass::get_documents_with_metadata_value (const text_t &metadata_element_name, 102 const text_t &metadata_value) 102 const text_t &metadata_value, 103 const text_t &sort_by_metadata_element_name) 103 104 { 104 105 text_tarray document_OIDs; … … 111 112 112 113 // Get the entries in the "document_metadata" table where the element and value matches those specified 113 text_t sql_cmd = "SELECT docOID FROM document_metadata WHERE element='" + metadata_element_name + "' AND value='" + metadata_value + "'"; 114 text_t sql_cmd; 115 if (sort_by_metadata_element_name == "") 116 { 117 // No sorting required 118 sql_cmd = "SELECT docOID FROM document_metadata WHERE element='" + metadata_element_name + "' AND value='" + metadata_value + "'"; 119 } 120 else 121 { 122 // Sort the documents by a certain metadata element 123 // John Thompson thinks this may not be the most efficient solution, and recommends using ON instead of WHERE 124 sql_cmd = "SELECT b.docOID FROM document_metadata AS a LEFT JOIN document_metadata AS b USING (docOID) WHERE a.element='" + metadata_element_name + "' AND a.value='" + metadata_value + "' AND b.element='" + sort_by_metadata_element_name + "' ORDER BY b.value"; 125 } 114 126 vector<text_tmap> sql_results; 115 127 if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) -
gsdl/trunk/lib/sqlitedbclass.h
r15803 r15836 47 47 // returns array of document OIDs 48 48 text_tarray get_documents_with_metadata_value (const text_t &metadata_element_name, 49 const text_t &metadata_value); 49 const text_t &metadata_value, 50 const text_t &sort_by_metadata_element_name); 50 51 51 52 // returns file extension string -
gsdl/trunk/src/colservr/sqlbrowsefilter.cpp
r15804 r15836 160 160 text_t metadata_element_name = ""; 161 161 text_t metadata_value = ""; 162 text_t sort_by_metadata_element_name = ""; 162 163 OptionValue_tarray::const_iterator options_iterator = request.filterOptions.begin(); 163 164 while (options_iterator != request.filterOptions.end()) … … 171 172 metadata_value = (*options_iterator).value; 172 173 } 174 if ((*options_iterator).name == "SortByMetadataElement") 175 { 176 sort_by_metadata_element_name = (*options_iterator).value; 177 } 173 178 options_iterator++; 174 179 } 175 180 176 text_tarray document_OIDs = sql_db_ptr->get_documents_with_metadata_value (metadata_element_name, metadata_value );181 text_tarray document_OIDs = sql_db_ptr->get_documents_with_metadata_value (metadata_element_name, metadata_value, sort_by_metadata_element_name); 177 182 178 183 // Fill in response.docInfo with the document OIDs -
gsdl/trunk/src/protocol/recptprototools.cpp
r15806 r15836 284 284 285 285 286 bool get_documents_with_metadata_value (const text_t metadata_element_name, const text_t metadata_value, 287 const text_t &collection, recptproto *collectproto,288 FilterResponse_t &response, ostream &logout)286 bool get_documents_with_metadata_value (const text_t metadata_element_name, const text_t metadata_value, 287 const text_t sort_by_metadata_element_name, const text_t &collection, 288 recptproto *collectproto, FilterResponse_t &response, ostream &logout) 289 289 { 290 290 response.clear(); … … 304 304 request_option.value = metadata_value; 305 305 request.filterOptions.push_back (request_option); 306 request_option.name = "SortByMetadataElement"; 307 request_option.value = sort_by_metadata_element_name; 308 request.filterOptions.push_back (request_option); 306 309 307 310 assert (collectproto != NULL); -
gsdl/trunk/src/protocol/recptprototools.h
r15806 r15836 71 71 recptproto *collectproto, FilterResponse_t &response, ostream &logout); 72 72 73 bool get_documents_with_metadata_value (const text_t metadata_element_name, const text_t metadata_value, 74 const text_t &collection, recptproto *collectproto,75 FilterResponse_t &response, ostream &logout);73 bool get_documents_with_metadata_value (const text_t metadata_element_name, const text_t metadata_value, 74 const text_t sort_by_metadata_element_name, const text_t &collection, 75 recptproto *collectproto, FilterResponse_t &response, ostream &logout); 76 76 77 77 #endif -
gsdl/trunk/src/recpt/dynamicclassifieraction.cpp
r15834 r15836 168 168 text_t metadata_value = arg_dcn; 169 169 FilterResponse_t document_OIDs_response; 170 get_documents_with_metadata_value (metadata_element_name, metadata_value, args["c"], collectproto, document_OIDs_response, logout);170 get_documents_with_metadata_value (metadata_element_name, metadata_value, "dls.Title", args["c"], collectproto, document_OIDs_response, logout); 171 171 172 172 // Check the metadata value is valid
Note:
See TracChangeset
for help on using the changeset viewer.