Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #44

Merged
merged 15 commits into from
Oct 15, 2024
25 changes: 24 additions & 1 deletion Classes/Command/HealthCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ protected function removeDoubleWorks(): void
$this->io->section('Removing double works');
$publishedItems = $this->publishedItemRepository->findAll();
$this->io->progressStart(count($publishedItems));

$works = [];
foreach ($publishedItems as $publishedItem) {
$this->io->progressAdvance();
foreach ($publishedItem->getContainedWorks() as $work) {
Expand All @@ -172,7 +174,11 @@ protected function removeDoubleWorks(): void
}
foreach ($publishedItem->getPublishedSubitems() as $publishedSubitem) {
foreach ($publishedSubitem->getContainedWorks() as $work) {
if (isset($works[$work->getGndId()]) && $works[$work->getGndId()]->getUid() != $work->getUid()) {
if (
isset($works[$work->getGndId()]) &&
$works[$work->getGndId()]->getUid() != $work->getUid() &&
$work->getGndId() != 'lokal'
) {
$publishedSubitem->removeContainedWork($work);
$publishedSubitem->addContainedWork($works[$work->getGndId()]);
$this->io->text('detected double ' . $work->getGndId() . ', ' . $work->getFullTitle() . '.');
Expand Down Expand Up @@ -258,6 +264,8 @@ protected function removeUnusedWorks(): void
{
$this->io->section('Removing unused works');
$publishedItems = $this->publishedItemRepository->findAll();

// check works linked in published items and subitems
foreach ($publishedItems as $publishedItem) {
foreach ($publishedItem->getContainedWorks() as $work) {
$works[$work->getUid()] = $work;
Expand All @@ -268,6 +276,21 @@ protected function removeUnusedWorks(): void
}
}
}

// check works linked as super works
while (true) {
$initialWorkCount = count($works);
foreach ($works as $work) {
if($work->getSuperWork() != null) {
$works[$work->getSuperWork()->getUid()] = $work->getSuperWork();
}
}
$newWorkCount = count($works);
if ($initialWorkCount == $newWorkCount) {
break;
}
}

$worksFromDb = $this->workRepository->findAll();
$this->io->progressStart(count($works));
foreach ($worksFromDb as $work) {
Expand Down
22 changes: 20 additions & 2 deletions Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Elastic\Elasticsearch\Client;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -85,6 +86,7 @@ class IndexCommand extends Command
[ 'type', '', 'string' ],
[ 'mvdb_id', '', 'string' ],
[ 'piano_combination', '', 'string' ],
[ 'public_comment', 'comment', 'string' ],
[ 'final', '', '' ] ];
protected static $actionData = [
[ 'quantity', '', 'int' ],
Expand Down Expand Up @@ -787,16 +789,30 @@ protected function fetchObjects(): void

if ($name == 'published_item') {
$qb->where(
$eb->notLike('mvdb_id', $qb->createNamedParameter('AA%'))
$eb->notLike('mvdb_id', $qb->createNamedParameter('AA%')),
$eb->eq('final', 2)
);
}

$data = $qb->execute()->fetchAll();
if ($name == 'person') {
$data = Collection::wrap($data)->
map(function ($person) { return self::removeSortingSymbols($person); });
}

$this->dataObjects[$name] = $data;
}
}

protected static function removeSortingSymbols(array $person): array
{
$name = Str::of($person['name'])->
replace('˜', '')->
replace('œ', '');
$person['name'] = $name;
return $person;
}

/**
* Executes an indexing sequence
*
Expand Down Expand Up @@ -861,7 +877,9 @@ protected function index(array $config, array $bufferedObject = null): array
foreach($mmObjects as $object) {
$subKey = $object[$subKeyField];
$superKey = $object[$superKeyField];
$indexedObjects[$superKey][] = isset($subDataObjects[$subKey][0]) ? $subDataObjects[$subKey][0] : null;
if (isset($subDataObjects[$subKey][0])) {
$indexedObjects[$superKey][] = $subDataObjects[$subKey][0];
}
}
} else {
$subDataObjects = $bufferedObject ?? $this->dataObjects[$config['subObject']];
Expand Down
28 changes: 28 additions & 0 deletions Classes/Domain/Model/PublishedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ class PublishedItem extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $comment = '';

/**
* publicComment
*
* @var string
*/
protected $publicComment = '';

/**
* publisher
*
Expand Down Expand Up @@ -1009,6 +1016,16 @@ protected static function getSubitemPlateId(PublishedSubitem $subitem): string
return $subitem->getPlateId();
}

/**
* Returns the public comment
*
* @return string $publicComment
*/
public function getPublicComment(): string
{
return $this->publicComment;
}

/**
* Returns the comment
*
Expand All @@ -1019,6 +1036,17 @@ public function getComment(): string
return $this->comment;
}

/**
* Sets the public comment
*
* @param string $publicComment
* @return void
*/
public function setPublicComment(string $publicComment): void
{
$this->publicComment = $publicComment;
}

/**
* Sets the comment
*
Expand Down
16 changes: 13 additions & 3 deletions Configuration/TCA/tx_mpdbcore_domain_model_publisheditem.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
'starttime' => 'starttime',
'endtime' => 'endtime',
],
'searchFields' => 'title,type,instrumentation,responsible_person,language,id,comment',
'searchFields' => 'title,type,instrumentation,responsible_person,language,id,comment,public_comment',
'iconfile' => 'EXT:mpdb_core/Resources/Public/Icons/tx_mpdbcore_domain_model_publishermakroitem.gif'
],
'interface' => [
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, type, instrumentation, data_acquisition_certain, related_persons_known, work_examined, data_set_manually_checked, contained_works_identified, responsible_person, date_of_publishing, final, language, id, comment, contained_works, editors, instruments, genre, first_composer, published_subitems, publisher',
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, type, instrumentation, data_acquisition_certain, related_persons_known, work_examined, data_set_manually_checked, contained_works_identified, responsible_person, date_of_publishing, final, language, id, comment, public_comment, contained_works, editors, instruments, genre, first_composer, published_subitems, publisher',
],
'types' => [
'1' => ['showitem' => 'title, type, instrumentation, data_acquisition_certain, related_persons_known, work_examined, data_set_manually_checked, contained_works_identified, responsible_person, date_of_publishing, final, language, id, comment, contained_works, editors, instruments, genre, first_composer, published_subitems, publisher, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, sys_language_uid, l10n_parent, l10n_diffsource, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, hidden, starttime, endtime'],
'1' => ['showitem' => 'title, type, instrumentation, data_acquisition_certain, related_persons_known, work_examined, data_set_manually_checked, contained_works_identified, responsible_person, date_of_publishing, final, language, id, comment, public_comment, contained_works, editors, instruments, genre, first_composer, published_subitems, publisher, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, sys_language_uid, l10n_parent, l10n_diffsource, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, hidden, starttime, endtime'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -284,6 +284,16 @@
'eval' => 'trim'
]
],
'public_comment' => [
'exclude' => true,
'label' => 'LLL:EXT:mpdb_core/Resources/Private/Language/locallang_db.xlf:tx_mpdbcore_domain_model_publisheditem.public_comment',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 15,
'eval' => 'trim'
]
],
'contained_works' => [
'exclude' => true,
'label' => 'enthaltene Werke',
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<trans-unit id="tx_mpdbcore_domain_model_publisheditem.comment" resname="tx_mpdbcore_domain_model_publisheditem.comment" approved="yes">
<source>comment</source>
</trans-unit>
<trans-unit id="tx_mpdbcore_domain_model_publisheditem.public_comment" resname="tx_mpdbcore_domain_model_publisheditem.public_comment" approved="yes">
<source>public comment</source>
</trans-unit>
<trans-unit id="tx_mpdbcore_domain_model_publisheditem.contained_works" resname="tx_mpdbcore_domain_model_publisheditem.contained_works" approved="yes">
<source>contained works</source>
</trans-unit>
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"elasticsearch/elasticsearch": "^8",
"slub/dm-ont": "@dev",
"fluidtypo3/vhs": "^6",
"illuminate/collections": "^8"
"illuminate/collections": "^8",
"illuminate/support": "^8"
},
"config": {
"allow-plugins": {
Expand Down
3 changes: 2 additions & 1 deletion ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CREATE TABLE tx_mpdbcore_domain_model_publishedsubitem (
db_identifier int(11) DEFAULT '0' NOT NULL,
contained_works int(11) unsigned DEFAULT '0' NOT NULL,
publisher_actions int(11) unsigned DEFAULT '0' NOT NULL,
mvdb_id varchar(255) DEFAULT '' NOT NULL
mvdb_id varchar(255) DEFAULT '' NOT NULL

);

Expand All @@ -51,6 +51,7 @@ CREATE TABLE tx_mpdbcore_domain_model_publisheditem (
mvdb_id varchar(255) DEFAULT '' NOT NULL,
plate_ids varchar(255) DEFAULT '' NOT NULL,
comment text,
public_comment text,
contained_works int(11) unsigned DEFAULT '0' NOT NULL,
editors int(11) unsigned DEFAULT '0' NOT NULL,
instruments int(11) unsigned DEFAULT '0' NOT NULL,
Expand Down