/** * @see MetadataDataObjectAdapter::extractMetadataFromDataObject() * @param $article Article * @return MetadataDescription */ function &extractMetadataFromDataObject(&$article) { assert(is_a($article, 'Article')); AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON); // Retrieve data that belongs to the article. // FIXME: Retrieve this data from the respective entity DAOs rather than // from the OAIDAO once we've migrated all OAI providers to the // meta-data framework. We're using the OAIDAO here because it // contains cached entities and avoids extra database access if this // adapter is called from an OAI context. $oaiDao = DAORegistry::getDAO('OAIDAO'); /* @var $oaiDao OAIDAO */ $journal = $oaiDao->getJournal($article->getJournalId()); $section = $oaiDao->getSection($article->getSectionId()); if (is_a($article, 'PublishedArticle')) { /* @var $article PublishedArticle */ $issue = $oaiDao->getIssue($article->getIssueId()); } $dc11Description = $this->instantiateMetadataDescription(); // Title $this->_addLocalizedElements($dc11Description, 'dc:title', $article->getTitle(null)); // Creator $authors = $article->getAuthors(); foreach ($authors as $author) { $authorName = $author->getFullName(true); $affiliation = $author->getLocalizedAffiliation(); if (!empty($affiliation)) { $authorName .= '; ' . $affiliation; } $dc11Description->addStatement('dc:creator', $authorName); unset($authorName); } // Subject $subjects = array_merge_recursive((array) $article->getDiscipline(null), (array) $article->getSubject(null), (array) $article->getSubjectClass(null)); $this->_addLocalizedElements($dc11Description, 'dc:subject', $subjects); // Description $this->_addLocalizedElements($dc11Description, 'dc:description', $article->getAbstract(null)); // Publisher $publisherInstitution = $journal->getSetting('publisherInstitution'); if (!empty($publisherInstitution)) { $publishers = array($journal->getPrimaryLocale() => $publisherInstitution); } else { $publishers = $journal->getName(null); // Default } $this->_addLocalizedElements($dc11Description, 'dc:publisher', $publishers); // Contributor $contributors = (array) $article->getSponsor(null); foreach ($contributors as $locale => $contributor) { $contributors[$locale] = array_map('trim', explode(';', $contributor)); } $this->_addLocalizedElements($dc11Description, 'dc:contributor', $contributors); // Date if (is_a($article, 'PublishedArticle')) { if ($article->getDatePublished()) { $dc11Description->addStatement('dc:date', date('Y-m-d', strtotime($article->getDatePublished()))); } elseif ($issue->getDatePublished()) { $dc11Description->addStatement('dc:date', date('Y-m-d', strtotime($issue->getDatePublished()))); } } // Type $driverType = 'info:eu-repo/semantics/article'; $dc11Description->addStatement('dc:type', $driverType, METADATA_DESCRIPTION_UNKNOWN_LOCALE); $types = $section->getIdentifyType(null); $types = array_merge_recursive(empty($types) ? array(AppLocale::getLocale() => __('rt.metadata.pkp.peerReviewed')) : $types, (array) $article->getType(null)); $this->_addLocalizedElements($dc11Description, 'dc:type', $types); $driverVersion = 'info:eu-repo/semantics/publishedVersion'; $dc11Description->addStatement('dc:type', $driverVersion, METADATA_DESCRIPTION_UNKNOWN_LOCALE); // Format if (is_a($article, 'PublishedArticle')) { $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); /* @var $articleGalleyDao ArticleGalleyDAO */ $galleys = $articleGalleyDao->getBySubmissionId($article->getId()); $formats = array(); while ($galley = $galleys->next()) { $dc11Description->addStatement('dc:format', $galley->getFileType()); } } // Identifier: URL if (is_a($article, 'PublishedArticle')) { $dc11Description->addStatement('dc:identifier', Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId()))); } // Source (journal title, issue id and pages) $sources = $journal->getName(null); $pages = $article->getPages(); if (!empty($pages)) { $pages = '; ' . $pages; } foreach ($sources as $locale => $source) { if (is_a($article, 'PublishedArticle')) { $sources[$locale] .= '; ' . $issue->getIssueIdentification(); } $sources[$locale] .= $pages; } $this->_addLocalizedElements($dc11Description, 'dc:source', $sources); if ($issn = $journal->getSetting('onlineIssn')) { $dc11Description->addStatement('dc:source', $issn, METADATA_DESCRIPTION_UNKNOWN_LOCALE); } if ($issn = $journal->getSetting('printIssn')) { $dc11Description->addStatement('dc:source', $issn, METADATA_DESCRIPTION_UNKNOWN_LOCALE); } // Get galleys and supp files. $galleys = array(); $suppFiles = array(); if (is_a($article, 'PublishedArticle')) { $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); /* @var $articleGalleyDao ArticleGalleyDAO */ $galleys = $articleGalleyDao->getBySubmissionId($article->getId())->toArray(); $suppFiles = $article->getSuppFiles(); } // Language $locales = array(); if (is_a($article, 'PublishedArticle')) { foreach ($galleys as $galley) { $galleyLocale = $galley->getLocale(); if (!is_null($galleyLocale) && !in_array($galleyLocale, $locales)) { $locales[] = $galleyLocale; $dc11Description->addStatement('dc:language', AppLocale::getIso3FromLocale($galleyLocale)); } } } $articleLanguage = $article->getLanguage(); if (empty($locales) && !empty($articleLanguage)) { $dc11Description->addStatement('dc:language', strip_tags($articleLanguage)); } // Relation // full text URLs foreach ($galleys as $galley) { $relation = Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId($journal), $galley->getBestGalleyId($journal))); $dc11Description->addStatement('dc:relation', $relation); unset($relation); } // supp file URLs foreach ($suppFiles as $suppFile) { $relation = Request::url($journal->getPath(), 'article', 'downloadSuppFile', array($article->getBestArticleId($journal), $suppFile->getBestSuppFileId($journal))); $dc11Description->addStatement('dc:relation', $relation); unset($relation); } // Public identifiers $pubIdPlugins = (array) PluginRegistry::loadCategory('pubIds', true, $journal->getId()); foreach ($pubIdPlugins as $pubIdPlugin) { if ($pubIssueId = $pubIdPlugin->getPubId($issue)) { $dc11Description->addStatement('dc:source', $pubIssueId, METADATA_DESCRIPTION_UNKNOWN_LOCALE); unset($pubIssueId); } if ($pubArticleId = $pubIdPlugin->getPubId($article)) { $dc11Description->addStatement('dc:identifier', $pubArticleId); unset($pubArticleId); } foreach ($galleys as $galley) { if ($pubGalleyId = $pubIdPlugin->getPubId($galley)) { $dc11Description->addStatement('dc:relation', $pubGalleyId); unset($pubGalleyId); } } foreach ($suppFiles as $suppFile) { if ($pubSuppFileId = $pubIdPlugin->getPubId($suppFile)) { $dc11Description->addStatement('dc:relation', $pubSuppFileId); unset($pubSuppFileId); } } } // Coverage $coverage = array_merge_recursive((array) $article->getCoverageGeo(null), (array) $article->getCoverageChron(null), (array) $article->getCoverageSample(null)); $this->_addLocalizedElements($dc11Description, 'dc:coverage', $coverage); // Rights $this->_addLocalizedElements($dc11Description, 'dc:rights', $journal->getSetting('copyrightNotice')); Hookregistry::call('Dc11SchemaArticleAdapter::extractMetadataFromDataObject', array($this, $article, $journal, $issue, &$dc11Description)); return $dc11Description; }
/** * @see MetadataDataObjectAdapter::extractMetadataFromDataObject() * @param $publicationFormat PublicationFormat * @return MetadataDescription */ function extractMetadataFromDataObject($publicationFormat) { assert(is_a($publicationFormat, 'PublicationFormat')); AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON); // Retrieve data that belongs to the publication format. // FIXME: Retrieve this data from the respective entity DAOs rather than // from the OAIDAO once we've migrated all OAI providers to the // meta-data framework. We're using the OAIDAO here because it // contains cached entities and avoids extra database access if this // adapter is called from an OAI context. $oaiDao = DAORegistry::getDAO('OAIDAO'); /* @var $oaiDao OAIDAO */ $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO'); $monograph = $publishedMonographDao->getById($publicationFormat->getMonographId()); $press = $oaiDao->getPress($monograph->getPressId()); $series = $oaiDao->getSeries($monograph->getSeriesId()); /* @var $series Series */ $dc11Description = $this->instantiateMetadataDescription(); // Title $titles = array(); foreach ($monograph->getTitle(null) as $titleLocale => $title) { $titles[$titleLocale] = $monograph->getFullTitle($titleLocale); } $this->_addLocalizedElements($dc11Description, 'dc:title', $titles); // Creator $authors = $monograph->getAuthors(); foreach ($authors as $author) { $authorName = $author->getFullName(true); $affiliation = $author->getLocalizedAffiliation(); if (!empty($affiliation)) { $authorName .= '; ' . $affiliation; } $dc11Description->addStatement('dc:creator', $authorName); unset($authorName); } // Subject $subjects = array_merge_recursive((array) $monograph->getDiscipline(null), (array) $monograph->getSubject(null)); $this->_addLocalizedElements($dc11Description, 'dc:subject', $subjects); // Description $this->_addLocalizedElements($dc11Description, 'dc:description', $monograph->getAbstract(null)); // Publisher $publisherInstitution = $press->getSetting('publisherInstitution'); if (!empty($publisherInstitution)) { $publishers = array($press->getPrimaryLocale() => $publisherInstitution); } else { $publishers = $press->getName(null); // Default } $this->_addLocalizedElements($dc11Description, 'dc:publisher', $publishers); // Contributor $contributors = $monograph->getSponsor(null); if (is_array($contributors)) { foreach ($contributors as $locale => $contributor) { $contributors[$locale] = array_map('trim', explode(';', $contributor)); } $this->_addLocalizedElements($dc11Description, 'dc:contributor', $contributors); } // Date // FIXME: should we use the publication dates of the publication format? If yes, // in which role preference order? if (is_a($monograph, 'PublishedMonograph')) { if ($monograph->getDatePublished()) { $dc11Description->addStatement('dc:date', date('Y-m-d', strtotime($monograph->getDatePublished()))); } } // Type $types = array_merge_recursive(array(AppLocale::getLocale() => __('rt.metadata.pkp.dctype')), (array) $monograph->getType(null)); $this->_addLocalizedElements($dc11Description, 'dc:type', $types); // Format $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); $entryKeys = $onixCodelistItemDao->getCodes('List7'); // List7 is for object formats if ($publicationFormat->getEntryKey()) { $formatName = $entryKeys[$publicationFormat->getEntryKey()]; $dc11Description->addStatement('dc:format', $formatName); } // Identifier: URL if (is_a($monograph, 'PublishedMonograph')) { $dc11Description->addStatement('dc:identifier', Request::url($press->getPath(), 'catalog', 'book', array($monograph->getId()))); } // Public idntifiers (e.g. DOI, URN) $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true); foreach ((array) $pubIdPlugins as $plugin) { $pubId = $plugin->getPubId($publicationFormat); if ($pubId) { $dc11Description->addStatement('dc:identifier', $pubId); } } // Identifier: others $identificationCodeFactory = $publicationFormat->getIdentificationCodes(); while ($identificationCode = $identificationCodeFactory->next()) { $dc11Description->addStatement('dc:identifier', $identificationCode->getValue()); } // Source (press title and pages) $sources = $press->getName(null); $pages = $monograph->getPages(); if (!empty($pages)) { $pages = '; ' . $pages; } foreach ($sources as $locale => $source) { $sources[$locale] .= '; '; $sources[$locale] .= $pages; } $this->_addLocalizedElements($dc11Description, 'dc:source', $sources); // Language // Relation // Coverage $coverage = (array) $monograph->getCoverage(null); $this->_addLocalizedElements($dc11Description, 'dc:coverage', $coverage); // Rights $salesRightsFactory = $publicationFormat->getSalesRights(); while ($salesRight = $salesRightsFactory->next()) { $dc11Description->addStatement('dc:rights', $salesRight->getNameForONIXCode()); } Hookregistry::call('Dc11SchemaPublicationFormatAdapter::extractMetadataFromDataObject', array(&$this, $monograph, $press, &$dc11Description)); return $dc11Description; }
/** * @see MetadataDataObjectAdapter::extractMetadataFromDataObject() * @param $publicationFormat PublicationFormat * @return MetadataDescription */ function extractMetadataFromDataObject($publicationFormat) { assert(is_a($publicationFormat, 'PublicationFormat')); AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON); // Retrieve data that belongs to the publication format. $oaiDao = DAORegistry::getDAO('OAIDAO'); $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO'); $monographDao = DAORegistry::getDAO('MonographDAO'); $monograph = $publishedMonographDao->getById($publicationFormat->getMonographId()); $series = $oaiDao->getSeries($monograph->getSeriesId()); /* @var $series Series */ $press = $oaiDao->getPress($monograph->getPressId()); $chapterDao = DAORegistry::getDAO('ChapterDAO'); $chapters = $chapterDao->getChapters($monograph->getId()); $description = $this->instantiateMetadataDescription(); // Title $this->_addLocalizedElements($description, 'dc:title[@xsi:type="ddb:titleISO639-2"]', $monograph->getTitle(null)); // Creator $authors = $monograph->getAuthors(); foreach ($authors as $author) { $pc = new MetadataDescription('plugins.metadata.xmdp22.schema.Pc14NameSchema', ASSOC_TYPE_AUTHOR); $this->_checkForContentAndAddElement($pc, 'pc:person/pc:name[@type="nameUsedByThePerson"]/pc:foreName', $author->getFirstName()); $this->_checkForContentAndAddElement($pc, 'pc:person/pc:name[@type="nameUsedByThePerson"]/pc:surName', $author->getLastName()); $this->_checkForContentAndAddElement($description, 'dc:creator[@xsi:type="pc:MetaPers"]', $pc); } // Subject $subjects = array_merge_recursive((array) $monograph->getDiscipline(null), (array) $monograph->getSubject(null), (array) $monograph->getSubjectClass(null)); $this->_addLocalizedElements($description, 'dc:subject[@xsi:type="xMetaDiss:noScheme"]', $subjects); // Table of Contents // Abstract $this->_addLocalizedElements($description, 'dcterms:abstract[@xsi:type="ddb:contentISO639-2"]', $monograph->getAbstract(null)); // Publisher $publisherInstitution = $press->getSetting('publisherInstitution'); if (!empty($publisherInstitution)) { $publishers = array($press->getPrimaryLocale() => $publisherInstitution); } else { $publishers = $press->getName(null); // Default } // Corporate Core Institution Schema // Since composite elements cannot be localized, the content of this element is based on the primary press locale $cc = new MetadataDescription('plugins.metadata.xmdp22.schema.CC21InstitutionSchema', ASSOC_TYPE_PRESS); // Name $this->_checkForContentAndAddElement($cc, 'cc:universityOrInstitution/cc:name', $press->getName()[$press->getPrimaryLocale()]); // Address $metadataPlugins = PluginRegistry::loadCategory('metadata', true); $address = $press->getData("mailingAddress"); if (!$address) { $address = $metadataPlugins['Xmdp22MetadataPlugin']->getData("cc:address", $monograph->getPressId()); } $cc->addStatement('cc:address', $address); // Place $place = $address; $place = $metadataPlugins['Xmdp22MetadataPlugin']->getData("cc:place", $monograph->getPressId()); $cc->addStatement('cc:universityOrInstitution/cc:place', $place); $this->_checkForContentAndAddElement($description, 'dc:publisher[@xsi:type="cc:Publisher"]', $cc); // Contributor $contributors = $monograph->getSponsor(null); if (is_array($contributors)) { foreach ($contributors as $locale => $contributor) { $contributors[$locale] = array_map('trim', explode(';', $contributor)); } $this->_addLocalizedElements($description, 'dc:contributor', $contributors); } // Date submitted //$description->addStatement('dcterms:dateSubmitted', date('Y', strtotime($monograph->getDateSubmitted()))); // Issued $this->_checkForContentAndAddElement($description, 'dcterms:issued[@xsi:type="dcterms:W3CDTF"]', date('Y-m-d', strtotime($monograph->getDatePublished()))); // Type $types = array_merge_recursive(array_map('lcfirst', array(AppLocale::getLocale() => __('rt.metadata.pkp.dctype'))), array_map('lcfirst', (array) $monograph->getType(null))); $this->_addLocalizedElements($description, 'dc:type[@xsi:type="dini:PublType"]', $types); // Format $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); $entryKeys = $onixCodelistItemDao->getCodes('List7'); // List7 is for object formats if ($publicationFormat->getEntryKey()) { $formatName = $entryKeys[$publicationFormat->getEntryKey()]; $this->_checkForContentAndAddElement($description, 'dc:format', $formatName); } // Identifier(s) // dc:identifier: xsi:type=urn:nbn|doi|hdl (1, mandatory) // ddb:identifier: ddb:type=URL|URN|DOI|handle|VG-Wort-Pixel|URL_Frontdoor|URL_Publikation|Erstkat-ID|ISSN|other (many, optional) $pubIdPlugins = PluginRegistry::loadCategory('pubIds'); if (isset($pubIdPlugins) && array_key_exists('DOIPubIdPlugin', $pubIdPlugins) && $pubIdPlugins['DOIPubIdPlugin']->getEnabled() == true) { $doi = $pubIdPlugins['DOIPubIdPlugin']->getPubId($publicationFormat); } if (isset($pubIdPlugins) && array_key_exists('URNDNBPubIdPlugin', $pubIdPlugins) && $pubIdPlugins['URNDNBPubIdPlugin']->getEnabled() == true) { $urn_dnb = $pubIdPlugins['URNDNBPubIdPlugin']->getPubId($monograph); $namespaces = explode(':', $urn_dnb); $numberOfNamespaces = min(sizeof($namespaces), 3); $scheme = implode(":", array_slice($namespaces, 0, $numberOfNamespaces)); } if (isset($urn_dnb)) { $description->addStatement('dc:identifier', $urn_dnb . ' [@xsi:type="' . $scheme . '"]'); if (isset($doi)) { $description->addStatement('ddb:identifier', $doi . ' [@ddb:type="DOI"]'); } } else { if (isset($doi)) { $description->addStatement('dc:identifier', $doi . ' [@xsi:type="doi"]'); } } $this->_checkForContentAndAddElement($description, 'ddb:identifier', Request::url($press->getPath(), 'catalog', 'book', array($monograph->getId())) . ' [@ddb:type="URL_Frontdoor"]'); // Source (press title and pages) $sources = $press->getName(null); $pages = $monograph->getPages(); if (!empty($pages)) { $pages = '; ' . $pages; } foreach ($sources as $locale => $source) { $sources[$locale] .= '; '; $sources[$locale] .= $pages; } $this->_addLocalizedElements($description, 'dc:source', $sources); // Language $language = $monograph->getLanguage(); if (!$language) { $language = AppLocale::get3LetterFrom2LetterIsoLanguage(substr($press->getPrimaryLocale(), 0, 2)); } else { $language = AppLocale::get3LetterFrom2LetterIsoLanguage($language); } $this->_checkForContentAndAddElement($description, 'dc:language[@xsi:type="dcterms:ISO639-2"]', $language); // Relation // Coverage $coverage = array_merge_recursive((array) $monograph->getCoverageGeo(null), (array) $monograph->getCoverageChron(null), (array) $monograph->getCoverageSample(null)); $this->_addLocalizedElements($description, 'dc:coverage[@xsi:type="ddb:encoding" @ddb:Scheme="None"]', $coverage); // Rights $salesRightsFactory = $publicationFormat->getSalesRights(); while ($salesRight = $salesRightsFactory->next()) { $this->_checkForContentAndAddElement($description, 'dc:rights', $salesRight->getNameForONIXCode()); } // File transfer // Per default, only the full manuscript or a file of a custom genre // (set via settings form) is transferred. If several files of the same // genre are found for one publication format, the first is selected as // the transfer file per default. // Alternative configurations (e.g. container formats) are thinkable, but not implemented. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $availableFiles = array_filter($submissionFileDao->getLatestRevisions($monograph->getId()), create_function('$a', 'return $a->getViewable() && $a->getDirectSalesPrice() !== null && $a->getAssocType() == ASSOC_TYPE_PUBLICATION_FORMAT;')); $genreDao = DAORegistry::getDAO('GenreDAO'); $genreId = $metadataPlugins['Xmdp22MetadataPlugin']->getData("genre:id", $monograph->getPressId()); if (!isset($genreId)) { // if genre is not set, try to make monograph default // -- this fails if the press uses custom components and the default components // have been deleted $genreId = $genreDao->getByKey('MANUSCRIPT', $press->getId())->getId(); if (isset($genreId)) { $metadataPlugins['Xmdp22MetadataPlugin']->updateSetting($monograph->getPressId(), "genre_id", $genreId); } } $transferableFiles = array(); foreach ($availableFiles as $availableFile) { if ($availableFile->getAssocId() == $publicationFormat->getId() && $availableFile->getGenreId() == $genreId) { // Collect all files that belong to this publication format and have the selected genre $transferableFiles[] = $availableFile; } } // first file that fits criteria is transfered per default // -- another solution would be to place all files in a container here if ($transferableFiles) { $transferFile = $transferableFiles[0]; $transferableFiles = array($transferFile); } // Number of files (will always be 1, unless a container solution is implemented) $this->_checkForContentAndAddElement($description, 'ddb:fileNumber', sizeof($transferableFiles)); // File Properties and Transfer link if (isset($transferFile)) { $description->addStatement('ddb:fileProperties', '[@ddb:fileName="' . $transferFile->getServerFileName() . '" @ddbfileSize="' . $transferFile->getFileSize() . '"]'); $description->addStatement('ddb:transfer[@ddb:type="dcterms:URI"]', Request::url($press->getPath(), 'catalog', 'download', array($monograph->getId(), $publicationFormat->getId(), $transferFile->getFileIdAndRevision()))); } // Contact ID $contactId = $metadataPlugins['Xmdp22MetadataPlugin']->getData("ddb:contactID", $monograph->getPressId()); $this->_checkForContentAndAddElement($description, 'ddb:contact', '[@ddb:contactID="' . $contactId . '"]'); // Rights $kind = $metadataPlugins['Xmdp22MetadataPlugin']->getData("ddb:kind", $monograph->getPressId()); $description->addStatement('ddb:rights', '[@ddb:kind="' . $kind . '"]'); Hookregistry::call('Xmdp22SchemaPublicationFormatAdapter::extractMetadataFromDataObject', array(&$this, $monograph, $press, &$description)); return $description; }