* along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Application * @author Thoralf Klein <*****@*****.**> * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id: find_urns_for_docs_without_visible_files.php 11775 2013-06-25 14:28:41Z tklein $ */ /** * Dieses Script sucht Dokumente ohne sichtbare Dateien, fuer die bereits * eine URN vergeben wurde. */ $updateRequired = 0; $docfinder = new Opus_DocumentFinder(); $docfinder->setIdentifierTypeExists('urn'); echo "checking documents...\n"; foreach ($docfinder->ids() as $docId) { $doc = new Opus_Document($docId); $numVisibleFiles = 0; foreach ($doc->getFile() as $file) { if ($file->getVisibleInOai() == 1) { $numVisibleFiles++; } } if ($numVisibleFiles > 0) { continue; } echo "-- document {$docId} has an URN " . $doc->getIdentifierUrn(0)->getValue() . ", but no visible files\n"; } if ($updateRequired == 0) {
/** * Retrieve all document ids for a valid oai request. * * @param array &$oaiRequest * @return array */ public function query(array $oaiRequest) { $finder = new Opus_DocumentFinder(); // add server state restrictions $finder->setServerStateInList($this->deliveringDocumentStates); $metadataPrefix = $oaiRequest['metadataPrefix']; if ('xMetaDissPlus' === $metadataPrefix || 'xMetaDiss' === $metadataPrefix) { $finder->setFilesVisibleInOai(); } if ('xMetaDiss' === $metadataPrefix) { $finder->setTypeInList($this->xMetaDissRestriction); } if ('epicur' === $metadataPrefix) { $finder->setIdentifierTypeExists('urn'); } if (array_key_exists('set', $oaiRequest)) { $setarray = explode(':', $oaiRequest['set']); if (!isset($setarray[0])) { return array(); } if ($setarray[0] == 'doc-type') { if (count($setarray) === 2 and !empty($setarray[1])) { $finder->setType($setarray[1]); } else { return array(); } } else { if ($setarray[0] == 'bibliography') { if (count($setarray) !== 2 or empty($setarray[1])) { return array(); } $setValue = $setarray[1]; $bibliographyMap = array("true" => 1, "false" => 0); if (false === isset($setValue, $bibliographyMap[$setValue])) { return array(); } $finder->setBelongsToBibliography($bibliographyMap[$setValue]); } else { if (count($setarray) < 1 or count($setarray) > 2) { $msg = "Invalid SetSpec: Must be in format 'set:subset'."; throw new Oai_Model_Exception($msg); } // Trying to locate collection role and filter documents. $role = Opus_CollectionRole::fetchByOaiName($setarray[0]); if (is_null($role)) { $msg = "Invalid SetSpec: Top level set does not exist."; throw new Oai_Model_Exception($msg); } $finder->setCollectionRoleId($role->getId()); // Trying to locate given collection and filter documents. if (count($setarray) == 2) { $subsetName = $setarray[1]; $foundSubsets = array_filter($role->getOaiSetNames(), function ($s) use($subsetName) { return $s['oai_subset'] === $subsetName; }); if (count($foundSubsets) < 1) { $msg = "Invalid SetSpec: Subset does not exist."; throw new Oai_Model_Exception($msg); } foreach ($foundSubsets as $subset) { if ($subset['oai_subset'] !== $subsetName) { $msg = "Invalid SetSpec: Internal error."; throw new Oai_Model_Exception($msg); } $finder->setCollectionId($subset['id']); } } } } } if (array_key_exists('from', $oaiRequest) and !empty($oaiRequest['from'])) { $from = DateTime::createFromFormat('Y-m-d', $oaiRequest['from']); $finder->setServerDateModifiedAfter($from->format('Y-m-d')); } if (array_key_exists('until', $oaiRequest)) { $until = DateTime::createFromFormat('Y-m-d', $oaiRequest['until']); $until->add(new DateInterval('P1D')); $finder->setServerDateModifiedBefore($until->format('Y-m-d')); } return $finder->ids(); }