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

Support additional RDF types based on a configurable field #889

Closed
seth-shaw-unlv opened this issue Aug 8, 2018 · 16 comments
Closed

Support additional RDF types based on a configurable field #889

seth-shaw-unlv opened this issue Aug 8, 2018 · 16 comments
Assignees

Comments

@seth-shaw-unlv
Copy link
Contributor

For a given bundle, I would like to define a field that stores one (or more) types that will be included as a typeof property in the RDFa and a @type in the JSON-LD serialization.

For example, in my controlled access terms module I define a Corporate Body bundle with the rdf.mapping config set to use schema:Organization as the type. I would like to add a List field of sub-types (e.g. Organizational Unit, Corporation, and Performing Group) that would be included as additional types.

I tried simply listing the field as a fieldMapping using the type property, but that didn't work as setting the type fields is a separate step from mapping the properties (and the resulting output made all my schema testers throw errors).

Adding it to the RDFa requires implementing a hook_preprocess_node(). I have an example gist that worked in my testing; although it would need to be made configurale. This fix only works for the HTML serialization. JSON-LD populates the @type field based on the rdf.mapping (which is what we would expect) and would need to be extended in some other way.

@dannylamb
Copy link
Contributor

We should do this in the islandora module, in an alter with a ContextReaction, and let the user configure which taxonomy term fields apply to rdf:type vs. whatever predicate is in the RDF mapping.

@dannylamb
Copy link
Contributor

Adding to sprint. We'll want this for the agents we create from mods:name elements.

@rtilla1
Copy link

rtilla1 commented Aug 20, 2018

From Spring Kick-off: Resolving this ticket will solve 2 types of problems:

  1. Creation of compound fields (names can be given both an entity and a relationship marker)
  2. Define a list of types that could be included as a property (to be used as a dropdown)

@seth-shaw-unlv
Copy link
Contributor Author

Related ticket: #893

@patdunlavey
Copy link

@seth-shaw-unlv I'm interested in this helping on this if #895 doesn't need all my time.

@seth-shaw-unlv seth-shaw-unlv self-assigned this Aug 20, 2018
@dannylamb
Copy link
Contributor

So it looks like there's two pieces to this. One is to make a 'compound' field that has the entity reference field plus a role. The other piece is to provide an implementation in the islandora module's jsonld alter to re-write the rdf accordingly. Does that sound about right? Do we want to split this into sub-tickets?

@seth-shaw-unlv
Copy link
Contributor Author

@dannylamb Yes. This ticket would have a simple list field that allows selecting a type. Then the islandora jsonld alter would re-write the RDF accordingly (type's value).

The compound field case is slightly different in that the drop-down subfield modifies the predicate associated with the compound field's value.

@seth-shaw-unlv
Copy link
Contributor Author

Thinking out loud, @dannylamb can you check my reasoning on this:

So, considering how islandora_jsonld_alter_normalized_array is currently setup, we need to add a \Drupal\islandora\ContextReaction\NormalizerAlterReaction that will alter the type attribute based on the value of a field (to be configured) for the passed entity. The condition would be, what, that the entity is of a predetermined content type (configurable in the Context admin)? Am I on the right track? The type predicate is in the normalized array, right?

If the above is correct, we could also have a another NormalizerAlterReaction for altering TypedRelation fields.

@dannylamb
Copy link
Contributor

dannylamb commented Aug 22, 2018

@seth-shaw-unlv I think the Condition will be left to the user, but probably something along the lines of picking a content type. We could flesh out something akin to a "has field" condition if we needed one, but we can probably make due with what we've already got for now.

I imagine the context reaction would just give you a list of taxonomy term reference fields to choose from, and the user would be allowed to select multiple. Then when actually exectuing, the external uris from terms in those fields would be appended to rdf:type. We'll probably also want to remove whatever predicate it was configured as in the rdf mapping from the jsonld body (if it was configured in the first place).

After that we'd have to figure out how to make it work with the TypedRelation fields like we're providing. It should all boil down to where do you scrape out the external uri to append to rdf:type.

@dannylamb
Copy link
Contributor

@Natkeeran @seth-shaw-unlv I'm about to assign this to @patdunlavey. Is there anything else either of you have cooking we should know about?

@seth-shaw-unlv
Copy link
Contributor Author

@dannylamb Sounds like a plan. I've been working on some bits for another project this morning (trying to clear the plate a bit more) and then I can better focus here.

I don't think we need to unset the existing @type since the taxonomy term is likely to be a more specific type than the one set in rdf.mapping.

@dannylamb
Copy link
Contributor

@seth-shaw-unlv I figured we'd keep that @type. What I meant to say was that if the field has been configured as a predicate (like schema:hasAdditionalType or something), we'd want to remove that predicate from the jsonld because its value is now in rdf:type.

@patdunlavey
Copy link

Does this module have any potential utility? https://www.drupal.org/project/rdfui (watch the video). Sorry if not, I'm at the bottom end of this learning curve!

@seth-shaw-unlv
Copy link
Contributor Author

@patdunlavey
Yes, and no. It works fine for how the core rdf module works, but it doesn't work for our attempt to override @type or overriding the predicate used by a field for a particular instance.

Also, it is limited to Schema.org (I believe).

@mjordan
Copy link
Contributor

mjordan commented Dec 19, 2018

@seth-shaw-unlv ok to close this issue?

@seth-shaw-unlv
Copy link
Contributor Author

@mjordan, I would like to wait until Islandora/controlled_access_terms#16 is merged before closing it since the PR came out of this issue thread.

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

No branches or pull requests

6 participants