Changeset 15807

Show
Ignore:
Timestamp:
29.05.2008 16:25:34 (11 years ago)
Author:
mdewsnip
Message:

(Adding dynamic classifiers) Added rudimentary code for displaying the documents that match a certain classifier node.

Files:
1 modified

Legend:

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

    r15795 r15807  
    3535  arg_ainfo.shortname = "dcl"; 
    3636  arg_ainfo.longname = "dynamic classifier ID"; 
     37  arg_ainfo.multiplechar = true; 
     38  arg_ainfo.defaultstatus = cgiarginfo::weak; 
     39  arg_ainfo.argdefault = ""; 
     40  arg_ainfo.savedarginfo = cgiarginfo::must; 
     41  argsinfo.addarginfo (NULL, arg_ainfo); 
     42 
     43  arg_ainfo.shortname = "dcn"; 
     44  arg_ainfo.longname = "dynamic classifier node"; 
    3745  arg_ainfo.multiplechar = true; 
    3846  arg_ainfo.defaultstatus = cgiarginfo::weak; 
     
    117125  } 
    118126 
     127  text_t metadata_element_name = cinfo->dynamic_classifiers[arg_dcl]; 
    119128  text_t classifier_type = "VList"; 
    120129  browserclass *bptr = browsers->getbrowser (classifier_type); 
     
    130139  bool getParents = false; 
    131140  parse_formatstring (formatstring, formatlistptr, metadata, getParents); 
     141  bool use_table = is_table_content (formatlistptr); 
    132142 
    133   text_t metadata_element_name = cinfo->dynamic_classifiers[arg_dcl]; 
    134   FilterResponse_t metadata_values_response; 
    135   get_metadata_values (metadata_element_name, args["c"], collectproto, metadata_values_response, logout); 
     143  // Check if a dynamic classifier node has been specified 
     144  text_t arg_dcn = args["dcn"]; 
     145  if (arg_dcn.empty()) 
     146  { 
     147    // No, so display the top-level classifier page, containing all the metadata values for the specified element 
     148    FilterResponse_t metadata_values_response; 
     149    get_metadata_values (metadata_element_name, args["c"], collectproto, metadata_values_response, logout); 
    136150 
    137   ResultDocInfo_tarray::iterator metadata_value_iterator = metadata_values_response.docInfo.begin(); 
    138   while (metadata_value_iterator != metadata_values_response.docInfo.end()) 
     151    // Add metadata necessary for output_section_group() to display the results as classifier nodes 
     152    ResultDocInfo_tarray::iterator metadata_value_iterator = metadata_values_response.docInfo.begin(); 
     153    while (metadata_value_iterator != metadata_values_response.docInfo.end()) 
     154    { 
     155      (*metadata_value_iterator).metadata["doctype"].values.push_back("classify"); 
     156      (*metadata_value_iterator).metadata["haschildren"].values.push_back("1"); 
     157      (*metadata_value_iterator).metadata["numleafdocs"].values.push_back((*metadata_value_iterator).result_num); 
     158      (*metadata_value_iterator).metadata["Title"].values.push_back((*metadata_value_iterator).OID); 
     159      metadata_value_iterator++; 
     160    } 
     161 
     162    // Display the classifier nodes 
     163    bptr->output_section_group (metadata_values_response, args, args["c"], 0, formatlistptr, use_table, metadata, getParents, collectproto, disp, outconvert, textout, logout); 
     164  } 
     165  else 
    139166  { 
    140     (*metadata_value_iterator).metadata["doctype"].values.push_back("classify"); 
    141     (*metadata_value_iterator).metadata["haschildren"].values.push_back("1"); 
    142     (*metadata_value_iterator).metadata["numleafdocs"].values.push_back((*metadata_value_iterator).result_num); 
    143     (*metadata_value_iterator).metadata["Title"].values.push_back((*metadata_value_iterator).OID); 
    144     metadata_value_iterator++; 
     167    // Yes, so get all the documents that fall under this node 
     168    text_t metadata_value = arg_dcn; 
     169    FilterResponse_t document_OIDs_response; 
     170    get_documents_with_metadata_value (metadata_element_name, metadata_value, args["c"], collectproto, document_OIDs_response, logout); 
     171 
     172    // Make an array of matching document OIDs 
     173    text_tarray document_OIDs; 
     174    ResultDocInfo_tarray::iterator document_OID_iterator = document_OIDs_response.docInfo.begin(); 
     175    while (document_OID_iterator != document_OIDs_response.docInfo.end()) 
     176    { 
     177      document_OIDs.push_back ((*document_OID_iterator).OID); 
     178      document_OID_iterator++; 
     179    } 
     180 
     181    // Request the necessary metadata for these documents 
     182    FilterResponse_t document_info_response; 
     183    get_info (document_OIDs, args["c"], args["l"], metadata, getParents, collectproto, document_info_response, logout); 
     184 
     185    // Display the document nodes 
     186    bptr->output_section_group (document_info_response, args, args["c"], 0, formatlistptr, use_table, metadata, getParents, collectproto, disp, outconvert, textout, logout); 
    145187  } 
    146  
    147   // Display the nodes 
    148   bool use_table = is_table_content (formatlistptr); 
    149   bptr->output_section_group (metadata_values_response, args, args["c"], 0, formatlistptr, use_table,  
    150                   metadata, getParents, collectproto, disp, outconvert, textout, logout); 
    151188 
    152189  textout << outconvert << disp << "_document:footer_\n";