Changeset 19046

Show
Ignore:
Timestamp:
19.04.2009 17:41:33 (10 years ago)
Author:
davidb
Message:

Qualifiers within metadata can now support a chain of parent: and child: terms, e.g. parent:child(All)

Location:
gsdl/trunk/runtime-src/src/recpt
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/recpt/formattools.cpp

    r16915 r19046  
    6161  mqualifier.sibling = sNone; 
    6262  mqualifier.child   = cNone; 
     63  pre_tree_traverse.clear(); 
    6364  parentoptions.clear(); 
    6465  siblingoptions.clear(); 
     
    470471  } 
    471472 
    472   if (meta.size() > 7 && (substr (meta.begin(), meta.begin()+6) == "parent")) { 
    473     getParents = true; 
    474     metaoption.metacommand |= mParent; 
    475     get_parent_options (meta, metaoption); 
    476   }  
    477   else if (meta.size() > 6 && (substr (meta.begin(), meta.begin()+5) == "child")) { 
    478     metaoption.metacommand |= mChild; 
    479     get_child_options (meta, metaoption); 
    480     metadata.insert("contains"); 
    481   }  
    482   // parent and child can have sibling also 
     473  bool had_parent_or_child = true; 
     474  bool prev_was_parent = false; 
     475  bool prev_was_child  = false; 
     476 
     477  while (had_parent_or_child) { 
     478    if (meta.size() > 7  
     479    && (substr (meta.begin(), meta.begin()+6) == "parent")) { 
     480 
     481      // clear out sibling and child (cmd and options) 
     482      metaoption.metacommand &= ~(mChild|mSibling); 
     483      metaoption.childoptions.clear(); 
     484      metaoption.siblingoptions.clear(); 
     485 
     486      getParents = true; 
     487      metaoption.metacommand |= mParent; 
     488      get_parent_options (meta, metaoption); 
     489 
     490      if (prev_was_parent) { 
     491    metaoption.pre_tree_traverse += ".pr"; 
     492      } 
     493      else if (prev_was_child) { 
     494    metaoption.pre_tree_traverse += ".fc"; 
     495      } 
     496 
     497      prev_was_parent = true; 
     498      prev_was_child  = false; 
     499    }  
     500    else if (meta.size() > 6  
     501         && (substr (meta.begin(), meta.begin()+5) == "child")) { 
     502 
     503      // clear out sibling and parent (cmd and options) 
     504      metaoption.metacommand &= ~(mParent|mSibling); 
     505      metaoption.parentoptions.clear(); 
     506      metaoption.siblingoptions.clear(); 
     507 
     508      metaoption.metacommand |= mChild; 
     509      get_child_options (meta, metaoption); 
     510      metadata.insert("contains"); 
     511 
     512      if (prev_was_parent) { 
     513    metaoption.pre_tree_traverse += ".pr"; 
     514      } 
     515      else if (prev_was_child) { 
     516    metaoption.pre_tree_traverse += ".fc"; 
     517      } 
     518 
     519      prev_was_child  = true; 
     520      prev_was_parent = false; 
     521    }  
     522    else { 
     523      prev_was_child  = false; 
     524      prev_was_parent = false; 
     525      had_parent_or_child = false; 
     526    } 
     527  } 
     528 
     529  // parent/child can have sibling tacked on end also 
    483530  if (meta.size() > 8 && (substr (meta.begin(), meta.begin()+7) == "sibling")) { 
    484531    metaoption.metacommand |= mSibling; 
     
    928975  if (docinfo.metadata["contains"].values[0].size()==0) return ""; // no children 
    929976   
     977  const text_t& pre_tree_trav = meta.pre_tree_traverse; 
    930978  const text_t& child_metaname = meta.metaname; 
    931979  const text_t& child_field = meta.childoptions; 
     
    937985    // just one child 
    938986    //get the information associated with the metadata for child doc 
    939     if (!get_info (docinfo.OID+child_field, collection, "", child_metadata,  
    940            false, collectproto, child_response, logout)) return ""; // invalid child number 
     987    if (!get_info (docinfo.OID+pre_tree_trav+child_field, collection, "",  
     988           child_metadata, false, collectproto, child_response,  
     989           logout)) return ""; // invalid child number 
    941990 
    942991      if (child_response.docInfo.empty()) return false; // no info for the child 
     
    9521001     
    9531002  if (meta.mqualifier.child != cAll) return false; // invalid qualifier 
     1003 
     1004 
     1005  if (!pre_tree_trav.empty()) { 
     1006    // need to get relevant "contains" metadata for new (e.g. pre tree trav) node 
     1007    FilterResponse_t trav_response; 
     1008 
     1009    text_tset trav_metadata; 
     1010    trav_metadata.insert("contains");  
     1011 
     1012    if (!get_info (docinfo.OID+pre_tree_trav, collection, "",  
     1013           trav_metadata, false, collectproto, trav_response,  
     1014           logout)) return ""; // invalid pre_tree_trav 
     1015 
     1016    if (trav_response.docInfo.empty()) return false; // no info for the pre_tree_trav OID 
     1017   
     1018    ResultDocInfo_t& trav_docinfo = trav_response.docInfo[0]; 
     1019    // use this for rest of routine 
     1020    docinfo = trav_docinfo; 
     1021  } 
    9541022   
    9551023  // we need to get all children 
     
    9651033    here++; 
    9661034    if (*(oid.begin()) == '"') translate_parent (oid, docinfo.OID); 
    967      
    9681035     
    9691036    //get the information associated with the metadata for child doc 
  • gsdl/trunk/runtime-src/src/recpt/formattools.h

    r16915 r19046  
    5757  } mqualifier; 
    5858 
     59  text_t pre_tree_traverse; 
    5960  text_t parentoptions; 
    6061  text_t siblingoptions;