Changeset 27528
- Timestamp:
- 2013-06-04T11:05:08+12:00 (11 years ago)
- Location:
- main/trunk/greenstone2/runtime-src/src/oaiservr
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/oaiservr/abstractlistaction.cpp
r24109 r27528 55 55 position = resumption_token.getPosition(); 56 56 } 57 58 // Case for "set" argument present -- output just the records in the specified set 57 58 // is it a super collection?? 59 bool is_super_collection = false; 60 59 61 if (set_name != "") 60 62 { 63 text_tarray super_colls = this->configuration->getSuperCollectionsList(); 64 for (int s = 0; s<super_colls.size(); s++) { 65 if (set_name == super_colls[s]) { 66 is_super_collection = true; 67 break; 68 } 69 } 70 } 71 72 // Case for "set" argument present that is not a super collection -- output just the records in the specified set 73 if (set_name != "" && !is_super_collection) { 61 74 // Separate the collection name and Greenstone classifier OID from the set name 62 75 text_t collection_name = ""; … … 72 85 73 86 // Case for no "set" argument present -- output all records in all collections 87 // or we are a super collection 74 88 else 75 89 { 76 90 // Get a list of the collections available 77 text_tarray& collections = this->configuration->getCollectionsList(); 91 text_tarray collections; 92 93 if (is_super_collection) { 94 collections = this->configuration->getSuperCollectionCollections(set_name); 95 } else { 96 collections = this->configuration->getCollectionsList(); 97 } 78 98 if (collections.size() == 0) 79 99 { … … 120 140 return true; 121 141 } 122 123 142 124 143 bool abstractlistaction::output_content_for_set(ostream &output, recptproto *protocol, oaiargs ¶ms, text_t collection_name, text_t gsdl_classifier_OID, text_t set_name) -
main/trunk/greenstone2/runtime-src/src/oaiservr/listidsaction.cpp
r22739 r27528 179 179 text_t set = params["set"]; 180 180 181 // Is the set a super collection?? 182 text_tarray &super_collections = this->configuration->getSuperCollectionsList(); 183 bool super_collection_found = false; 184 for (int c = 0; c < super_collections.size(); c++) 185 { 186 if (super_collections[c] == set) 187 { 188 super_collection_found = true; 189 break; 190 } 191 } 192 if (super_collection_found) { 193 this->errorType = ""; 194 return true; 195 } 196 181 197 // Extract the collection name from the set specification 182 198 text_t collection = ""; -
main/trunk/greenstone2/runtime-src/src/oaiservr/listsetsaction.cpp
r22739 r27528 131 131 } 132 132 133 // if no resumption token, output the super colls. Otherwise, start from 134 // the collection list correct position. 135 // Assume for now that super coll list is always in the first list 136 text_t set_name =""; 137 if (position == "") { 138 text_tarray& supercolls = this->configuration->getSuperCollectionsList(); 139 if (collections.size() != 0) { 140 text_tarray::iterator supercoll_iterator = supercolls.begin(); 141 while (supercoll_iterator != supercolls.end()) { 142 set_name = (*supercoll_iterator); 143 output_content_for_supercol(output, set_name); 144 supercoll_iterator++; 145 } 146 } 147 } 133 148 // Get the current collection from the position value 134 149 text_t collection_name = ""; … … 173 188 return true; 174 189 } 190 191 bool listsetsaction::output_content_for_supercol(ostream &output, text_t supercoll) { 192 utf8outconvertclass utf8convert; 193 output << utf8convert << " <set>\n"; 194 output << utf8convert << " <setSpec>" << supercoll << "</setSpec>\n"; 195 if (this->configuration->getSetName(supercoll) != "") 196 { 197 output << utf8convert << " <setName>" << this->configuration->getSetName(supercoll) << "</setName>\n"; 198 } 199 else 200 { 201 output << utf8convert << " <setName>" << supercoll << "</setName>\n"; 202 } 203 if (this->configuration->getSetDescription(supercoll) != "") 204 { 205 output << utf8convert << " <setDescription>" << this->configuration->getSetDescription(supercoll) << "</setDescription>\n"; 206 } 207 output << utf8convert << " </set>\n"; 208 this->setsOutput++; 209 } 210 211 175 212 176 213 -
main/trunk/greenstone2/runtime-src/src/oaiservr/listsetsaction.h
r22739 r27528 40 40 bool output_content(ostream &output, recptproto *protocol, oaiargs ¶ms); 41 41 42 bool output_content_for_supercol(ostream &output, text_t supercoll); 42 43 bool output_content_for_col(ostream &output, recptproto *protocol, oaiargs ¶ms, text_t collection); 43 44 }; -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.cpp
r24871 r27528 413 413 oaiclassifier::getCollectionFromOAIID(oaiLabel, collection_id); 414 414 if(oaiVersion >= 200){ 415 416 // A doc is always a member of its collection set 417 output << " <setSpec>" << collection_id << "</setSpec>" << endl; 418 // are we part of a super collection? 419 text_tarray super_colls = this->configuration->getSuperCollectionsForThisCollection(collection_id); 420 if (super_colls.size()!=0) { 421 text_tarray::const_iterator super_start = super_colls.begin(); 422 text_tarray::const_iterator super_end = super_colls.end(); 423 while(super_start != super_end) { 424 output << " <setSpec>" << *super_start << "</setSpec>" << endl; 425 ++ super_start; 426 } 427 } 428 429 // Do we have subsets? 415 430 text_tarray::const_iterator member = memberOf.begin(); 416 431 text_tarray::const_iterator memEnd = memberOf.end(); 417 418 // As well as all the subsets that a doc appears in, it is also a member of the 'collection' set419 output << " <setSpec>" << collection_id << "</setSpec>" << endl;420 432 while (member != memEnd) { 421 433 text_t oaiSet = *member; -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp
r24114 r27528 29 29 #include <stdlib.h> 30 30 #include "fileutil.h" 31 32 31 33 32 /** … … 211 210 } 212 211 } 212 else if (key == "oaisupercollection" && cfgline.size() > 1) { 213 214 // Configure a hierarchical super set 215 // The line should read 216 // 217 // oaisupercollection <setName> [collections part of this set] 218 // 219 // Records in specified collections will be advertised as being part 220 // of the SetName set as well as their collectionName set 221 // 222 // This configuration should only appear in oai.cfg 223 // 224 if (this->collection != "") { 225 cerr << "Attempt to configure an oai super collection outside of oai.cfg" << endl; 226 cerr << "Configuration attempted in " << this->collection << " collection." << endl; 227 exit(1); 228 } 229 230 text_t super_set = cfgline[0]; 231 this->superCollectList.push_back(super_set); 232 this->superCollectMap[super_set] = new oaisupercollectconfig(super_set); 233 for (int c = 1; c < cfgline.size(); ++c) { 234 text_t sub_coll = cfgline[c]; 235 // Add the collection into the list for this supercoll 236 this->superCollectMap[super_set]->collectionList.push_back(sub_coll); 237 // Add the super coll into the list for the collection 238 if (this->collectMap[sub_coll]== NULL) { 239 this->collectMap[sub_coll] = new oaicollectconfig(sub_coll); 240 } 241 this->collectMap[sub_coll]->superCollectList.push_back(super_set); 242 } 243 } 213 244 else if (key == "oaimetadata" && cfgline.size() >= 1) { 214 245 // List of metadata prefixes to suuport … … 274 305 } 275 306 if (value != "") { 276 if (this->collectMap[coll_name] == NULL) { 277 this->collectMap[coll_name] = new oaicollectconfig(coll_name); 278 } 279 if (key == "oaisetname") { 280 this->collectMap[coll_name]->setName = value; 281 } else if (key == "oaisetdescription") { 282 this->collectMap[coll_name]->setDescription = value; 307 // check first for super collection 308 if (this->superCollectMap[coll_name] != NULL) { 309 if (key == "oaisetname") { 310 this->superCollectMap[coll_name]->setName = value; 311 } else if (key == "oaisetdescription") { 312 this->superCollectMap[coll_name]->setDescription = value; 313 } 314 } else { 315 if (this->collectMap[coll_name] == NULL) { 316 this->collectMap[coll_name] = new oaicollectconfig(coll_name); 317 } 318 if (key == "oaisetname") { 319 this->collectMap[coll_name]->setName = value; 320 } else if (key == "oaisetdescription") { 321 this->collectMap[coll_name]->setDescription = value; 322 } 283 323 } 284 324 } … … 418 458 text_t oaiconfig::getSetName(const text_t &setSpec) 419 459 { 420 if (this->collectMap[setSpec] == NULL) { 421 return "" ; 422 } 460 if (this->collectMap[setSpec] != NULL) { 461 this->collectMap[setSpec]->setName; 462 } 463 if (this->superCollectMap[setSpec] != NULL) { 464 return this->superCollectMap[setSpec]->setName; 465 } 466 return "" ; 423 467 424 return this->collectMap[setSpec]->setName; 468 } 469 470 text_t oaiconfig::getSetDescription(const text_t &setSpec) 471 { 472 if (this->collectMap[setSpec] != NULL) { 473 return this->collectMap[setSpec]->setDescription; 474 } 475 if (this->superCollectMap[setSpec] != NULL) { 476 return this->superCollectMap[setSpec]->setDescription; 477 } 425 478 426 } 427 428 text_t oaiconfig::getSetDescription(const text_t &setSpec) 429 { 430 if (this->collectMap[setSpec] == NULL) { 431 return "" ; 432 } 479 return "" ; 433 480 434 return this->collectMap[setSpec]->setDescription; 435 } 436 481 } 482 483 text_tarray oaiconfig::getSuperCollectionsForThisCollection(const text_t &collection) { 484 485 text_tarray super_colls; 486 if (this->superCollectList.size() == 0) { 487 return super_colls; 488 } 489 490 for (int s = 0; s < this->superCollectList.size(); s++) { 491 text_tarray colls = this->superCollectMap[this->superCollectList[s]]->collectionList; 492 for (int c = 0; c < colls.size(); c++) 493 { 494 if (colls[c] == collection) 495 { 496 super_colls.push_back(this->superCollectList[s]); 497 break; 498 } 499 } 500 } 501 502 return super_colls; 503 } -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.h
r23233 r27528 39 39 text_t setDescription; // A display description for the set (collection) 40 40 text_tmap fieldMap; // maps from OAI name to GSDL name 41 text_tarray superCollectList; // a list of all super collections this belongs to 41 42 }; 42 43 43 44 typedef map<text_t, oaicollectconfig *, lttext_t> oaicollectmap; 45 46 class oaisupercollectconfig { 47 public: 48 oaisupercollectconfig(const text_t &supercollectionname) { this->supercollection = supercollectionname; } 49 text_t supercollection; 50 text_t setName; // A display name for the set (supercollection) 51 text_t setDescription; // A display description for the set (supercollection) 52 text_tarray collectionList; // a list of collections contained in this super collection 53 }; 54 55 typedef map<text_t, oaisupercollectconfig *, lttext_t> oaisupercollectmap; 56 44 57 45 58 class oaiconfig : configurable { … … 50 63 virtual void configure(const text_t &key, const text_tarray &cfgline); 51 64 text_tarray & getCollectionsList() { return this->collectList; } 65 text_tarray & getSuperCollectionsList() { return this->superCollectList; } 66 text_tarray & getSuperCollectionCollections(const text_t super_coll) { 67 return this->superCollectMap[super_coll]->collectionList; 68 } 69 text_tarray getSuperCollectionsForThisCollection(const text_t &collection); 52 70 text_tset & getMetadataSet() { return this->metadataSet; } 53 71 text_t getMapping(const text_t &collection, const text_t &collectfield); … … 86 104 oaicollectmap collectMap; // The configuration of collections 87 105 text_t collection; // Used to track which collection is being configured 88 106 text_tarray superCollectList; //a list of super collections. may be empty 107 oaisupercollectmap superCollectMap; // The configuration of the super collections 89 108 }; 90 109 #endif
Note:
See TracChangeset
for help on using the changeset viewer.