Changeset 21761 for main/trunk/greenstone2/runtime-src/src
- Timestamp:
- 2010-03-03T14:59:22+13:00 (14 years ago)
- Location:
- main/trunk/greenstone2/runtime-src/src/oaiservr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/oaiservr/dublincore.cpp
r18895 r21761 1 1 2 2 #include "dublincore.h" 3 #include "gsdltools.h" 3 4 4 5 dublin_core::dublin_core() : metaformat() { … … 72 73 } 73 74 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 74 109 bool dublin_core::output_formatdata(ostream &output) 75 110 { -
main/trunk/greenstone2/runtime-src/src/oaiservr/dublincore.h
r18895 r21761 6 6 virtual void output_metadata_header(ostream &output); 7 7 virtual void output_metadata_footer(ostream &output); 8 8 virtual bool output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection, ResultDocInfo_t &docInfo); 9 9 public: 10 10 dublin_core(); -
main/trunk/greenstone2/runtime-src/src/oaiservr/metaformat.cpp
r21605 r21761 39 39 } 40 40 41 bool metaformat::output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection, ResultDocInfo_t &docInfo) { 42 return false; 43 } 41 44 bool metaformat::scan_metadata(ostream &output, const text_t &collection, ResultDocInfo_t &docInfo, 42 45 bool doOutput) … … 70 73 text_t mapTo = this->get_mapping(collection, here->first); 71 74 if (mapTo != "") { 72 // Do we actually want to do anything here? Doesn't getting here imply that this73 // particular metadata is stuff we don't want?74 75 if (doOutput) { 75 76 if (this->is_valid_element(mapTo)) { … … 85 86 86 87 // Otherwise try to map the element automatically 87 // For example, dc.X is mapped to oai_dc.X (doesn't check X is a valid Dublin Core element though)88 // For example, dc.X is mapped to oai_dc.X 88 89 else if (metaItem == this->formatPrefix()) { 89 90 metaItem = substr(last+1, here->first.end()); // Get the rest of the metadata tag (it's name) but without the '.' … … 117 118 return false; 118 119 } 119 120 // specific metadata formats might need to do some custom metadata that is not just a standard mapping. eg oai_dc outputting an identifier that is a link 121 this->output_custom_metadata(output, utf8convert, headerDone, collection, docInfo); 120 122 if (headerDone) { 123 121 124 this->output_metadata_footer(output); 122 125 } … … 125 128 } 126 129 130 text_t metaformat::get_metadata_value(ResultDocInfo_t &docInfo, const text_t &meta_name) { 131 MetadataInfo_tmap::iterator here = docInfo.metadata.find(meta_name); 132 if (here == docInfo.metadata.end()) { 133 return ""; 134 } 135 return here->second.values[0]; 136 137 } 138 139 void metaformat::get_metadata_values(ResultDocInfo_t &docInfo, const text_t &meta_name, text_tarray &values) { 140 MetadataInfo_tmap::iterator here = docInfo.metadata.find(meta_name); 141 if (here != docInfo.metadata.end()) { 142 values = here->second.values; 143 } 144 } 127 145 128 146 bool metaformat::is_available(const text_t &collection, ResultDocInfo_t &docInfo) -
main/trunk/greenstone2/runtime-src/src/oaiservr/metaformat.h
r18895 r21761 26 26 virtual bool scan_metadata(ostream &output, const text_t &collection, 27 27 ResultDocInfo_t &docInfo, bool doOutput); 28 virtual bool output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection, 29 ResultDocInfo_t &docInfo); 30 text_t get_metadata_value(ResultDocInfo_t &docInfo, const text_t &meta_name); 31 void get_metadata_values(ResultDocInfo_t &docInfo, const text_t &meta_name, text_tarray & values); 28 32 oaiconfig * oaiConfigure; 29 33
Note:
See TracChangeset
for help on using the changeset viewer.