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

Add a 'Pass Through URI' Data Converter to JSON-LD: Issue-1581 #45

Merged
merged 4 commits into from
Aug 18, 2020
Merged

Add a 'Pass Through URI' Data Converter to JSON-LD: Issue-1581 #45

merged 4 commits into from
Aug 18, 2020

Conversation

seth-shaw-unlv
Copy link
Contributor

GitHub Issue: Islandora/documentation#1581

What does this Pull Request do?

Adds a converter for RDF maps to take the targets of an entity reference field and replace their URI with the value of a Link or Authority Link fields (e.g. the Islandora taxonomy vocabularies or Genre taxonomy vocabulary).

What's new?

  • Changes EntityReferenceItemNormalizer to support the DataConverter to populate '@id' (if '@id' is set as the datatype) OR the '@value'. It also only adds the target entity as another graph if not using the converter.
  • Adds EntityReferenceConverter that will replace the target entity with the value of a field as passed with a 'link_field' argument in the RDF mapping.
  • Updates the tests so they run without deprecation notices.
  • Does this change add any new dependencies? No.
  • Does this change require any other modifications to be made to the repository
    (i.e. Regeneration activity, etc.)? No.
  • Could this change impact execution of existing code? No.

How should this be tested?

  • Take a site with a node that references some taxonomies where the terms have a link (or authority link) field with a value. E.g. a subject term with an id.loc.gov URI.
  • View the JSON-LD of that node. You will see the field mapped as usual to use the predicate in the RDF mapping where the value is the referenced taxonomy term URI.
  • Apply the PR
  • Update the RDF mapping so that field uses the new converter. E.g.
  field_subject:
    properties:
      - 'dcterms:subject'
    datatype_callback:
      callable: 'Drupal\jsonld\EntityReferenceConverter::linkFieldPassthrough'
      arguments:
        link_field: 'field_authority_link'
  • Clear cache
  • View the node's JSON-LD again. Instead of seeing the taxonomy term URI you will see the value of the term's link field (e.g. the id.loc.gov URI for a subject).

Interested parties

@Islandora/8-x-committers

@seth-shaw-unlv
Copy link
Contributor Author

I just realized that using the converter with a term that doesn't have the value doesn't fall back to the original serialization as I thought it would. But here is my WIP if folks want to look at it now.

@seth-shaw-unlv seth-shaw-unlv marked this pull request as ready for review August 13, 2020 04:39
@seth-shaw-unlv
Copy link
Contributor Author

Came back for a few minutes this evening to finish the PR off. It now supports the case where a Converter passes along a fieldable entity (either a new target or the original one, it doesn't care).

I believe you were interested in this one, @elizoller. Let me know what you think.

@elizoller
Copy link
Member

elizoller commented Aug 13, 2020

This worked well for me. Tested on the resource type and the subject fields in the repository item content type in an islandora-playbook instance.
I also gave it a whirl in the context of our ASU install because I have quite a few other customizations to the RDF mapping - it worked well there also.

Copy link
Member

@whikloj whikloj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for my test, it does require some RDF changes to enable it. Seeing as how it allows non-matching targets to fall through it might be nice if it was just used by default. We'd need to add a configuration field in the UI to set the link_field argument.

Just a thought, I'm good with this as is and that as a possible later piece of work.

@whikloj
Copy link
Member

whikloj commented Aug 14, 2020

I know there is no 24 hour 🕐 in Islandora 8, but its Friday. So I'll give the other @Islandora/8-x-committers the day to have a look at this, if there is no issues/concerns raised I'll merge it.

@seth-shaw-unlv
Copy link
Contributor Author

Can haz squash and merge, @elizoller or @whikloj?

@elizoller elizoller merged commit 659ef35 into Islandora:8.x-1.x Aug 18, 2020
@seth-shaw-unlv seth-shaw-unlv deleted the issue-1581 branch August 18, 2020 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants