[8219] | 1 |
|
---|
[8182] | 2 | #include "dublincore.h"
|
---|
[21761] | 3 | #include "gsdltools.h"
|
---|
[8182] | 4 |
|
---|
[18895] | 5 | dublin_core::dublin_core() : metaformat() {
|
---|
| 6 | // These element names taken from the schema
|
---|
| 7 | // http://www.openarchives.org/OAI/2.0/oai_dc.xsd
|
---|
| 8 | elementSet.insert("contributor");
|
---|
| 9 | elementSet.insert("coverage");
|
---|
| 10 | elementSet.insert("creator");
|
---|
| 11 | elementSet.insert("date");
|
---|
| 12 | elementSet.insert("description");
|
---|
| 13 | elementSet.insert("format");
|
---|
| 14 | elementSet.insert("identifier");
|
---|
| 15 | elementSet.insert("language");
|
---|
| 16 | elementSet.insert("publisher");
|
---|
| 17 | elementSet.insert("relation");
|
---|
| 18 | elementSet.insert("rights");
|
---|
| 19 | elementSet.insert("source");
|
---|
| 20 | elementSet.insert("subject");
|
---|
| 21 | elementSet.insert("title");
|
---|
| 22 | elementSet.insert("type");
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | }
|
---|
| 26 |
|
---|
[8182] | 27 | const text_t dublin_core::formatName() {
|
---|
| 28 | return "oai_dc";
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | const text_t dublin_core::formatPrefix() {
|
---|
[8219] | 32 | return "dc";
|
---|
[8182] | 33 | }
|
---|
| 34 |
|
---|
| 35 | bool dublin_core::output_record(ostream &output, recptproto *protocol, const text_t &collection,
|
---|
| 36 | const text_t &record_OID)
|
---|
| 37 | {
|
---|
| 38 | return metaformat::output_record(output, protocol, collection, record_OID);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | void dublin_core::output_metadata_header(ostream &output)
|
---|
| 42 | {
|
---|
| 43 | output << " <metadata>\n";
|
---|
| 44 |
|
---|
| 45 | if (this->oaiConfigure->getOAIVersion() <= 110){
|
---|
| 46 | // output dublin core wrapper for OAI v1.1
|
---|
| 47 | output << " <dc xmlns=\"http://purl.org/dc/elements/1.1/\"\n"
|
---|
| 48 | << " xmlns:xsi=\"http://www.w3c.org/2001/XMLSchema-instance\"\n"
|
---|
| 49 | << " xsi:schemaLocation=\"http://purl.org/dc/elements/1.1/\n"
|
---|
| 50 | << " http://www.openarchives.org/OAI/1.1/dc.xsd\">\n";
|
---|
| 51 | }
|
---|
| 52 | else {
|
---|
| 53 | output << " <oai_dc:dc\n"
|
---|
| 54 | << " xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\"\n"
|
---|
| 55 | << " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
|
---|
| 56 | << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
|
---|
| 57 | << " xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/\n"
|
---|
| 58 | << " http://www.openarchives.org/OAI/2.0/oai_dc.xsd\">\n";
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | void dublin_core::output_metadata_footer(ostream &output)
|
---|
| 63 | {
|
---|
| 64 | if (this->oaiConfigure->getOAIVersion() <= 110) {
|
---|
| 65 | output << " </dc>" << endl;
|
---|
| 66 | }
|
---|
| 67 | else {
|
---|
| 68 | output << " </oai_dc:dc>" << endl;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | output << " </metadata>" << endl;
|
---|
| 72 | output.flush();
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[21761] | 75 | bool dublin_core::output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection, ResultDocInfo_t &docInfo) {
|
---|
| 76 | text_t value = get_metadata_value(docInfo, "srclink_file");
|
---|
| 77 | if (value.empty()) {
|
---|
| 78 | value = "gs doc"; // todo, situation where no source doc.
|
---|
| 79 | } else {
|
---|
| 80 | if (starts_with(value, "[")) {
|
---|
| 81 | // its a format statement type value eg [SourceFile], need to get the appropriate metadata
|
---|
| 82 | value = substr(findchar(value.begin(), value.end(), '[')+1,findchar(value.begin(), value.end(), ']') );
|
---|
| 83 | value = get_metadata_value(docInfo, value);
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | if (!value.empty()) {
|
---|
| 87 | text_t assocfilepath = get_metadata_value(docInfo, "assocfilepath");
|
---|
| 88 | if (!assocfilepath.empty()) {
|
---|
| 89 | value = this->oaiConfigure->getCollectionConfig("", "baseDocRoot")+"/collect/"+collection+"/index/assoc/"+assocfilepath+"/"+value;
|
---|
| 90 | } else {
|
---|
| 91 | value = "";
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | }
|
---|
| 95 | if (!value.empty()) {
|
---|
| 96 | if (!headerDone) {
|
---|
| 97 | this->output_metadata_header(output);
|
---|
| 98 | headerDone = true;
|
---|
| 99 | }
|
---|
| 100 | if (this->oaiConfigure->getOAIVersion() >= 200) {
|
---|
| 101 | output << outconvert << " <dc:identifier>" << xml_safe(value) << "</dc:identifier>\n";
|
---|
| 102 | }
|
---|
| 103 | else {
|
---|
| 104 | output << outconvert << " <identifier>" << xml_safe(value) << "</identifier>\n";
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[8182] | 109 | bool dublin_core::output_formatdata(ostream &output)
|
---|
| 110 | {
|
---|
| 111 | output << " <metadataPrefix>oai_dc</metadataPrefix>" << endl;
|
---|
| 112 |
|
---|
| 113 | if (this->oaiConfigure->getOAIVersion() <= 110) {
|
---|
| 114 | output << " <schema>http://www.openarchives.org/OAI/1.1/dc.xsd</schema>" << endl
|
---|
| 115 | << " <metadataNamespace>http://purl.org/dc/elements/1.1/</metadataNamespace>" << endl;
|
---|
| 116 | }
|
---|
| 117 | else {
|
---|
| 118 | output << " <schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>" << endl
|
---|
| 119 | << " <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>"
|
---|
| 120 | << endl;
|
---|
| 121 | }
|
---|
| 122 | return true;
|
---|
| 123 | }
|
---|
| 124 |
|
---|