/** * Create a Dataverse study: create deposit package with journal-, article-, * and suppfile-level metadata, then deposit in Dataverse to create study. * @param $article Article * @return DataverseStudy */ function createStudy($article) { $package = $this->createMetadataPackage($article); $client = $this->_initSwordClient(); $depositReceipt = $client->depositAtomEntry($this->getSetting($article->getJournalId(), 'dvUri'), $this->getSetting($article->getJournalId(), 'username'), $this->getSetting($article->getJournalId(), 'password'), '', $package->getAtomEntryFilePath()); $study = null; if ($depositReceipt->sac_status == DATAVERSE_PLUGIN_HTTP_STATUS_CREATED) { $this->import('classes.DataverseStudy'); $study = new DataverseStudy(); $study->setSubmissionId($article->getId()); $study->setEditUri($depositReceipt->sac_edit_iri); $study->setEditMediaUri($depositReceipt->sac_edit_media_iri); $study->setStatementUri($depositReceipt->sac_state_iri_atom); $study->setDataCitation($depositReceipt->sac_dcterms['bibliographicCitation'][0]); // Persistent URI may be present, as an altenate foreach ($depositReceipt->sac_links as $link) { if ($link->sac_linkrel == 'alternate') { $study->setPersistentUri($link->sac_linkhref); break; } } // Insert new Dataverse study for this submission $dataverseStudyDao =& DAORegistry::getDAO('DataverseStudyDAO'); $dataverseStudyDao->insertStudy($study); } return $study; }
/** * Internal function to return DataverseStudy object from a row. * @param $row array * @return DataverseStudy */ function &_returnStudyFromRow(&$row) { $dataversePlugin =& PluginRegistry::getPlugin('generic', $this->_parentPluginName); $dataversePlugin->import('classes.DataverseStudy'); $study = new DataverseStudy(); $study->setId($row['study_id']); $study->setSubmissionId($row['submission_id']); $study->setEditUri($row['edit_uri']); $study->setEditMediaUri($row['edit_media_uri']); $study->setStatementUri($row['statement_uri']); $study->setPersistentUri($row['persistent_uri']); $study->setDataCitation($row['data_citation']); return $study; }
/** * Update cataloguing information for an existing study. * @param Article $article * @param DataverseStudy $study * @return DataverseStudy */ function &updateStudy(&$article, &$study) { $journal =& Request::getJournal(); $packager = new DataversePackager(); // Add article metadata $packager->addMetadata('title', $article->getLocalizedTitle()); $packager->addMetadata('description', $article->getLocalizedAbstract()); foreach ($article->getAuthors() as $author) { $packager->addMetadata('creator', $author->getFullName(true)); } // subject: academic disciplines $split = '/\\s*' . DATAVERSE_PLUGIN_SUBJECT_SEPARATOR . '\\s*/'; foreach (preg_split($split, $article->getLocalizedDiscipline(), NULL, PREG_SPLIT_NO_EMPTY) as $subject) { $packager->addMetadata('subject', $subject); } // subject: subject classifications foreach (preg_split($split, $article->getLocalizedSubjectClass(), NULL, PREG_SPLIT_NO_EMPTY) as $subject) { $packager->addMetadata('subject', $subject); } // subject: keywords foreach (preg_split($split, $article->getLocalizedSubject(), NULL, PREG_SPLIT_NO_EMPTY) as $subject) { $packager->addMetadata('subject', $subject); } // geographic coverage foreach (preg_split($split, $article->getLocalizedCoverageGeo(), NULL, PREG_SPLIT_NO_EMPTY) as $coverage) { $packager->addMetadata('coverage', $coverage); } // rights $packager->addMetadata('rights', $journal->getLocalizedSetting('copyrightNotice')); // publisher $packager->addMetadata('publisher', $journal->getSetting('publisherInstitution')); // metadata for published articles: public IDs, publication dates $pubIdAttributes = array(); if ($article->getStatus() == STATUS_PUBLISHED) { // publication date $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($article->getId(), $article->getJournalId()); $datePublished = $publishedArticle->getDatePublished(); if (!$datePublished) { // If article has no pub date, use issue pub date $issueDao =& DAORegistry::getDAO('IssueDAO'); $issue =& $issueDao->getIssueByArticleId($article->getId(), $article->getJournalId()); $datePublished = $issue->getDatePublished(); } $packager->addMetadata('date', strftime('%Y-%m-%d', strtotime($datePublished))); // isReferencedBy: If article is published, add a persistent URL to citation using specified pubid plugin $pubIdPlugin =& PluginRegistry::getPlugin('pubIds', $this->getSetting($article->getJournalId(), 'pubIdPlugin')); if ($pubIdPlugin && $pubIdPlugin->getEnabled()) { $pubIdAttributes['agency'] = $pubIdPlugin->getDisplayName(); $pubIdAttributes['IDNo'] = $article->getPubId($pubIdPlugin->getPubIdType()); $pubIdAttributes['holdingsURI'] = $pubIdPlugin->getResolvingUrl($article->getJournalId(), $pubIdAttributes['IDNo']); } else { // If no pub id plugin selected, use OJS URL $pubIdAttributes['holdingsURI'] = Request::url($journal->getPath(), 'article', 'view', array($article->getId())); } } // isReferencedBy $packager->addMetadata('isReferencedBy', $this->getCitation($article), $pubIdAttributes); // Include (some) suppfile metadata in study $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $dataverseFileDao =& DAORegistry::getDAO('DataverseFileDAO'); $dvFiles =& $dataverseFileDao->getDataverseFilesByStudyId($study->getId()); foreach ($dvFiles as $dvFile) { $suppFile =& $suppFileDao->getSuppFile($dvFile->getSuppFileId(), $article->getId()); if (isset($suppFile)) { // subject foreach (preg_split($split, $suppFile->getSuppFileSubject(), NULL, PREG_SPLIT_NO_EMPTY) as $subject) { $packager->addMetadata('subject', $subject); } // Type of file if ($suppFile->getType()) { $packager->addMetadata('type', $suppFile->getType()); } // Type of file, user-defined: if ($suppFile->getSuppFileTypeOther()) { $packager->addMetadata('type', $suppFile->getSuppFileTypeOther()); } } } // Write atom entry to file $packager->createAtomEntry(); // Update the study in Dataverse $client = $this->_initSwordClient(); $depositReceipt = $client->replaceMetadata($study->getEditUri(), $this->getSetting($article->getJournalId(), 'username'), $this->getSetting($article->getJournalId(), 'password'), '', $packager->getAtomEntryFilePath()); if ($depositReceipt->sac_status != DATAVERSE_PLUGIN_HTTP_STATUS_OK) { return false; } // Updating the metadata may have updated the data citation $study->setDataCitation($depositReceipt->sac_dcterms['bibliographicCitation'][0]); $dataverseStudyDao =& DAORegistry::getDAO('DataverseStudyDAO'); $dataverseStudyDao->updateStudy($study); return $study; }