Respect deleted records policy
This commit is contained in:
parent
7188f37c9f
commit
00d4dc80cc
|
@ -24,7 +24,6 @@ namespace OCC\OaiPmh2\Console;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use OCC\OaiPmh2\Database;
|
use OCC\OaiPmh2\Database;
|
||||||
use OCC\OaiPmh2\Database\Record;
|
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
@ -160,6 +159,7 @@ class CsvImportCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Database::getInstance()->flush(true);
|
Database::getInstance()->flush(true);
|
||||||
|
Database::getInstance()->pruneOrphanSets();
|
||||||
|
|
||||||
$output->writeln([
|
$output->writeln([
|
||||||
'',
|
'',
|
||||||
|
|
|
@ -129,21 +129,27 @@ class Database
|
||||||
$format = $this->entityManager->getReference(Format::class, $format);
|
$format = $this->entityManager->getReference(Format::class, $format);
|
||||||
}
|
}
|
||||||
$record = $this->entityManager->find(Record::class, ['identifier' => $identifier, 'format' => $format]);
|
$record = $this->entityManager->find(Record::class, ['identifier' => $identifier, 'format' => $format]);
|
||||||
if (isset($record)) {
|
if (!isset($data) && Configuration::getInstance()->deletedRecords === 'no') {
|
||||||
try {
|
if (isset($record)) {
|
||||||
$record->setContent($data);
|
$this->entityManager->remove($record);
|
||||||
$record->setLastChanged($lastChanged);
|
|
||||||
} catch (ValidationFailedException $exception) {
|
|
||||||
throw $exception;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
if (isset($record)) {
|
||||||
$record = new Record($identifier, $format, $data, $lastChanged);
|
try {
|
||||||
} catch (ValidationFailedException $exception) {
|
$record->setContent($data);
|
||||||
throw $exception;
|
$record->setLastChanged($lastChanged);
|
||||||
|
} catch (ValidationFailedException $exception) {
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$record = new Record($identifier, $format, $data, $lastChanged);
|
||||||
|
} catch (ValidationFailedException $exception) {
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->entityManager->persist($record);
|
||||||
}
|
}
|
||||||
$this->entityManager->persist($record);
|
|
||||||
if (!$bulkMode) {
|
if (!$bulkMode) {
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue