Browse Source

Move rdf namespaces into jsonld config (Issue-1520) (#832)

* move rdf namespaces into jsonld config

* Add form link to jsonld settings form
pull/837/head
Seth Shaw 3 years ago committed by GitHub
parent
commit
56444554ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 84
      islandora.install
  2. 25
      islandora.module
  3. 8
      src/Form/IslandoraSettingsForm.php

84
islandora.install

@ -5,6 +5,13 @@
* Install/update hook implementations. * Install/update hook implementations.
*/ */
/**
* Adds common namespaces to jsonld.settings.
*/
function islandora_install() {
update_jsonld_included_namespaces();
}
/** /**
* Delete the 'delete_media' action we used to provide, if it exists. * Delete the 'delete_media' action we used to provide, if it exists.
* *
@ -90,3 +97,80 @@ function islandora_update_8005() {
} }
} }
} }
/**
* Adds adds previously hardcoded namespaces to configuration.
*/
function islandora_update_8006() {
update_jsonld_included_namespaces();
}
/**
* Used by install and update_8006 to add namespaces to jsonld.settings.yml.
*/
function update_jsonld_included_namespaces() {
$namespaces = [
[
'prefix' => 'ldp',
'namespace' => 'http://www.w3.org/ns/ldp#',
], [
'prefix' => 'dc11',
'namespace' => 'http://purl.org/dc/elements/1.1/',
], [
'prefix' => 'dcterms',
'namespace' => 'http://purl.org/dc/terms/',
], [
'prefix' => 'nfo',
'namespace' => 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/v1.1/',
], [
'prefix' => 'ebucore',
'namespace' => 'http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#',
], [
'prefix' => 'fedora',
'namespace' => 'http://fedora.info/definitions/v4/repository#',
], [
'prefix' => 'owl',
'namespace' => 'http://www.w3.org/2002/07/owl#',
], [
'prefix' => 'ore',
'namespace' => 'http://www.openarchives.org/ore/terms/',
], [
'prefix' => 'rdf',
'namespace' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
], [
'prefix' => 'rdau',
'namespace' => 'http://rdaregistry.info/Elements/u/',
], [
'prefix' => 'islandora',
'namespace' => 'http://islandora.ca/',
], [
'prefix' => 'pcdm',
'namespace' => 'http://pcdm.org/models#',
], [
'prefix' => 'use',
'namespace' => 'http://pcdm.org/use#',
], [
'prefix' => 'iana',
'namespace' => 'http://www.iana.org/assignments/relation/',
], [
'prefix' => 'premis',
'namespace' => 'http://www.loc.gov/premis/rdf/v1#',
], [
'prefix' => 'premis3',
'namespace' => 'http://www.loc.gov/premis/rdf/v3/',
], [
'prefix' => 'co',
'namespace' => 'http://purl.org/co/',
],
];
$config = \Drupal::configFactory()->getEditable('jsonld.settings');
if ($config && !is_array($config->get('rdf_namespaces'))) {
$config->set('rdf_namespaces', $namespaces);
$config->save(TRUE);
}
else {
\Drupal::logger('islandora')
->warning("Could not find required jsonld.settings to add default RDF namespaces.");
}
}

25
islandora.module

@ -43,31 +43,6 @@ function islandora_help($route_name, RouteMatchInterface $route_match) {
} }
} }
/**
* Implements hook_rdf_namespaces().
*/
function islandora_rdf_namespaces() {
// Yes, it's amazing, rdf is not registered by default!
return [
'ldp' => 'http://www.w3.org/ns/ldp#',
'dc11' => 'http://purl.org/dc/elements/1.1/',
'dcterms' => 'http://purl.org/dc/terms/',
'nfo' => 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/v1.1/',
'ebucore' => 'http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#',
'fedora' => 'http://fedora.info/definitions/v4/repository#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'ore' => 'http://www.openarchives.org/ore/terms/',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'islandora' => 'http://islandora.ca/',
'pcdm' => 'http://pcdm.org/models#',
'use' => 'http://pcdm.org/use#',
'iana' => 'http://www.iana.org/assignments/relation/',
'premis' => 'http://www.loc.gov/premis/rdf/v1#',
'premis3' => 'http://www.loc.gov/premis/rdf/v3/',
'co' => 'http://purl.org/co/',
];
}
/** /**
* Implements hook_node_insert(). * Implements hook_node_insert().
*/ */

8
src/Form/IslandoraSettingsForm.php

@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
use Stomp\Client; use Stomp\Client;
use Stomp\Exception\StompException; use Stomp\Exception\StompException;
use Stomp\StatefulStomp; use Stomp\StatefulStomp;
@ -184,6 +185,13 @@ class IslandoraSettingsForm extends ConfigFormBase {
'#default_value' => $selected_bundles, '#default_value' => $selected_bundles,
], ],
]; ];
$form['rdf_namespaces'] = [
'#type' => 'link',
'#title' => $this->t('Update RDF namespace configurations in the JSON-LD module settings.'),
'#url' => Url::fromRoute('system.jsonld_settings'),
];
return parent::buildForm($form, $form_state); return parent::buildForm($form, $form_state);
} }

Loading…
Cancel
Save