Ignore:
Timestamp:
1999-04-30T13:59:44+12:00 (25 years ago)
Author:
sjboddie
Message:

lots of stuff - getting documentaction working (documentaction replaces
old browseaction)

File:
1 edited

Legend:

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

    r213 r248  
    1212/*
    1313   $Log$
     14   Revision 1.5  1999/04/30 01:59:37  sjboddie
     15   lots of stuff - getting documentaction working (documentaction replaces
     16   old browseaction)
     17
    1418   Revision 1.4  1999/03/29 02:14:25  sjboddie
    1519
     
    4953
    5054  top.clear();
     55  if (OID.empty()) return;
     56
    5157  text_t::const_iterator begin = OID.begin();
    5258  text_t::const_iterator end = OID.end();
     
    8187}
    8288
    83 
    84 // don't know how to do this yet either ...
    85 bool contains_text (const text_t &/*OID*/) {
    86   return true;
    87 }
    88 
    89 
    9089// get_parents_array loads the parents array with all the parents of the
    9190// document or classification specified by OID
     
    105104
    106105
    107 // get_children_array loads the children array with all the children of the
    108 // document or classification specified by OID
    109 void get_children_array (const text_t &OID, text_tarray &children) {
    110 
    111   children.erase(children.begin(), children.end());
    112 
    113   // just stuff some rubish in for now
    114   children.push_back (OID + ".1");
    115   children.push_back (OID + ".2");
    116   children.push_back (OID + ".3");
    117   children.push_back (OID + ".4");
    118   children.push_back (OID + ".5");
    119   children.push_back (OID + ".6");
    120   children.push_back (OID + ".7");
    121 }
    122 
     106// get_info does a protocol call and returns (in response) the metadata
     107// associated with OID. The metadata array should be loaded with whatever
     108// metadata fields are to be requested.
     109
     110bool get_info (const text_t &OID, const text_t &collection,
     111           const text_tarray &metadata, recptproto *collectproto,
     112           FilterResponse_t &response, ostream &logout) {
     113
     114  response.clear();
     115
     116  comerror_t err;
     117  FilterRequest_t request;
     118
     119  request.filterName = "NullFilter";
     120  request.filterResultOptions = FRmetadata;
     121  request.fields = metadata;
     122  request.docSet.insert (OID);
     123 
     124  collectproto->filter (collection, request, response, err, logout);
     125  if (err != noError) {
     126    outconvertclass text_t2ascii;
     127    logout << text_t2ascii
     128       << "Error: call to filter failed for " << OID
     129       << " in OIDtools::get_info ("
     130       << get_comerror_string (err) << ")\n";
     131    return false;
     132  }
     133  return true;
     134}
     135
     136// get_children does a protocol call and returns (in response) the OIDs and
     137// metadata of all the children of OID. The metadata array should be loaded
     138// with whatever metadata fields are to be requested.
     139
     140bool get_children (const text_t &OID, const text_t &collection,
     141           const text_tarray &metadata, recptproto *collectproto,
     142           FilterResponse_t &response, ostream &logout) {
     143 
     144  response.clear();
     145
     146  comerror_t err;
     147  FilterRequest_t request;
     148  OptionValue_t option;
     149
     150  option.name = "ParentNode";
     151  option.value = OID;
     152  request.filterOptions.push_back (option);
     153  request.filterName = "BrowseFilter";
     154  request.filterResultOptions = FROID | FRmetadata;
     155  request.fields = metadata;
     156
     157  collectproto->filter (collection, request, response, err, logout);
     158
     159  if (err != noError) {
     160    outconvertclass text_t2ascii;
     161    logout << text_t2ascii
     162       << "Error: call to filter failed for " << OID
     163       << " in OIDtools::get_children ("
     164       << get_comerror_string (err) << ")\n";
     165    return false;
     166  }
     167  return true;
     168}
     169
     170// get_first_child does a protocol call and returns (in child) the OID
     171// of the first child of OID if it exists
     172bool get_first_child (const text_t &OID, text_t &child, const text_t &collection,
     173              recptproto *collectproto, ostream logout) {
     174
     175  comerror_t err;
     176  FilterResponse_t response;
     177  FilterRequest_t request;
     178  OptionValue_t option;
     179
     180  request.filterName = "BrowseFilter";
     181  option.name = "EndResults";
     182  option.value = "1";
     183  request.filterOptions.push_back (option);
     184  option.name = "ParentNode";
     185  option.value = OID;
     186  request.filterOptions.push_back (option);
     187  request.filterResultOptions = FROID;
     188 
     189  collectproto->filter (collection, request, response, err, logout);
     190 
     191  if (err != noError) {
     192    outconvertclass text_t2ascii;
     193    logout << text_t2ascii
     194       << "Error: call to filter failed for " << OID
     195       << " in OIDtools::get_first_child ("
     196       << get_comerror_string (err) << ")\n";
     197    return false;
     198  }
     199   
     200  if (response.docInfo[0].OID.empty())
     201    return false;
     202  else
     203    child = response.docInfo[0].OID;
     204  return true;
     205}
    123206
    124207// get_parent returns the parent of the document or classification
     
    139222}
    140223
    141 
    142 // get_first_child loads child with the first
    143 // child of OID
    144 void get_first_child(const text_t &OID, text_t &child) {
    145   // shove something in for now - I think we'll need to
    146   // look up db here
    147   child.clear();
    148   child += OID + ".1";
    149 }
     224// takes an OID like ".2.3 and replaces the " with parent
     225void translate_parent (text_t &OID, const text_t &parent) {
     226
     227  text_t::const_iterator here = OID.begin();
     228  text_t::const_iterator end = OID.end();
     229  text_t temp;
     230
     231  while (here != end) {
     232    if (*here == '"') temp += parent;
     233    else temp.push_back (*here);
     234    here ++;
     235  }
     236  OID = temp;
     237}
     238
     239// shrink_parent does the opposite to translate_parent
     240void shrink_parent (text_t &OID) {
     241 
     242  text_t::iterator parit = findchar (OID.begin(), OID.end(), '.');
     243  if (parit == OID.end()) return;
     244
     245  OID.erase (OID.begin(), parit);
     246  OID = "\"" + OID;
     247}
     248
     249// checks if OID uses ".fc", ".lc", ".pr", ".ns",
     250// or ".ps" syntax (first child, last child, parent,
     251// next sibling, previous sibling)
     252bool needs_translating (const text_t &OID) {
     253
     254  if (OID.size() < 4) return false;
     255
     256  text_t tail = substr (OID.end()-3, OID.end());
     257  if (tail == ".fc" || tail == ".lc" || tail == ".pr" ||
     258      tail == ".ns" || tail == ".ps") return true;
     259
     260  return false;
     261}
Note: See TracChangeset for help on using the changeset viewer.