From f1b154a1f201527fc28385576dc3b83f2fd52f30 Mon Sep 17 00:00:00 2001 From: haogatyp Date: Wed, 18 Dec 2024 14:41:10 +0100 Subject: [PATCH] #1959: Extended search: Make publication identifiers searchable. --- .../ClientConfigurationManager.php | 5 ++++ Classes/Domain/Model/Client.php | 15 ++++++++++++ Classes/Services/Api/InternalFormat.php | 24 +++++++++++++++++++ .../Services/ElasticSearch/ElasticSearch.php | 4 ++++ .../TCA/tx_dpf_domain_model_client.php | 20 ++++++++++++++-- .../Private/Language/de.locallang_db.xlf | 8 +++++++ Resources/Private/Language/locallang_db.xlf | 6 +++++ ext_tables.sql | 1 + 8 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Classes/Configuration/ClientConfigurationManager.php b/Classes/Configuration/ClientConfigurationManager.php index efd7a97c..49def4a7 100644 --- a/Classes/Configuration/ClientConfigurationManager.php +++ b/Classes/Configuration/ClientConfigurationManager.php @@ -253,6 +253,11 @@ public function getAdditionalSearchTitleXpaths() return $this->getSetting("additionalSearchTitleXpaths"); } + public function getAdditionalIdentifierXpaths() + { + return $this->getSetting("additionalIdentifierXpaths"); + } + public function getNamespaces() { return $this->getSetting("namespaces"); diff --git a/Classes/Domain/Model/Client.php b/Classes/Domain/Model/Client.php index 89ed47ab..ea3cfd2b 100644 --- a/Classes/Domain/Model/Client.php +++ b/Classes/Domain/Model/Client.php @@ -732,6 +732,11 @@ class Client extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity */ protected $additionalSearchTitleXpaths = ''; + /** + * @var string + */ + protected $additionalIdentifierXpaths = ''; + /** * Returns the project * @@ -2569,4 +2574,14 @@ public function setAdditionalSearchTitleXpaths(string $additionalSearchTitleXpat { $this->additionalSearchTitleXpaths = $additionalSearchTitleXpaths; } + + public function getAdditionalIdentifierXpaths(): string + { + return $this->additionalIdentifierXpaths; + } + + public function setIdentifierXpaths(string $additionalIdentifierXpaths): void + { + $this->additionalIdentifierXpaths = $additionalIdentifierXpaths; + } } diff --git a/Classes/Services/Api/InternalFormat.php b/Classes/Services/Api/InternalFormat.php index 284a591a..15cdc6e6 100644 --- a/Classes/Services/Api/InternalFormat.php +++ b/Classes/Services/Api/InternalFormat.php @@ -474,6 +474,30 @@ public function getSearchTitles(): array return $values; } + /** + * @return array + */ + public function getSearchIdentifiers(): array + { + $additionalIdentifierXpaths = $this->clientConfigurationManager->getAdditionalIdentifierXpaths(); + $additionalIdentifierXpathList = explode(";", trim($additionalIdentifierXpaths, " ;")); + $xpath = $this->getXpath(); + $values = []; + + foreach ($additionalIdentifierXpathList as $additionalIdentifierXpathItem) { + if (empty($additionalIdentifierXpathItem)) continue; + + $elements = $xpath->query(self::rootNode . trim($additionalIdentifierXpathItem)); + + if ($elements) foreach ($elements as $element) { + $values[] = trim($element->nodeValue); + } + } + + return $values; + } + + /** * @return array */ diff --git a/Classes/Services/ElasticSearch/ElasticSearch.php b/Classes/Services/ElasticSearch/ElasticSearch.php index 7dfc456f..126114e5 100644 --- a/Classes/Services/ElasticSearch/ElasticSearch.php +++ b/Classes/Services/ElasticSearch/ElasticSearch.php @@ -293,6 +293,10 @@ public function index(Document $document, $refresh = 'wait_for') $data->identifier[] = $document->getObjectIdentifier(); $data->identifier[] = $document->getProcessNumber(); + foreach ($internalFormat->getSearchIdentifiers() as $searchIdentifier) { + $data->identifier[] = $searchIdentifier; + } + if ($document->getCreator()) { $data->creator = $document->getCreator(); } else { diff --git a/Configuration/TCA/tx_dpf_domain_model_client.php b/Configuration/TCA/tx_dpf_domain_model_client.php index 36d63085..6ff25e2c 100644 --- a/Configuration/TCA/tx_dpf_domain_model_client.php +++ b/Configuration/TCA/tx_dpf_domain_model_client.php @@ -62,7 +62,7 @@ text_type_xpath, open_access_xpath, peer_review_xpath, peer_review_other_version_xpath, license_xpath, validation_xpath, date_issued_xpath, framework_agreement_id_xpath, search_year_xpaths, publisher_xpaths, - project_id_xpath, project_title_xpath','additional_search_title_xpaths', + project_id_xpath, project_title_xpath, additional_search_title_xpaths, additional_identifier_xpaths', 'iconfile' => 'EXT:dpf/Resources/Public/Icons/default.gif', ), 'interface' => array( @@ -96,7 +96,7 @@ text_type_xpath, open_access_xpath, peer_review_xpath, peer_review_other_version_xpath, license_xpath, validation_xpath, date_issued_xpath, framework_agreement_id_xpath, search_year_xpaths, publisher_xpaths, - project_id_xpath, project_title_xpath, additional_search_title_xpaths' + project_id_xpath, project_title_xpath, additional_search_title_xpaths, additional_identifier_xpaths' ), 'types' => array( '1' => array('showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, --palette--;;1, @@ -121,6 +121,7 @@ --pallette--;;pallette_project_id_xpath, --pallette--;;pallette_project_title_xpath, --pallette--;;pallette_additional_search_title_xpaths, + --pallette--;;pallette_additional_identifier_xpaths, --div--;Fedora, fedora_host, fedora_user, fedora_password, fedora_endpoint, fedora_root_container, fedora_collection_namespace, --div--;Elastic search, elastic_search_host, elastic_search_port, elastic_search_index_name, --div--;Upload, upload_directory, upload_domain, @@ -193,6 +194,10 @@ 'label' => 'LLL:EXT:dpf/Resources/Private/Language/locallang_db.xlf:tx_dpf_domain_model_client.search_field_xml.additional_search_title.label', 'showitem' => 'additional_search_title_xpaths' ), + 'pallette_additional_identifier_xpaths' => array( + 'label' => 'LLL:EXT:dpf/Resources/Private/Language/locallang_db.xlf:tx_dpf_domain_model_client.search_field_xml.additional_identifiers.label', + 'showitem' => 'additional_identifier_xpaths' + ), ), 'columns' => array( 'sys_language_uid' => array( @@ -1461,5 +1466,16 @@ 'eval' => 'trim', ), ), + 'additional_identifier_xpaths' => array( + 'exclude' => 1, + 'l10n_mode' => 'exclude', + 'label' => 'LLL:EXT:dpf/Resources/Private/Language/locallang_db.xlf:tx_dpf_domain_model_client.search_field_xml.additional_identifiers.xpath', + 'config' => array( + 'type' => 'text', + 'cols' => 80, + 'rows' => 10, + 'eval' => 'trim', + ), + ), ), ); diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 422edbe0..eca7eb5d 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -1259,6 +1259,14 @@ XPath expressions for additional titles (Multiple Xpath expressions can be concatenated using ';') XPath-Ausdrücke für zusätzliche Titel(Mehrere XPath-Ausdrücke können mit „;“ verkettet werden) + + Additional identifiers + Zusätzliche Identifikatoren + + + XPath expressions for additional identifiers (Multiple Xpath expressions can be concatenated using ';') + XPath-Ausdrücke für zusätzliche Identifikatoren(Mehrere XPath-Ausdrücke können mit „;“ verkettet werden) + diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 7759aaf4..b40b1e3b 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -949,6 +949,12 @@ XPath expressions for additional title information (Multiple Xpath expressions can be concatenated using ';') + + + Additional identifiers + + + XPath expressions for additional identifiers (Multiple Xpath expressions can be concatenated using ';') diff --git a/ext_tables.sql b/ext_tables.sql index 51321f02..a647f92d 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -483,6 +483,7 @@ CREATE TABLE tx_dpf_domain_model_client ( project_id_xpath tinytext NOT NULL, project_title_xpath tinytext NOT NULL, additional_search_title_xpaths text NOT NULL, + additional_identifier_xpaths text NOT NULL, fis_collections tinytext NOT NULL,