Respect deleted records policy

This commit is contained in:
Sebastian Meyer 2024-01-04 15:33:28 +01:00
parent 7188f37c9f
commit 00d4dc80cc
2 changed files with 18 additions and 12 deletions

View File

@ -24,7 +24,6 @@ namespace OCC\OaiPmh2\Console;
use DateTime;
use OCC\OaiPmh2\Database;
use OCC\OaiPmh2\Database\Record;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@ -160,6 +159,7 @@ class CsvImportCommand extends Command
}
}
Database::getInstance()->flush(true);
Database::getInstance()->pruneOrphanSets();
$output->writeln([
'',

View File

@ -129,6 +129,11 @@ class Database
$format = $this->entityManager->getReference(Format::class, $format);
}
$record = $this->entityManager->find(Record::class, ['identifier' => $identifier, 'format' => $format]);
if (!isset($data) && Configuration::getInstance()->deletedRecords === 'no') {
if (isset($record)) {
$this->entityManager->remove($record);
}
} else {
if (isset($record)) {
try {
$record->setContent($data);
@ -144,6 +149,7 @@ class Database
}
}
$this->entityManager->persist($record);
}
if (!$bulkMode) {
$this->entityManager->flush();
}