From 53c5b99dacec52368de9ed359e955e1177fd03a2 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 11 Jul 2023 10:52:18 +0200 Subject: [PATCH 1/2] [BUGFIX] Persist collection to prevent duplicates (#983) --- Classes/Command/BaseCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 0fd39da1f..2db397582 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -176,6 +176,7 @@ protected function saveToDatabase(Document $document) if ($doc === null) { return false; } + $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $doc->cPid = $this->storagePid; $metadata = $doc->getTitledata($this->storagePid); @@ -212,6 +213,8 @@ protected function saveToDatabase(Document $document) $documentCollection->setDescription(''); // add to CollectionRepository $this->collectionRepository->add($documentCollection); + // persist collection to prevent duplicates + $persistenceManager->persistAll(); } // add to document $document->addCollection($documentCollection); @@ -273,7 +276,6 @@ protected function saveToDatabase(Document $document) $this->documentRepository->update($document); } - $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $persistenceManager->persistAll(); return true; From f78b6b3162efee0c42e751b2ff54a32937dc942a Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 20 Jul 2023 15:15:37 +0200 Subject: [PATCH 2/2] [FEATURE] Use order in case volume_sorting is empty (#984) --- Classes/Command/BaseCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 2db397582..d6309b0fc 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -195,7 +195,7 @@ protected function saveToDatabase(Document $document) $document->setAuthor(implode('; ', $metadata['author'])); $document->setThumbnail($doc->thumbnail ? : ''); $document->setMetsLabel($metadata['mets_label'][0] ? : ''); - $document->setMetsOrderlabel($metadata['mets_orderlabel'][0] ? : $metadata['mets_order'][0] ? : ''); + $document->setMetsOrderlabel($metadata['mets_orderlabel'][0] ? : ''); $structure = $this->structureRepository->findOneByIndexName($metadata['type'][0], 'tx_dlf_structures'); $document->setStructure($structure); @@ -261,7 +261,7 @@ protected function saveToDatabase(Document $document) // set volume data $document->setVolume($metadata['volume'][0] ? : ''); - $document->setVolumeSorting($metadata['volume_sorting'][0] ? : ''); + $document->setVolumeSorting($metadata['volume_sorting'][0] ? : $metadata['mets_order'][0] ? : ''); // Get UID of parent document. if ($document->getDocumentFormat() === 'METS') {