Browse Source

Fixes JSONLD endpoint fail for Extracted Text (#768)

* wrapping string in array for case where there's no rdf mapping
* Adding rdf mapping for extracted text
pull/770/head
dannylamb 5 years ago committed by GitHub
parent
commit
8b7caa9e8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 51
      modules/islandora_text_extraction_defaults/config/install/rdf.mapping.media.extracted_text.yml
  2. 3
      src/Plugin/ContextReaction/JsonldTypeAlterReaction.php

51
modules/islandora_text_extraction_defaults/config/install/rdf.mapping.media.extracted_text.yml

@ -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'

3
src/Plugin/ContextReaction/JsonldTypeAlterReaction.php

@ -44,6 +44,9 @@ class JsonldTypeAlterReaction extends NormalizerAlterReaction {
// Search for the entity in the graph. // Search for the entity in the graph.
foreach ($normalized['@graph'] as &$elem) { foreach ($normalized['@graph'] as &$elem) {
if (!is_array($elem['@type'])) {
$elem['@type'] = [$elem['@type']];
}
if ($elem['@id'] === $this->getSubjectUrl($entity)) { if ($elem['@id'] === $this->getSubjectUrl($entity)) {
foreach ($entity->get($config['source_field'])->getValue() as $type) { foreach ($entity->get($config['source_field'])->getValue() as $type) {
// If the configured field is using an entity reference, // If the configured field is using an entity reference,

Loading…
Cancel
Save