Changeset 1342 for branches/z3950-branch/gsdl/src/recpt/z3950proto.cpp
- Timestamp:
- 2000-08-03T14:49:41+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/z3950-branch/gsdl/src/recpt/z3950proto.cpp
r1191 r1342 1 2 #ifndef Z3950PROTO_H 3 #define Z3050PROTO_H 1 /********************************************************************** 2 * 3 * z3950proto.cpp -- 4 * Copyright (C) 2000 The New Zealand Digital Library Project 5 * 6 * A component of the Greenstone digital library software 7 * from the New Zealand Digital Library Project at the 8 * University of Waikato, New Zealand. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * 24 *********************************************************************/ 4 25 5 26 #include "z3950proto.h" … … 200 221 } 201 222 202 // is this right? ie does end refer to the last element, or AFTER the203 // last element?204 223 if (here==end) { 205 224 err=protocolError; … … 230 249 // collectinfo.collectionmeta; // text_tmap 231 250 collectinfo.collectionmeta=*((*here)->getMeta()); 232 /* collectinfo.format; //text_tmap 233 collectinfo.building; //text_tmap 234 */ 251 collectinfo.format=*((*here)->getFormat()); //text_tmap 252 /* collectinfo.building; //text_tmap */ 235 253 236 254 ////collectinfo.receptionist="z3950"; … … 299 317 // now have collection in zserver. 300 318 301 // ColInfoResponse_t *info = new ColInfoResponse_t;302 319 ColInfoResponse_t info; 303 320 ResultDocInfo_t *docInfo; … … 307 324 308 325 // See if this is for a query action 309 /*** johnmcp **** - could check filterName??????? ********/310 /* if (!request.requestParams.empty())311 cout << "RequestParams: " << request.requestParams.getcstr() << "\n";312 if (!request.refParams.empty())313 cout << "RefParams: " << request.refParams.getcstr() << "\n";314 */315 /* cout << "filterOptions:\n";316 OptionValue_tarray::iterator ov_here=request.filterOptions.begin();317 OptionValue_tarray::iterator ov_end=request.filterOptions.end();318 while (ov_here != ov_end) {319 cout << "OV pair: `" << ov_here->name.getcstr() << "'=`"320 << ov_here->value.getcstr() << "'\n";321 ov_here++;322 }*/323 324 // fields is type text_tset;325 /* cout << "Fields:\n";326 text_tset::iterator fields_h=request.fields.begin();327 text_tset::iterator fields_e=request.fields.end();328 while (fields_h != fields_e) {329 cout << "Field: " << fields_h->getcstr() << "\n";330 fields_h++;331 }*/332 333 334 // if this is true, we assume query action.335 // if (request.filterResultOptions & /*FROID*/FRtermFreq) {336 326 if (request.filterName=="QueryFilter") { 337 327 /* Sample OptionValue pairs … … 346 336 */ 347 337 // go through options 348 text_t opt_term; 338 text_t opt_term; // the term(s) that the user entered 339 text_t opt_fields; // which fields to search on 349 340 int opt_start=1, opt_end=20; // default values 350 341 int nummatches=0, maxdocs=50; // default values … … 354 345 // cout << "OV pair: `" << ov_here->name.getcstr() << "'=`" 355 346 // << ov_here->value.getcstr() << "'\n"; 356 if (ov_here->name=="Term") { 357 opt_term=ov_here->value; 358 } else if (ov_here->name=="StartResults") { 359 opt_start=ov_here->value.getint(); 360 } else if (ov_here->name=="EndResults") { 361 opt_end=ov_here->value.getint(); 362 } else if (ov_here->name=="Maxdocs") { 363 maxdocs=ov_here->value.getint(); 364 } 347 if (ov_here->name=="Term") 348 { 349 opt_term=ov_here->value; 350 } else if (ov_here->name=="Index") 351 { 352 opt_fields=ov_here->value; 353 } else if (ov_here->name=="StartResults") 354 { 355 opt_start=ov_here->value.getint(); 356 } else if (ov_here->name=="EndResults") 357 { 358 opt_end=ov_here->value.getint(); 359 } else if (ov_here->name=="Maxdocs") 360 { 361 maxdocs=ov_here->value.getint(); 362 } 365 363 ov_here++; 366 364 } 367 365 err=noError; 368 text_tarray *titles=(*zserver)->getbriefrecords(opt_term, 369 opt_start, 366 text_tarray *titles=(*zserver)->getrecordTitles(opt_term, 367 opt_fields, 368 opt_start, // first to get 370 369 opt_end-opt_start, //count 371 370 &nummatches,err); … … 375 374 docInfo=new ResultDocInfo_t; 376 375 response.docInfo.push_back(*docInfo); 377 logout << "z3950 filter query: error connecting to server\n"; 376 docInfo->metadata["Title"].values.push_back("Error - query err?"); 377 logout << "\nz3950 filter query: error connecting to server\n"; 378 // for now, DON'T use GSDL protocol err. 379 err=noError; 378 380 return; 379 381 } 380 382 // check if (titles==NULL) - only happens on error? 381 382 text_tarray::iterator titles_here=titles->begin(); 383 text_tarray::iterator titles_end=titles->end(); 384 int counter=1; 385 while (titles_here!=titles_end) { 386 docInfo=new ResultDocInfo_t; 387 docInfo->metadata["Title"].values.push_back(*titles_here); 388 docInfo->result_num=counter; 389 // we need to give some OID, so we'll just use counter for now... 390 // make it the number into the whole possible retrieved set. 391 docInfo->OID=counter+opt_start-1; 392 response.docInfo.push_back(*docInfo); 393 counter++; 394 titles_here++; 383 if (nummatches>0) { 384 text_tarray::iterator titles_here=titles->begin(); 385 text_tarray::iterator titles_end=titles->end(); 386 int counter=1; 387 while (titles_here!=titles_end) { 388 docInfo=new ResultDocInfo_t; 389 docInfo->metadata["Title"].values.push_back(*titles_here); 390 docInfo->result_num=counter; 391 // we need to give some OID, so we'll just use counter for now... 392 // make it the number into the whole possible retrieved set. 393 docInfo->OID=counter+opt_start-1; 394 response.docInfo.push_back(*docInfo); 395 counter++; 396 titles_here++; 397 } 395 398 } 396 399 … … 432 435 get_collectinfo (collection, info, err, logout); 433 436 // should check err returned here.... 434 /* In the absence of any other information, (eg commented code), 435 assuming that if the request.fields is empty, then we should return 436 all metadata, otherwise return only the requested fields */ 437 /**** comtypes.h has: "text_tset fields; // empty if not used" ****/ 437 438 // get the Query out of the filterOptions. 439 text_t query=""; 440 text_t field=""; 441 OptionValue_tarray::iterator opt_here=request.filterOptions.begin(); 442 OptionValue_tarray::iterator opt_end=request.filterOptions.end(); 443 while (opt_here!=opt_end) { 444 if (opt_here->name=="Query") { 445 query=opt_here->value; 446 if (field!="") break; // break from loop if we've got both 447 } else if (opt_here->name=="Index") { 448 field=opt_here->value; 449 if (query!="") break; // break from loop if we've got both 450 } 451 opt_here++; 452 } 438 453 439 454 if (!request.fields.empty()) { … … 452 467 if (it!=info.collectionmeta.end()) 453 468 docs_here->metadata[*fields_here].values.push_back((*it).second); 454 else if (*fields_here=="Title") { 455 text_t title; 469 else if (*fields_here=="Title" && !request.docSet.empty()) { 470 // We only do this for a document action. 471 // (This comes through as a NullQuery). 472 // hopefully docSet is only not empty for documentaction... 473 text_t doctitle; 456 474 int i; 457 // check that docSet isn't empty !!!@!!!475 // check that docSet isn't empty first!!!!!! 458 476 i=request.docSet[0].getint(); 459 477 text_t doctext="unneeded"; 460 (*zserver)->getfullrecord( i, title, doctext,err);478 (*zserver)->getfullrecord(query, field, i, doctitle, doctext, err); 461 479 // check err value! 462 doc Info->metadata["Title"].values.push_back(title);480 docs_here->metadata["Title"].values.push_back(doctitle); 463 481 } else { 464 482 docs_here->metadata[*fields_here].values.push_back(""); … … 503 521 504 522 // do indices' names, regardless of whether asked for or not... 505 response.docInfo[0].metadata[".author"].values.push_back("author fields"); 506 response.docInfo[0].metadata[".title"].values.push_back("title fields"); 507 response.docInfo[0].metadata[".any"].values.push_back("any fields"); 523 if (!response.docInfo.empty()) { 524 response.docInfo[0].metadata[".author"].values.push_back("author fields"); 525 response.docInfo[0].metadata[".title"].values.push_back("title fields"); 526 response.docInfo[0].metadata[".any"].values.push_back("any fields"); 527 } 508 528 } //end of if (... & FRmetadata) ... 509 529 } … … 538 558 text_t title="unneeded"; 539 559 text_t doctext; 540 (*zserver)->getfullrecord(request.OID.getint(),title,doctext,err); 560 text_t query; // this should not be needed, as we have already connected to 561 // get the title.... 562 text_t field; // ditto... 563 (*zserver)->getfullrecord(query,field,request.OID.getint(), 564 title,doctext,err); 541 565 // check return value of above? (false=>not connected) 542 566 if (err==noError) … … 554 578 } 555 579 } 556 557 558 #endif
Note:
See TracChangeset
for help on using the changeset viewer.