Changeset 16046


Ignore:
Timestamp:
2008-06-18T14:45:32+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding dynamic classifiers) Added partial support for "grouping nodes" (ie. hlists), accessible using the new "-group_using" dynamic classifier option.

Location:
gsdl/trunk/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/recpt/dynamicclassifieraction.cpp

    r16039 r16046  
    158158  textout << outconvert << disp << classifier_header_format_statement << "\n";
    159159
    160   // Output the dynamic classifier
    161   if (args["dcn"].empty())
     160  // Output the dynamic classifier, beginning with the (optional) grouping nodes
     161  text_t selected_grouping_node_OID = "";
     162  if (!classifier_options["-group_using"].empty())
     163  {
     164    selected_grouping_node_OID = output_grouping_nodes (classifier_options, args, collectproto, browsers, disp, outconvert, textout, logout);
     165  }
     166
     167  if (args["dcn"] == selected_grouping_node_OID)
    162168  {
    163169    // Simple case for the top-level page
     
    216222
    217223
     224text_t dynamicclassifieraction::output_grouping_nodes (text_tmap classifier_options, cgiargsclass &args,
     225                               recptproto *collectproto, browsermapclass *browsers,
     226                               displayclass &disp, outconvertclass &outconvert,
     227                               ostream &textout, ostream &logout)
     228{
     229  // Get all the metadata values for the specified element, and group them according to the "-group_using" value
     230  text_t metadata_element_name = classifier_options["metadata_element_name"];
     231  text_t metadata_value_grouping_expression = classifier_options["-group_using"];
     232  FilterResponse_t grouping_nodes_response;
     233  bool request_success = get_metadata_values (metadata_element_name, "", metadata_value_grouping_expression, args["c"], collectproto, grouping_nodes_response, logout);
     234
     235  // If the request failed then it's probably because the collection isn't using an SQL infodbtype
     236  if (request_success == false)
     237  {
     238    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";
     239    return "";
     240  }
     241
     242  // Check some grouping nodes were returned
     243  if (grouping_nodes_response.docInfo.empty())
     244  {
     245    return "";
     246  }
     247
     248  // If no classifier node has been specified automatically go to the first grouping node
     249  if (args["dcn"] == "")
     250  {
     251    args["dcn"] = grouping_nodes_response.docInfo.front().OID;
     252  }
     253
     254  text_t selected_grouping_node_OID = "";
     255  ResultDocInfo_tarray::iterator grouping_node_iterator = grouping_nodes_response.docInfo.begin();
     256  while (grouping_node_iterator != grouping_nodes_response.docInfo.end())
     257  {
     258    // Is this the grouping node that is currently selected?
     259    if ((*grouping_node_iterator).OID == args["dcn"])
     260    {
     261      selected_grouping_node_OID = (*grouping_node_iterator).OID;
     262    }
     263
     264    // Add the necessary metadata required to display the grouping nodes correctly
     265    (*grouping_node_iterator).metadata["doctype"].values.push_back ("classify");
     266    (*grouping_node_iterator).metadata["haschildren"].values.push_back ("1");
     267    (*grouping_node_iterator).metadata["numleafdocs"].values.push_back ("?");  // We can't determine this without more database requests
     268    (*grouping_node_iterator).metadata["Title"].values.push_back ((*grouping_node_iterator).OID);
     269    grouping_node_iterator++;
     270  }
     271
     272  // Get the format statement for this classifier if there is one, or use the browser's default otherwise
     273  text_t formatstring;
     274  text_t classifier_type = "HList";
     275  browserclass *bptr = browsers->getbrowser (classifier_type);
     276  ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, args["c"], logout);
     277  if (!get_formatstring (args["dcl"], classifier_type, cinfo->format, formatstring))
     278  {
     279    formatstring = bptr->get_default_formatstring();
     280  }
     281  format_t *formatlistptr = new format_t();
     282  text_tset metadata;
     283  bool getParents = false;
     284  parse_formatstring (formatstring, formatlistptr, metadata, getParents);
     285  bool use_table = is_table_content (formatlistptr);
     286
     287  // Display the grouping nodes
     288  bptr->output_section_group (grouping_nodes_response, args, args["c"], 0, formatlistptr, use_table, metadata, getParents, collectproto, disp, outconvert, textout, logout);
     289
     290  return selected_grouping_node_OID;
     291}
     292
     293
    218294void dynamicclassifieraction::output_top_level_page (text_tmap classifier_options, cgiargsclass &args,
    219295                             recptproto *collectproto, browsermapclass *browsers,
  • gsdl/trunk/src/recpt/dynamicclassifieraction.h

    r16032 r16046  
    6565  text_tmap parse_classifier_options (text_t classifier_specification, cgiargsclass &args);
    6666
     67  text_t output_grouping_nodes (text_tmap classifier_options, cgiargsclass &args,
     68                recptproto *collectproto, browsermapclass *browsers,
     69                displayclass &disp, outconvertclass &outconvert,
     70                ostream &textout, ostream &logout);
     71
    6772  void output_top_level_page (text_tmap classifier_options, cgiargsclass &args,
    6873                  recptproto *collectproto, browsermapclass *browsers,
Note: See TracChangeset for help on using the changeset viewer.