Changeset 16114
- Timestamp:
- 2008-06-24T12:50:27+12:00 (15 years ago)
- Location:
- gsdl/trunk/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/src/recpt/dynamicclassifieraction.cpp
r16112 r16114 173 173 } 174 174 175 // Output the dynamic classifier, beginning with the (optional) grouping nodes 175 // Prepare to output the dynamic classifier 176 text_t classifier_node_OID = args["dcn"]; 177 int classifier_node_indent = 0; 178 179 // Begin with the (optional) grouping nodes 176 180 text_t selected_grouping_node_OID = ""; 177 181 if (!classifier_options["-group_using"].empty()) 178 182 { 179 183 selected_grouping_node_OID = output_grouping_nodes (classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 180 } 181 text_t classifier_node_OID = args["dcn"]; // args["dcn"] may have been modified by output_grouping_nodes() 182 int classifier_node_indent = 0; 184 classifier_node_OID = args["dcn"]; // args["dcn"] may have been modified by output_grouping_nodes() 185 } 186 187 // Next, optionally display an hlist level 188 text_t selected_hlist_node_OID = ""; 189 if (classifier_options["-use_hlist_at_top"] == "1") 190 { 191 text_t parent_classifier_node_OID = selected_grouping_node_OID; 192 text_t classifier_node_metadata_value = selected_grouping_node_OID; 193 text_t metadata_value_filter = selected_grouping_node_OID + "*"; 194 selected_hlist_node_OID = output_hlist_classifier_nodes (parent_classifier_node_OID, classifier_node_metadata_value, metadata_value_filter, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 195 classifier_node_OID = args["dcn"]; // args["dcn"] may have been modified by output_hlist_classifier_nodes() 196 } 183 197 184 198 // Simple case at the top level: just output the child classifier nodes … … 199 213 } 200 214 215 // This is the classifier node OID without any hlist nodes 216 text_t classifier_node_OID_sans_hlists = classifier_node_OID; 217 if (classifier_node_OID == selected_hlist_node_OID) 218 { 219 classifier_node_OID_sans_hlists = ""; 220 } 221 else if (starts_with (classifier_node_OID, selected_hlist_node_OID + "|")) 222 { 223 classifier_node_OID_sans_hlists = substr (classifier_node_OID.begin() + (selected_hlist_node_OID + "|").size(), classifier_node_OID.end()); 224 } 225 201 226 // Determine the parent classifier node labels 202 227 text_tlist parent_classifier_node_labels; 203 splitchar(classifier_node_OID_sans_ grouping.begin(), classifier_node_OID_sans_grouping.end(), '|', parent_classifier_node_labels);228 splitchar(classifier_node_OID_sans_hlists.begin(), classifier_node_OID_sans_hlists.end(), '|', parent_classifier_node_labels); 204 229 205 230 // Output the parent classifier nodes and the current classifier node 206 output_upper_classifier_nodes (selected_ grouping_node_OID, parent_classifier_node_labels, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout);231 output_upper_classifier_nodes (selected_hlist_node_OID, parent_classifier_node_labels, classifier_node_indent, classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout); 207 232 208 233 // Output the child classifier nodes … … 319 344 320 345 return selected_grouping_node_OID; 346 } 347 348 349 text_t dynamicclassifieraction::output_hlist_classifier_nodes (text_t parent_classifier_node_OID, 350 text_t classifier_node_metadata_value, 351 text_t metadata_value_filter, 352 text_tmap classifier_options, cgiargsclass &args, 353 recptproto *collectproto, browsermapclass *browsers, 354 displayclass &disp, outconvertclass &outconvert, 355 ostream &textout, ostream &logout) 356 { 357 // Get all the metadata values for the specified element that match the filter 358 text_t metadata_element_name = classifier_options["metadata_element_name"]; 359 FilterResponse_t metadata_values_response; 360 bool request_success = get_metadata_values (metadata_element_name, metadata_value_filter, "", args["c"], collectproto, metadata_values_response, logout); 361 362 // If the request failed then it's probably because the collection isn't using an SQL infodbtype 363 if (request_success == false) 364 { 365 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"; 366 return ""; 367 } 368 369 // Check some metadata values were returned 370 if (metadata_values_response.docInfo.empty()) 371 { 372 return ""; 373 } 374 375 // After processing any hierarchical metadata values we're left with the hlist classifer nodes 376 map<text_t, int, lttext_t> hlist_classifier_nodes; 377 ResultDocInfo_tarray::iterator metadata_value_iterator = metadata_values_response.docInfo.begin(); 378 while (metadata_value_iterator != metadata_values_response.docInfo.end()) 379 { 380 text_t metadata_value = (*metadata_value_iterator).OID; 381 382 // If we're not at the top-level we need to remove the current position from the metadata values 383 if (starts_with(metadata_value, classifier_node_metadata_value + "|")) 384 { 385 metadata_value = substr(metadata_value.begin() + (classifier_node_metadata_value + "|").size(), metadata_value.end()); 386 } 387 388 // Is this metadata value hierarchical? 389 text_t::iterator hierarchy_split_position = findchar(metadata_value.begin(), metadata_value.end(), '|'); 390 if (hierarchy_split_position != metadata_value.end()) 391 { 392 // Yes, so use the first part of the hierarchy only 393 metadata_value = substr(metadata_value.begin(), hierarchy_split_position); 394 } 395 396 // Create a node for this metadata value if we haven't seen it before 397 if (hlist_classifier_nodes.find(metadata_value) == hlist_classifier_nodes.end()) 398 { 399 hlist_classifier_nodes[metadata_value] = 0; 400 } 401 402 // Increment the occurrence count 403 hlist_classifier_nodes[metadata_value] += (*metadata_value_iterator).result_num; 404 405 metadata_value_iterator++; 406 } 407 408 // If no classifier node has been specified automatically go to the first hlist node 409 if (args["dcn"] == parent_classifier_node_OID) 410 { 411 args["dcn"] = (*hlist_classifier_nodes.begin()).first; 412 } 413 414 // Add the necessary metadata to the hlist classifier nodes 415 text_t selected_hlist_node_OID = ""; 416 FilterResponse_t hlist_classifier_nodes_response; 417 map<text_t, int, lttext_t>::iterator hlist_classifier_nodes_iterator = hlist_classifier_nodes.begin(); 418 while (hlist_classifier_nodes_iterator != hlist_classifier_nodes.end()) 419 { 420 text_t hlist_classifier_node_OID = (*hlist_classifier_nodes_iterator).first; 421 422 // Is this the hlist node that is currently selected? 423 if (starts_with (args["dcn"], hlist_classifier_node_OID)) 424 { 425 selected_hlist_node_OID = hlist_classifier_node_OID; 426 } 427 428 // Add the necessary metadata required to display the hlist nodes correctly 429 ResultDocInfo_t hlist_classifier_node; 430 hlist_classifier_node.OID = hlist_classifier_node_OID; 431 hlist_classifier_node.metadata["doctype"].values.push_back ("classify"); 432 hlist_classifier_node.metadata["haschildren"].values.push_back ("1"); 433 hlist_classifier_node.metadata["numleafdocs"].values.push_back ("?"); // We can't determine this without more database requests 434 hlist_classifier_node.metadata["Title"].values.push_back (hlist_classifier_node_OID); 435 hlist_classifier_nodes_response.docInfo.push_back (hlist_classifier_node); 436 437 hlist_classifier_nodes_iterator++; 438 } 439 440 // Display the hlist nodes 441 display_classifier_nodes (hlist_classifier_nodes_response, "HList", 0, args, collectproto, browsers, disp, outconvert, textout, logout); 442 443 return selected_hlist_node_OID; 321 444 } 322 445 -
gsdl/trunk/src/recpt/dynamicclassifieraction.h
r16113 r16114 70 70 ostream &textout, ostream &logout); 71 71 72 text_t output_hlist_classifier_nodes (text_t parent_classifier_node_OID, 73 text_t classifier_node_metadata_value, 74 text_t metadata_value_filter, 75 text_tmap classifier_options, cgiargsclass &args, 76 recptproto *collectproto, browsermapclass *browsers, 77 displayclass &disp, outconvertclass &outconvert, 78 ostream &textout, ostream &logout); 79 72 80 void output_upper_classifier_nodes (text_t root_classifier_node_OID, 73 81 text_tlist parent_classifier_node_labels,
Note:
See TracChangeset
for help on using the changeset viewer.