-
Notifications
You must be signed in to change notification settings - Fork 72
Description
The Context Reactions that alter a node's JSON-LD representation depend on the Node Context being present.
If I go to http://localhost:8000/node/89?_format=jsonld
{
"@graph": [
{
"@id": "http:\/\/localhost:8000\/node\/89",
"@type": [
"http:\/\/pcdm.org\/models#Object",
"http:\/\/purl.org\/dc\/dcmitype\/Dataset"
],
"http:\/\/schema.org\/dateModified": [
{
"@value": "2021-12-09T18:58:34+00:00",
"@type": "http:\/\/www.w3.org\/2001\/XMLSchema#dateTime"
}
],
"http:\/\/purl.org\/spar\/datacite\/hasResourceType": [
{
"@value": "Visitations",
"@type": "http:\/\/www.w3.org\/2001\/XMLSchema#string"
}
],
"http:\/\/purl.org\/spar\/datacite\/hasGeneralResourceTYpe": [
{
"@value": "Dataset",
"@type": "http:\/\/www.w3.org\/2001\/XMLSchema#string",
"@container": "@list"
}
],
"http:\/\/schema.org\/sameAs": [
{
"@id": "http:\/\/localhost:8000\/node\/89"
}
]
}
]
}
The "Dataset" type and the SameAs predicate were added via two context reactions that ship with Islandora, in JsonldSelfReferenceReaction.php and JsonldTypeAlterReaction.php.
However when I use Drupal's serializer service directly to get the node in JSON-LD format, I get:
$s = \Drupal::service('serializer);
$n = \Drupal::entityTypeManager()->getStorage('node')->load(89);
$s->serialize($n, 'jsonld');
<warning>PHP Deprecated: \Drupal\node\Plugin\Condition\NodeType is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Entity\Plugin\Condition\EntityBundle instead. See https://www.drupal.org/node/2983299 in /var/www/html/drupal/web/core/modules/node/src/Plugin/Condition/NodeType.php on line 53</warning>
{
"@graph": [
{
"@id": "http:\/\/default\/node\/89",
"@type": [
"http:\/\/pcdm.org\/models#Object"
],
"http:\/\/schema.org\/dateModified": [
{
"@value": "2021-12-09T18:58:34+00:00",
"@type": "http:\/\/www.w3.org\/2001\/XMLSchema#dateTime"
}
],
"http:\/\/purl.org\/spar\/datacite\/hasResourceType": [
{
"@value": "Visitations",
"@type": "http:\/\/www.w3.org\/2001\/XMLSchema#string"
}
],
"http:\/\/purl.org\/spar\/datacite\/hasGeneralResourceTYpe": [
{
"@value": "Dataset",
"@type": "http:\/\/www.w3.org\/2001\/XMLSchema#string",
"@container": "@list"
}
]
}
]
}
Since the serializer service is pretty well-known, I think it's important to not have it generate different output depending on whether the node was loaded with a context or otherwise.
Generally I also don't think the added complexity gives us much that just writing a custom normalizer alter hook gives us.
I propose deprecating the JSONLD alter reactions and putting the Type based on field_external_uri value and "SameAs" predicates directly into the islandora module.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status