Changeset 649 for trunk/gsdl/src/recpt/OIDtools.cpp
- Timestamp:
- 1999-10-10T21:14:12+13:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/OIDtools.cpp
r533 r649 28 28 /* 29 29 $Log$ 30 Revision 1.17 1999/10/10 08:14:02 sjboddie 31 - metadata now returns mp rather than array 32 - redesigned browsing support (although it's not finished so 33 won't currently work ;-) 34 30 35 Revision 1.16 1999/09/07 04:56:51 sjboddie 31 36 added GPL notice … … 135 140 136 141 // get_info does a protocol call and returns (in response) the metadata 137 // associated with OID. The metadata arrayshould be loaded with whatever142 // associated with OID. Metadata should be loaded with whatever 138 143 // metadata fields are to be requested. 139 144 140 145 bool get_info (const text_t &OID, const text_t &collection, 141 const text_t array&metadata, bool getParents,146 const text_tset &metadata, bool getParents, 142 147 recptproto *collectproto, FilterResponse_t &response, 143 148 ostream &logout) { … … 163 168 return false; 164 169 } 165 166 // check the result to make sure we have the right amount of metadata167 if (!response.docInfo.empty() &&168 response.docInfo[0].metadata.size() != metadata.size()) return false;169 170 170 171 return true; … … 172 173 173 174 bool get_info (const text_tarray &OIDs, const text_t &collection, 174 const text_t array&metadata, bool getParents,175 const text_tset &metadata, bool getParents, 175 176 recptproto *collectproto, FilterResponse_t &response, 176 177 ostream &logout) { … … 198 199 } 199 200 200 // check the result to make sure we have the right amount of metadata201 if (!response.docInfo.empty() &&202 response.docInfo[0].metadata.size() != metadata.size()) return false;203 204 201 return true; 205 202 } … … 210 207 211 208 FilterResponse_t response; 212 text_t arraymetadata;213 metadata. push_back("haschildren");209 text_tset metadata; 210 metadata.insert ("haschildren"); 214 211 215 212 if (get_info (OID, collection, metadata, false, collectproto, response, logout)) { 216 if (response.docInfo[0].metadata[ 0].values[0] == "1")213 if (response.docInfo[0].metadata["haschildren"].values[0] == "1") 217 214 return true; 218 215 } … … 222 219 223 220 // get_children does a protocol call and returns (in response) the OIDs and 224 // metadata of all the children of OID. The metadata arrayshould be loaded221 // metadata of all the children of OID. The metadata set should be loaded 225 222 // with whatever metadata fields are to be requested. 226 223 227 224 bool get_children (const text_t &OID, const text_t &collection, 228 const text_t array&metadata, bool getParents,225 const text_tset &metadata, bool getParents, 229 226 recptproto *collectproto, FilterResponse_t &response, 230 227 ostream &logout) { … … 323 320 } 324 321 325 void recurse_contents (const ResultDocInfo_t section, const bool &classify, 326 int &totalcols, const text_t &collection, 327 const text_tarray &metadata, recptproto *collectproto, 328 FilterResponse_t &response, ostream &logout) { 329 330 int metasize = section.metadata.size(); 331 332 int haschildren = section.metadata[metasize-2].values[0].getint(); 333 const text_t &doctype = section.metadata[metasize-1].values[0]; 334 int cols; 335 336 if ((haschildren == 1) && ((!classify) || (doctype == "classify"))) { 337 text_t parent = response.docInfo.back().OID; 338 int parentcols = countchar (parent.begin(), parent.end(), '.'); 322 static void recurse_contents (ResultDocInfo_t section, const bool &is_classify, 323 const text_t &collection, const text_tset &metadata, 324 recptproto *collectproto, FilterResponse_t &response, 325 ostream &logout) { 326 327 int haschildren = section.metadata["haschildren"].values[0].getint(); 328 const text_t &doctype = section.metadata["doctype"].values[0]; 329 330 if ((haschildren == 1) && ((!is_classify) || (doctype == "classify"))) { 339 331 FilterResponse_t tmp; 340 332 bool getParents = false; 341 333 get_children (section.OID, collection, metadata, getParents, collectproto, tmp, logout); 342 ResultDocInfo_tarray:: const_iterator thisdoc = tmp.docInfo.begin();343 ResultDocInfo_tarray:: const_iterator lastdoc = tmp.docInfo.end();334 ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin(); 335 ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end(); 344 336 while (thisdoc != lastdoc) { 345 if (((*thisdoc).metadata[metasize-1].values[0] != "classify") && (classify))346 cols = parentcols + 1;347 else348 cols = countchar ((*thisdoc).OID.begin(), (*thisdoc).OID.end(), '.');349 if (cols > totalcols) totalcols = cols;350 337 response.docInfo.push_back (*thisdoc); 351 recurse_contents (*thisdoc, classify, totalcols, collection,352 metadata,collectproto, response, logout);338 recurse_contents (*thisdoc, is_classify, collection, metadata, 339 collectproto, response, logout); 353 340 thisdoc ++; 354 341 } … … 358 345 // get_contents returns OIDs and metadata of all contents 359 346 // below (and including) OID. 360 void get_contents (const text_t &topOID, const text_t &classifytype,361 text_t array &metadata, int &totalcols,362 const text_t &collection, recptproto *collectproto,363 FilterResponse_t &response,ostream &logout) {347 void get_contents (const text_t &topOID, const bool &is_classify, 348 text_tset &metadata, const text_t &collection, 349 recptproto *collectproto, FilterResponse_t &response, 350 ostream &logout) { 364 351 365 352 if (topOID.empty()) return; 366 bool classify = false;367 353 response.clear(); 368 354 369 metadata.push_back("haschildren"); 370 metadata.push_back("doctype"); 371 372 // we don't want to recurse all the way down through each document 373 // if we're expanding top level contents 374 if (classifytype == "classify") classify = true; 375 376 // update totalcols 377 totalcols = countchar (topOID.begin(), topOID.end(), '.'); 355 metadata.insert ("haschildren"); 356 metadata.insert ("doctype"); 378 357 379 358 // get topOIDs info 380 359 if (get_info (topOID, collection, metadata, false, collectproto, response, logout)) 381 recurse_contents (response.docInfo[0], classify, totalcols, collection,360 recurse_contents (response.docInfo[0], is_classify, collection, 382 361 metadata, collectproto, response, logout); 383 362 }
Note:
See TracChangeset
for help on using the changeset viewer.