17 import(
'lib.pkp.classes.oai.PKPOAIDAO');
18 import(
'classes.issue.Issue');
37 parent::__construct();
44 $this->journalCache = array();
45 $this->sectionCache = array();
60 if (!isset($this->journalCache[$journalId])) {
61 $this->journalCache[$journalId] = $this->journalDao->getById($journalId);
63 return $this->journalCache[$journalId];
72 if (!isset($this->issueCache[$issueId])) {
73 $this->issueCache[$issueId] = $this->issueDao->getById($issueId);
75 return $this->issueCache[$issueId];
84 if (!isset($this->sectionCache[$sectionId])) {
85 $this->sectionCache[$sectionId] = $this->sectionDao->getById($sectionId);
87 return $this->sectionCache[$sectionId];
102 if (isset($journalId)) {
103 $journals = array($this->journalDao->getById($journalId));
105 $journals = $this->journalDao->getAll(
true);
106 $journals = $journals->toArray();
111 foreach ($journals as $journal) {
112 $title = $journal->getLocalizedName();
113 $abbrev = $journal->getPath();
114 array_push($sets,
new OAISet(urlencode($abbrev), $title,
''));
117 $articleTombstoneSets = $tombstoneDao->getSets(ASSOC_TYPE_JOURNAL, $journal->getId());
119 $sections = $this->sectionDao->getByJournalId($journal->getId());
120 foreach ($sections->toArray() as $section) {
121 if (array_key_exists(urlencode($abbrev) .
':' . urlencode($section->getLocalizedAbbrev()), $articleTombstoneSets)) {
122 unset($articleTombstoneSets[urlencode($abbrev) .
':' . urlencode($section->getLocalizedAbbrev())]);
124 array_push($sets,
new OAISet(urlencode($abbrev) .
':' . urlencode($section->getLocalizedAbbrev()), $section->getLocalizedTitle(),
''));
126 foreach ($articleTombstoneSets as $articleTombstoneSetSpec => $articleTombstoneSetName) {
127 array_push($sets,
new OAISet($articleTombstoneSetSpec, $articleTombstoneSetName,
''));
131 HookRegistry::call(
'OAIDAO::getJournalSets', array($this, $journalId, $offset, $limit, $total, &$sets));
133 $total = count($sets);
134 $sets = array_slice($sets, $offset, $limit);
147 $journal =& $this->journalDao->getByPath($journalSpec);
148 if (!isset($journal) || (isset($restrictJournalId) && $journal->getId() != $restrictJournalId)) {
152 $journalId = $journal->getId();
155 if (isset($sectionSpec)) {
156 $section = $this->sectionDao->getByAbbrev($sectionSpec, $journal->getId());
157 if (isset($section)) {
158 $sectionId = $section->getId();
164 return array($journalId, $sectionId);
174 $journal = $this->
getJournal($row[
'journal_id']);
175 $section = $this->
getSection($row[
'section_id']);
176 $articleId = $row[
'submission_id'];
178 $record->identifier = $this->oai->articleIdToIdentifier($articleId);
179 $record->
sets = array(urlencode($journal->getPath()) .
':' . urlencode($section->getLocalizedAbbrev()));
183 $issue = $this->
getIssue($row[
'issue_id']);
184 $galleys = $this->articleGalleyDao->getByPublicationId($submission->getCurrentPublication()->getId())->toArray();
186 $record->setData(
'article', $submission);
187 $record->setData(
'journal', $journal);
188 $record->setData(
'section', $section);
189 $record->setData(
'issue', $issue);
190 $record->setData(
'galleys', $galleys);
207 function _getRecordsRecordSet($setIds, $from, $until, $set, $submissionId =
null, $orderBy =
'journal_id, submission_id') {
208 $journalId = array_shift($setIds);
209 $sectionId = array_shift($setIds);
211 $params = array(
'enableOai', (
int) STATUS_PUBLISHED);
212 if (isset($journalId)) $params[] = (int) $journalId;
213 if (isset($sectionId)) $params[] = (
int) $sectionId;
214 if ($submissionId) $params[] = (int) $submissionId;
215 if (isset($journalId)) $params[] = (
int) $journalId;
216 if (isset($sectionId)) $params[] = (
int) $sectionId;
219 $params[] = $set .
':%';
221 if ($submissionId) $params[] = (int) $submissionId;
223 'SELECT GREATEST(a.last_modified, i.last_modified) AS last_modified,
224 a.submission_id AS submission_id,
225 j.journal_id AS journal_id,
226 s.section_id AS section_id,
228 NULL AS tombstone_id,
230 NULL AS oai_identifier
233 JOIN publications p ON (a.current_publication_id = p.publication_id)
234 JOIN publication_settings psissue ON (psissue.publication_id = p.publication_id AND psissue.setting_name=\'issueId\')
235 JOIN issues i ON (CAST(i.issue_id AS CHAR) = psissue.setting_value)
236 JOIN sections s ON (s.section_id = p.section_id)
237 JOIN journals j ON (j.journal_id = a.context_id)
238 JOIN journal_settings jsoai ON (jsoai.journal_id = j.journal_id AND jsoai.setting_name=? AND jsoai.setting_value=\'1\')
239 WHERE i.published = 1 AND j.enabled = 1 AND a.status = ?
240 ' . (isset($journalId) ?
' AND j.journal_id = ?':
'') .
'
241 ' . (isset($sectionId) ?
' AND p.section_id = ?':
'') .
'
242 ' . ($from?
' AND GREATEST(a.last_modified, i.last_modified) >= ' . $this->
datetimeToDB($from):
'') .
'
243 ' . ($until?
' AND GREATEST(a.last_modified, i.last_modified) <= ' . $this->
datetimeToDB($until):
'') .
'
244 ' . ($submissionId?
' AND a.submission_id = ?':
'') .
'
246 SELECT dot.date_deleted AS last_modified,
247 dot.data_object_id AS submission_id,
248 ' . (isset($journalId) ?
'tsoj.assoc_id' :
'NULL') .
' AS assoc_id,' .
'
249 ' . (isset($sectionId)?
'tsos.assoc_id' :
'NULL') .
' AS section_id,
254 FROM data_object_tombstones dot' .
'
255 ' . (isset($journalId) ?
'JOIN data_object_tombstone_oai_set_objects tsoj ON (tsoj.tombstone_id = dot.tombstone_id AND tsoj.assoc_type = ' . ASSOC_TYPE_JOURNAL .
' AND tsoj.assoc_id = ?)' :
'') .
'
256 ' . (isset($sectionId)?
'JOIN data_object_tombstone_oai_set_objects tsos ON (tsos.tombstone_id = dot.tombstone_id AND tsos.assoc_type = ' . ASSOC_TYPE_SECTION .
' AND tsos.assoc_id = ?)' :
'') .
'
258 ' . (isset($set)?
' AND (dot.set_spec = ? OR dot.set_spec LIKE ?)':
'') .
'
259 ' . ($from?
' AND dot.date_deleted >= ' . $this->
datetimeToDB($from):
'') .
'
260 ' . ($until?
' AND dot.date_deleted <= ' . $this->
datetimeToDB($until):
'') .
'
261 ' . ($submissionId?
' AND dot.data_object_id = ?':
'') .
'
262 ORDER BY ' . $orderBy,