Changeset 18895

Show
Ignore:
Timestamp:
06.04.2009 13:18:45 (10 years ago)
Author:
kjdon
Message:

added is_valid_element to metaformat, which checks elementSet for the element name. metaformat subclass constructors must set up elementSet. Currently they do this in the code. would be good if it could read in from a file eventually, maybe?? When metaformat is outputting the m,etadata, it checks whether the element is valid before outputting. otherwise it will invalidate the response as it won't conform to the schema. also, changed where we lowercased the entire name to lowercasing only the first letter - some qdc fields have an internal upper case letter.

Location:
gsdl/trunk/runtime-src/src/oaiservr
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/oaiservr/dublincore.cpp

    r8219 r18895  
    11 
    22#include "dublincore.h" 
     3 
     4dublin_core::dublin_core() : metaformat() { 
     5  // These element names taken from the schema 
     6  // http://www.openarchives.org/OAI/2.0/oai_dc.xsd 
     7  elementSet.insert("contributor"); 
     8  elementSet.insert("coverage"); 
     9  elementSet.insert("creator"); 
     10  elementSet.insert("date"); 
     11  elementSet.insert("description"); 
     12  elementSet.insert("format"); 
     13  elementSet.insert("identifier"); 
     14  elementSet.insert("language"); 
     15  elementSet.insert("publisher"); 
     16  elementSet.insert("relation"); 
     17  elementSet.insert("rights"); 
     18  elementSet.insert("source"); 
     19  elementSet.insert("subject"); 
     20  elementSet.insert("title"); 
     21  elementSet.insert("type"); 
     22  
     23 
     24} 
    325 
    426const text_t dublin_core::formatName() { 
  • gsdl/trunk/runtime-src/src/oaiservr/dublincore.h

    r8182 r18895  
    66  virtual void output_metadata_header(ostream &output); 
    77  virtual void output_metadata_footer(ostream &output); 
     8 
    89 public: 
    9   dublin_core() : metaformat(){}; 
     10  dublin_core();  
    1011  virtual const text_t formatName(); 
    1112  virtual const text_t formatPrefix(); 
  • gsdl/trunk/runtime-src/src/oaiservr/metaformat.cpp

    r18884 r18895  
    6969    if (metaItem == this->formatPrefix()) { 
    7070      metaItem = substr(last+1, here->first.end()); // Get the rest of the metadata tag (it's name) but without the '.' 
    71       lc(metaItem); // Convert it to lowercase for putting in the xml tags 
    72  
     71      lc(metaItem.begin(),metaItem.begin()+1); // We want lowercase, but some of the fields in qualified dublin core have internal upper case, eg instructionalMethod. So we assume that lowercasing the first letter is enough 
    7372      if (doOutput) { 
    74     this->output_item(output, utf8convert, headerDone, metaItem, here->second.values); 
     73    if (this->is_valid_element(metaItem)) { 
     74       
     75      this->output_item(output, utf8convert, headerDone, metaItem, here->second.values); 
     76    } 
    7577      } 
    7678      else { 
     
    8688    // particular metadata is stuff we don't want? 
    8789    if (doOutput) { 
    88       this->output_item(output, utf8convert, headerDone, mapTo, here->second.values); 
     90      if (this->is_valid_element(mapTo)) { 
     91        this->output_item(output, utf8convert, headerDone, mapTo, here->second.values); 
     92      } 
    8993    } 
    9094    else { 
     
    115119  ofstream o("dummy", ios::out); 
    116120  return this->scan_metadata(o, collection, docInfo, false); 
     121} 
     122 
     123bool metaformat::is_valid_element(text_t &meta_name) 
     124{ 
     125  if (elementSet.count(meta_name)==1) return true; 
     126  return false; 
     127   
    117128} 
    118129 
  • gsdl/trunk/runtime-src/src/oaiservr/metaformat.h

    r18875 r18895  
    1919 protected: 
    2020  virtual void output_metadata_header(ostream &output) = 0; 
    21   virtual void output_item(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &label,  
     21  virtual void output_item(ostream &output, outconvertclass &outconvert,  
     22               bool &headerDone, const text_t &label,  
    2223               const text_tarray &values); 
    2324  virtual void output_metadata_footer(ostream &output) = 0; 
    24   virtual bool scan_metadata(ostream &output, const text_t &collection,  ResultDocInfo_t &docInfo,  
    25                  bool doOutput); 
     25  virtual bool is_valid_element(text_t &meta_name); 
     26  virtual bool scan_metadata(ostream &output, const text_t &collection,   
     27                 ResultDocInfo_t &docInfo, bool doOutput); 
    2628  oaiconfig *    oaiConfigure; 
     29 
     30  // a set containing all the valid element names for the set. Must be  
     31  // initialized by each metadata class 
     32  text_tset elementSet;  
    2733 
    2834 public: 
     
    3036  virtual const text_t formatName() = 0; 
    3137  virtual const text_t formatPrefix() = 0; 
    32   virtual bool output_record(ostream &output, recptproto *protocol, const text_t &collection,  
     38  virtual bool output_record(ostream &output, recptproto *protocol,  
     39                 const text_t &collection,  
    3340                 const text_t &record_OID); 
    3441  virtual bool is_available(const text_t &collection, ResultDocInfo_t &docInfo); 
    35   virtual bool output_metadata(ostream &output, const text_t &collection,  ResultDocInfo_t &docInfo); 
     42  virtual bool output_metadata(ostream &output, const text_t &collection,   
     43                   ResultDocInfo_t &docInfo); 
    3644  virtual bool output_formatdata(ostream &output) = 0; 
    3745  void    set_configuration(oaiconfig *config) { this->oaiConfigure = config; } 
  • gsdl/trunk/runtime-src/src/oaiservr/qualified_dublincore.cpp

    r18865 r18895  
    22#include "qualified_dublincore.h" 
    33 
     4qualified_dublin_core::qualified_dublin_core() : metaformat() { 
     5  // These element names taken from the schema 
     6  //http://www.greenstone.org/namespace/gsdl_qdc/1.0/gsdl_qdc.xsd 
     7 
     8  elementSet.insert("title"); 
     9   elementSet.insert("creator"); 
     10   elementSet.insert("subject"); 
     11   elementSet.insert("description"); 
     12   elementSet.insert("publisher"); 
     13   elementSet.insert("contributor"); 
     14   elementSet.insert("date"); 
     15   elementSet.insert("type"); 
     16   elementSet.insert("format"); 
     17   elementSet.insert("identifier"); 
     18   elementSet.insert("source"); 
     19   elementSet.insert("language"); 
     20   elementSet.insert("relation"); 
     21   elementSet.insert("coverage"); 
     22   elementSet.insert("rights"); 
     23   elementSet.insert("alternative"); 
     24   elementSet.insert("tableOfContents"); 
     25   elementSet.insert("abstract"); 
     26   elementSet.insert("created"); 
     27   elementSet.insert("valid"); 
     28   elementSet.insert("available"); 
     29   elementSet.insert("issued");  
     30   elementSet.insert("modified"); 
     31   elementSet.insert("dateAccepted"); 
     32   elementSet.insert("dateCopyrighted"); 
     33   elementSet.insert("dateSubmitted"); 
     34   elementSet.insert("extent"); 
     35   elementSet.insert("medium"); 
     36   elementSet.insert("isVersionOf"); 
     37   elementSet.insert("hasVersion"); 
     38   elementSet.insert("isReplacedBy"); 
     39   elementSet.insert("replaces");  
     40   elementSet.insert("isRequiredBy"); 
     41   elementSet.insert("requires");  
     42   elementSet.insert("isPartOf"); 
     43   elementSet.insert("hasPart");  
     44   elementSet.insert("isReferencedBy"); 
     45   elementSet.insert("references"); 
     46   elementSet.insert("isFormatOf"); 
     47   elementSet.insert("hasFormat"); 
     48   elementSet.insert("conformsTo"); 
     49   elementSet.insert("spatial"); 
     50   elementSet.insert("temporal"); 
     51   elementSet.insert("audience"); 
     52   elementSet.insert("accrualMethod"); 
     53   elementSet.insert("accrualPeriodicity"); 
     54   elementSet.insert("accrualPolicy"); 
     55   elementSet.insert("instructionalMethod"); 
     56   elementSet.insert("provenance"); 
     57   elementSet.insert("rightsHolder"); 
     58   elementSet.insert("mediator"); 
     59   elementSet.insert("educationLevel"); 
     60   elementSet.insert("accessRights"); 
     61   elementSet.insert("license");  
     62   elementSet.insert("bibliographicCitation"); 
     63} 
    464const text_t qualified_dublin_core::formatName() { 
    565  return "gsdl_qdc"; 
  • gsdl/trunk/runtime-src/src/oaiservr/qualified_dublincore.h

    r18875 r18895  
    77  virtual void output_metadata_footer(ostream &output); 
    88 public: 
    9   qualified_dublin_core() : metaformat(){} 
     9  qualified_dublin_core(); 
    1010  virtual const text_t formatName(); 
    1111  virtual const text_t formatPrefix(); 
  • gsdl/trunk/runtime-src/src/oaiservr/rfc1807.cpp

    r15194 r18895  
    11#include "rfc1807.h" 
     2 
     3rfc1807::rfc1807() : metaformat(){ 
     4  // These element names taken from the schema 
     5  // http://www.openarchives.org/OAI/1.1/rfc1807.xsd 
     6  elementSet.insert("bib-version"); 
     7  elementSet.insert("id"); 
     8  elementSet.insert("entry");  
     9  elementSet.insert("organization"); 
     10  elementSet.insert("title"); 
     11  elementSet.insert("type"); 
     12  elementSet.insert("revision"); 
     13  elementSet.insert("withdraw"); 
     14  elementSet.insert("author");  
     15  elementSet.insert("corp-author"); 
     16  elementSet.insert("contact");  
     17  elementSet.insert("date"); 
     18  elementSet.insert("pages"); 
     19  elementSet.insert("copyright"); 
     20  elementSet.insert("handle");  
     21  elementSet.insert("other_access"); 
     22  elementSet.insert("retrieval"); 
     23  elementSet.insert("keyword");  
     24  elementSet.insert("cr-category"); 
     25  elementSet.insert("period");  
     26  elementSet.insert("series");  
     27  elementSet.insert("monitoring"); 
     28  elementSet.insert("funding"); 
     29  elementSet.insert("contract"); 
     30  elementSet.insert("grant"); 
     31  elementSet.insert("language"); 
     32  elementSet.insert("notes");  
     33  elementSet.insert("abstract"); 
     34  
     35};  
    236 
    337const text_t rfc1807::formatName()  
     
    5690  return true; 
    5791} 
     92 
     93 
  • gsdl/trunk/runtime-src/src/oaiservr/rfc1807.h

    r8182 r18895  
    66  virtual void output_metadata_footer(ostream &output); 
    77 public: 
    8   rfc1807() : metaformat(){}; // call parent constructor 
     8  rfc1807();  
    99  virtual const text_t formatName(); 
    1010  virtual const text_t formatPrefix();