dannylamb
5 years ago
5 changed files with 149 additions and 0 deletions
@ -0,0 +1,8 @@
|
||||
services: |
||||
logger.channel.islandora_text_extraction: |
||||
parent: logger.channel_base |
||||
arguments: ['islandora_text_extraction'] |
||||
islandora_text_extraction.search_reindexer: |
||||
class: Drupal\islandora_text_extraction\SearchReindexer |
||||
arguments: ['@islandora.utils', '@logger.channel.islandora_text_extraction'] |
||||
|
@ -0,0 +1,65 @@
|
||||
<?php |
||||
|
||||
namespace Drupal\islandora_text_extraction; |
||||
|
||||
use Drupal\islandora\IslandoraUtils; |
||||
use Drupal\media\MediaInterface; |
||||
use Psr\Log\LoggerInterface; |
||||
|
||||
/** |
||||
* Creates a GeminiClient as a Drupal service. |
||||
* |
||||
* @package Drupal\islandora |
||||
*/ |
||||
class SearchReindexer { |
||||
|
||||
/** |
||||
* Islandora Utils. |
||||
* |
||||
* @var \Drupal\islandora\IslandoraUtils |
||||
*/ |
||||
protected $utils; |
||||
|
||||
/** |
||||
* Logger. |
||||
* |
||||
* @var \Psr\Log\LoggerInterface |
||||
*/ |
||||
protected $logger; |
||||
|
||||
/** |
||||
* Constructor. |
||||
* |
||||
* @param \Drupal\islandora\IslandoraUtils $utils |
||||
* Islandora utils. |
||||
* @param \Psr\Log\LoggerInterface $logger |
||||
* The logger channel. |
||||
*/ |
||||
public function __construct(IslandoraUtils $utils, LoggerInterface $logger) { |
||||
$this->utils = $utils; |
||||
$this->logger = $logger; |
||||
} |
||||
|
||||
/** |
||||
* Reindexes parent node for a media. No-op if parent does not exist. |
||||
* |
||||
* @param Drupal\media\MediaInterface $media |
||||
* Media whose parent you want to reindex. |
||||
*/ |
||||
public function reindexParent(MediaInterface $media) { |
||||
$parent = $this->utils->getParentNode($media); |
||||
|
||||
if ($parent === NULL) { |
||||
return; |
||||
} |
||||
|
||||
$this->logger->debug( |
||||
"Re-indexing parent node @nid for extracted text @mid using the search_api", |
||||
['@nid' => $parent->id(), '@mid' => $media->id()] |
||||
); |
||||
|
||||
$parent->original = $parent; |
||||
search_api_entity_update($parent); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,51 @@
|
||||
langcode: en |
||||
status: true |
||||
dependencies: |
||||
config: |
||||
- media.type.extracted_text |
||||
enforced: |
||||
module: |
||||
- islandora_text_extraction_defaults |
||||
module: |
||||
- media |
||||
id: media.extracted_text |
||||
targetEntityType: media |
||||
bundle: extracted_text |
||||
types: |
||||
- 'pcdm:File' |
||||
fieldMappings: |
||||
name: |
||||
properties: |
||||
- 'dcterms:title' |
||||
- 'rdf:label' |
||||
created: |
||||
properties: |
||||
- 'schema:dateCreated' |
||||
datatype_callback: |
||||
callable: 'Drupal\rdf\CommonDataConverter::dateIso8601Value' |
||||
changed: |
||||
properties: |
||||
- 'schema:dateModified' |
||||
datatype_callback: |
||||
callable: 'Drupal\rdf\CommonDataConverter::dateIso8601Value' |
||||
uid: |
||||
properties: |
||||
- 'schema:author' |
||||
mapping_type: rel |
||||
field_mime_type: |
||||
properties: |
||||
- 'ebucore:hasMimeType' |
||||
field_media_of: |
||||
properties: |
||||
- 'pcdm:fileOf' |
||||
mapping_type: rel |
||||
field_original_name: |
||||
properties: |
||||
- 'premis3:originalName' |
||||
field_tags: |
||||
properties: |
||||
- 'schema:additionalType' |
||||
mapping_type: rel |
||||
field_file_size: |
||||
properties: |
||||
- 'premis:hasSize' |
Loading…
Reference in new issue