#include "dublincore.h" #include "gsdltools.h" dublin_core::dublin_core() : metaformat() { // These element names taken from the schema // http://www.openarchives.org/OAI/2.0/oai_dc.xsd elementSet.insert("contributor"); elementSet.insert("coverage"); elementSet.insert("creator"); elementSet.insert("date"); elementSet.insert("description"); elementSet.insert("format"); elementSet.insert("identifier"); elementSet.insert("language"); elementSet.insert("publisher"); elementSet.insert("relation"); elementSet.insert("rights"); elementSet.insert("source"); elementSet.insert("subject"); elementSet.insert("title"); elementSet.insert("type"); } const text_t dublin_core::formatName() { return "oai_dc"; } const text_t dublin_core::formatPrefix() { return "dc"; } bool dublin_core::output_record(ostream &output, recptproto *protocol, const text_t &collection, const text_t &record_OID) { return metaformat::output_record(output, protocol, collection, record_OID); } void dublin_core::output_metadata_header(ostream &output) { output << " \n"; if (this->oaiConfigure->getOAIVersion() <= 110){ // output dublin core wrapper for OAI v1.1 output << " \n"; } else { output << " \n"; } } void dublin_core::output_metadata_footer(ostream &output) { if (this->oaiConfigure->getOAIVersion() <= 110) { output << " " << endl; } else { output << " " << endl; } output << " " << endl; output.flush(); } bool dublin_core::output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection, ResultDocInfo_t &docInfo) { text_t value = get_metadata_value(docInfo, "srclink_file"); if (value.empty()) { value = "gs doc"; // todo, situation where no source doc. } else { if (starts_with(value, "[")) { // its a format statement type value eg [SourceFile], need to get the appropriate metadata value = substr(findchar(value.begin(), value.end(), '[')+1,findchar(value.begin(), value.end(), ']') ); value = get_metadata_value(docInfo, value); } } if (!value.empty()) { text_t assocfilepath = get_metadata_value(docInfo, "assocfilepath"); if (!assocfilepath.empty()) { value = this->oaiConfigure->getCollectionConfig("", "baseDocRoot")+"/collect/"+collection+"/index/assoc/"+assocfilepath+"/"+value; } else { value = ""; } } if (!value.empty()) { if (!headerDone) { this->output_metadata_header(output); headerDone = true; } if (this->oaiConfigure->getOAIVersion() >= 200) { output << outconvert << " " << xml_safe(value) << "\n"; } else { output << outconvert << " " << xml_safe(value) << "\n"; } } return true; } bool dublin_core::output_formatdata(ostream &output) { output << " oai_dc" << endl; if (this->oaiConfigure->getOAIVersion() <= 110) { output << " http://www.openarchives.org/OAI/1.1/dc.xsd" << endl << " http://purl.org/dc/elements/1.1/" << endl; } else { output << " http://www.openarchives.org/OAI/2.0/oai_dc.xsd" << endl << " http://www.openarchives.org/OAI/2.0/oai_dc/" << endl; } return true; }