Skip to content

Commit

Permalink
Merge branch 'master' into move-solr-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-meyer authored Jul 20, 2023
2 parents 912a17d + f78b6b3 commit 5145cd4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -194,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);
Expand All @@ -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);
Expand Down Expand Up @@ -258,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') {
Expand All @@ -273,7 +276,6 @@ protected function saveToDatabase(Document $document)
$this->documentRepository->update($document);
}

$persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
$persistenceManager->persistAll();

return true;
Expand Down

0 comments on commit 5145cd4

Please sign in to comment.