/** * 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; }
/** * Delete draft study or deaccession released study. * @param DataverseStudy $study * @return boolean Study deleted */ function deleteStudy(&$study) { $journal =& Request::getJournal(); $client = $this->_initSwordClient(); $response = $client->deleteContainer($study->getEditUri(), $this->getSetting($journal->getId(), 'username'), $this->getSetting($journal->getId(), 'password'), ''); // on behalf of $studyDeleted = $response->sac_status == DATAVERSE_PLUGIN_HTTP_STATUS_NO_CONTENT; // Notify on success or failure import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $user =& Request::getUser(); if ($studyDeleted) { $dvFileDao =& DAORegistry::getDAO('DataverseFileDAO'); $dvFileDao->deleteDataverseFilesByStudyId($study->getId()); $dataverseStudyDao = DAORegistry::getDAO('DataverseStudyDAO'); $dataverseStudyDao->deleteStudy($study); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_DATAVERSE_STUDY_DELETED); } else { $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR); } return $studyDeleted; }