const Package::AttributionList Package::ContributorNames(bool localized) const { AttributionList result; for ( auto item : PropertiesMatching(MakePropertyIRI("contributor", "dcterms")) ) { result.emplace_back((localized? item->LocalizedValue() : item->Value())); } return result; }
const Package::AttributionList Package::AuthorNames() const { AttributionList result; for ( auto item : MetadataItemsWithDCType(Metadata::DCType::Creator) ) { result.emplace_back(item->Value()); } return result; }
const Package::AttributionList Package::AttributionNames(bool localized) const { AttributionList result; IRI fileAsIRI(MakePropertyIRI("file-as")); for ( auto item : PropertiesMatching(DCType::Creator) ) { auto extension = item->ExtensionWithIdentifier(fileAsIRI); if ( extension ) result.emplace_back(extension->Value()); else result.emplace_back((localized? item->LocalizedValue() : item->Value())); } return result; }
const Package::AttributionList Package::AttributionNames() const { AttributionList result; IRI fileAsIRI(MakePropertyIRI("file-as")); for ( auto item : MetadataItemsWithDCType(Metadata::DCType::Creator) ) { const Metadata::Extension* extension = item->ExtensionWithProperty(fileAsIRI); if ( extension != nullptr ) result.emplace_back(extension->Value()); else result.emplace_back(item->Value()); } return result; }
const Package::AttributionList Package::AuthorNames(bool localized) const { AttributionList result; for ( auto item : PropertiesMatching(DCType::Creator) ) { result.emplace_back((localized? item->LocalizedValue() : item->Value())); } if ( result.empty() ) { // maybe they're using dcterms:creator instead? for ( auto item : PropertiesMatching(MakePropertyIRI("creator", "dcterms")) ) { result.emplace_back((localized? item->LocalizedValue() : item->Value())); } } return result; }
const string Package::Authors() const { // TODO: handle localization AttributionList authors = AuthorNames(); if ( authors.size() == 1 ) return authors[0]; else if ( authors.size() == 2 ) return _Str(authors[0], " and ", authors[1]); std::stringstream ss; auto pos = authors.begin(); auto last = pos + (authors.size() - 1); while ( pos != last ) { ss << *(pos++) << ", "; } ss << "and " << *last; return string(ss.str()); }
const string Package::Contributors(bool localized) const { // TODO: handle localization of the word 'and' AttributionList contributors = ContributorNames(localized); if ( contributors.empty() ) return string::EmptyString; if ( contributors.size() == 1 ) return contributors[0]; else if ( contributors.size() == 2 ) return _Str(contributors[0], " and ", contributors[1]); std::stringstream ss; auto pos = contributors.begin(); auto last = pos + (contributors.size() - 1); while ( pos != last ) { ss << *(pos++) << ", "; } ss << "and " << *last; return string(ss.str()); }