Changeset 16057
- Timestamp:
- 2008-06-18T17:02:18+12:00 (16 years ago)
- Location:
- gsdl/trunk/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/src/recpt/dynamicclassifieraction.cpp
r16056 r16057 165 165 } 166 166 167 // Simple case for the top-level nodes 167 // Prepare to output the classifier (and maybe document) nodes 168 text_t classifier_node_OID = args["dcn"]; 169 int classifier_node_indent = 0; 170 171 // Simple case at the top level: just output the child classifier nodes 168 172 if (args["dcn"] == selected_grouping_node_OID) 169 173 { 170 text_t classifier_node_OID = args["dcn"]; 174 text_t metadata_value_filter = args["dcn"] + "*"; 175 output_child_classifier_nodes (classifier_node_OID, metadata_value_filter, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 176 } 177 178 // More complex case below the top level 179 else 180 { 181 // Output the parent classifier nodes 182 output_parent_classifier_nodes (classifier_node_OID, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 183 184 // Display the selected classifier node 185 text_tarray classifier_node_labels; 186 splitchar(classifier_node_OID.begin(), classifier_node_OID.end(), '|', classifier_node_labels); 187 text_t classifier_node_label = classifier_node_labels.back(); 188 text_t classifier_node_numleafdocs = "?"; 189 display_classifier_node (classifier_node_OID, classifier_node_label, classifier_node_numleafdocs, classifier_node_indent, args, collectproto, browsers, disp, outconvert, textout, logout); 190 classifier_node_indent++; 191 192 // Output the child classifier nodes 193 text_t metadata_value_filter = args["dcn"] + "|*"; 194 output_child_classifier_nodes (classifier_node_OID, metadata_value_filter, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 195 196 // Get the document nodes at this level 197 text_t metadata_element_name = classifier_options["metadata_element_name"]; 171 198 text_t classifier_node_metadata_value = args["dcn"]; 172 int classifier_node_indent = 0; 173 output_top_level_node (classifier_node_OID, classifier_node_metadata_value, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 174 } 175 else 176 { 177 // More complex case for an internal page 178 text_t classifier_node_OID = args["dcn"]; 179 text_t classifier_node_metadata_value = args["dcn"]; 180 int classifier_node_indent = 0; 181 output_internal_node (classifier_node_OID, classifier_node_metadata_value, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 199 text_t sort_documents_by = classifier_options["-sort_documents_by"]; 200 FilterResponse_t documents_response; 201 get_documents_with_metadata_value (metadata_element_name, classifier_node_metadata_value, sort_documents_by, args["c"], collectproto, documents_response, logout); 202 203 // Display the document nodes 204 display_document_nodes (documents_response, classifier_node_indent, args, collectproto, browsers, disp, outconvert, textout, logout); 182 205 } 183 206 … … 298 321 299 322 300 void dynamicclassifieraction::output_top_level_node (text_t classifier_node_OID, 301 text_t classifier_node_metadata_value, 302 int& classifier_node_indent, 303 text_tmap classifier_options, cgiargsclass &args, 304 recptproto *collectproto, browsermapclass *browsers, 305 displayclass &disp, outconvertclass &outconvert, 306 ostream &textout, ostream &logout) 307 { 308 // Get all the metadata values for the specified element that match the filter 309 text_t metadata_element_name = classifier_options["metadata_element_name"]; 310 text_t metadata_value_filter = classifier_node_metadata_value + "*"; 311 FilterResponse_t metadata_values_response; 312 bool request_success = get_metadata_values (metadata_element_name, metadata_value_filter, "", args["c"], collectproto, metadata_values_response, logout); 313 314 // If the request failed then it's probably because the collection isn't using an SQL infodbtype 315 if (request_success == false) 316 { 317 textout << outconvert << disp << "Error: Dynamic classifier functionality is not available. Please check you are using an SQL infodbtype and the collection has been rebuilt.\n"; 318 return; 319 } 320 321 // After processing any hierarchical metadata values, we're left with the child classifer nodes 322 map<text_t, int, lttext_t> child_classifier_nodes = process_metadata_values (classifier_options, metadata_values_response.docInfo); 323 324 // Display the child classifier nodes 325 map<text_t, int, lttext_t>::iterator child_classifier_nodes_iterator = child_classifier_nodes.begin(); 326 while (child_classifier_nodes_iterator != child_classifier_nodes.end()) 327 { 328 text_t child_classifier_node_OID = (*child_classifier_nodes_iterator).first; 329 if (classifier_node_OID != "") 330 { 331 child_classifier_node_OID = classifier_node_OID + "|" + child_classifier_node_OID; 332 } 333 text_t child_classifier_node_label = (*child_classifier_nodes_iterator).first; 334 int child_classifier_node_numleafdocs = (*child_classifier_nodes_iterator).second; 335 display_classifier_node (child_classifier_node_OID, child_classifier_node_label, child_classifier_node_numleafdocs, classifier_node_indent, args, collectproto, browsers, disp, outconvert, textout, logout); 336 child_classifier_nodes_iterator++; 337 } 338 } 339 340 341 void dynamicclassifieraction::output_internal_node (text_t classifier_node_OID, 342 text_t classifier_node_metadata_value, 343 int& classifier_node_indent, 344 text_tmap classifier_options, cgiargsclass &args, 345 recptproto *collectproto, browsermapclass *browsers, 346 displayclass &disp, outconvertclass &outconvert, 347 ostream &textout, ostream &logout) 348 { 349 // Get all the classifier nodes at this level 350 text_t metadata_element_name = classifier_options["metadata_element_name"]; 351 text_t metadata_value_filter = classifier_node_metadata_value + "|*"; 352 FilterResponse_t metadata_values_response; 353 bool request_success = get_metadata_values (metadata_element_name, metadata_value_filter, "", args["c"], collectproto, metadata_values_response, logout); 354 355 // If the request failed then it's probably because the collection isn't using an SQL infodbtype 356 if (request_success == false) 357 { 358 textout << outconvert << disp << "Error: Dynamic classifier functionality is not available. Please check you are using an SQL infodbtype and the collection has been rebuilt.\n"; 359 return; 360 } 361 362 // Get all the documents at this level 363 text_t sort_documents_by = classifier_options["-sort_documents_by"]; 364 FilterResponse_t documents_response; 365 get_documents_with_metadata_value (metadata_element_name, classifier_node_metadata_value, sort_documents_by, args["c"], collectproto, documents_response, logout); 366 367 // If there are no classifier nodes or documents at this level then the classifier node value is invalid 368 if (metadata_values_response.docInfo.empty() && documents_response.docInfo.empty()) 369 { 370 textout << outconvert << disp << "Error: Invalid classifier node \"" << classifier_node_OID << "\".\n"; 371 return; 372 } 373 323 void dynamicclassifieraction::output_parent_classifier_nodes (text_t classifier_node_OID, 324 int& classifier_node_indent, 325 text_tmap classifier_options, cgiargsclass &args, 326 recptproto *collectproto, browsermapclass *browsers, 327 displayclass &disp, outconvertclass &outconvert, 328 ostream &textout, ostream &logout) 329 { 374 330 // Determine the parent classifier nodes 375 331 text_tarray parent_classifier_node_labels; 376 332 splitchar(classifier_node_OID.begin(), classifier_node_OID.end(), '|', parent_classifier_node_labels); 377 text_t classifier_node_label = parent_classifier_node_labels.back();378 333 parent_classifier_node_labels.pop_back(); 379 334 … … 392 347 parent_classifier_node_labels_iterator++; 393 348 } 394 395 // Display the selected classifier node 396 int classifier_node_numleafdocs = metadata_values_response.docInfo.size() + documents_response.docInfo.size(); 397 display_classifier_node (classifier_node_OID, classifier_node_label, classifier_node_numleafdocs, classifier_node_indent, args, collectproto, browsers, disp, outconvert, textout, logout); 398 classifier_node_indent++; 349 } 350 351 352 void dynamicclassifieraction::output_child_classifier_nodes (text_t classifier_node_OID, 353 text_t metadata_value_filter, 354 int& classifier_node_indent, 355 text_tmap classifier_options, cgiargsclass &args, 356 recptproto *collectproto, browsermapclass *browsers, 357 displayclass &disp, outconvertclass &outconvert, 358 ostream &textout, ostream &logout) 359 { 360 // Get all the metadata values for the specified element that match the filter 361 text_t metadata_element_name = classifier_options["metadata_element_name"]; 362 FilterResponse_t metadata_values_response; 363 bool request_success = get_metadata_values (metadata_element_name, metadata_value_filter, "", args["c"], collectproto, metadata_values_response, logout); 364 365 // If the request failed then it's probably because the collection isn't using an SQL infodbtype 366 if (request_success == false) 367 { 368 textout << outconvert << disp << "Error: Dynamic classifier functionality is not available. Please check you are using an SQL infodbtype and the collection has been rebuilt.\n"; 369 return; 370 } 399 371 400 372 // After processing any hierarchical metadata values, we're left with the child classifer nodes … … 405 377 while (child_classifier_nodes_iterator != child_classifier_nodes.end()) 406 378 { 407 text_t child_classifier_node_OID = classifier_node_OID + "|" + (*child_classifier_nodes_iterator).first; 379 text_t child_classifier_node_OID = (*child_classifier_nodes_iterator).first; 380 if (classifier_node_OID != "") 381 { 382 child_classifier_node_OID = classifier_node_OID + "|" + child_classifier_node_OID; 383 } 408 384 text_t child_classifier_node_label = (*child_classifier_nodes_iterator).first; 409 385 int child_classifier_node_numleafdocs = (*child_classifier_nodes_iterator).second; … … 411 387 child_classifier_nodes_iterator++; 412 388 } 413 414 // Display the documents at this level415 display_document_nodes (documents_response, classifier_node_indent, args, collectproto, browsers, disp, outconvert, textout, logout);416 389 } 417 390 -
gsdl/trunk/src/recpt/dynamicclassifieraction.h
r16056 r16057 70 70 ostream &textout, ostream &logout); 71 71 72 void output_top_level_node (text_t classifier_node_OID, 73 text_t classifier_node_metadata_value, 74 int& classifier_node_indent, 75 text_tmap classifier_options, cgiargsclass &args, 76 recptproto *collectproto, browsermapclass *browsers, 77 displayclass &disp, outconvertclass &outconvert, 78 ostream &textout, ostream &logout); 72 void output_parent_classifier_nodes (text_t classifier_node_OID, 73 int& classifier_node_indent, 74 text_tmap classifier_options, cgiargsclass &args, 75 recptproto *collectproto, browsermapclass *browsers, 76 displayclass &disp, outconvertclass &outconvert, 77 ostream &textout, ostream &logout); 79 78 80 void output_ internal_node(text_t classifier_node_OID,81 text_t classifier_node_metadata_value,82 int& classifier_node_indent,83 text_tmap classifier_options, cgiargsclass &args,84 recptproto *collectproto, browsermapclass *browsers,85 displayclass &disp, outconvertclass &outconvert,86 ostream &textout, ostream &logout);79 void output_child_classifier_nodes (text_t classifier_node_OID, 80 text_t metadata_value_filter, 81 int& classifier_node_indent, 82 text_tmap classifier_options, cgiargsclass &args, 83 recptproto *collectproto, browsermapclass *browsers, 84 displayclass &disp, outconvertclass &outconvert, 85 ostream &textout, ostream &logout); 87 86 88 87 map<text_t, int, lttext_t> process_metadata_values (text_tmap classifier_options,
Note:
See TracChangeset
for help on using the changeset viewer.