Browse Source

Work on #1521.

pull/778/head
Mark Jordan 6 years ago
parent
commit
55b72a7ac4
  1. 6
      islandora.links.menu.yml
  2. 4
      islandora.routing.yml
  3. 30
      src/Controller/RdfMappingsReportController.php

6
islandora.links.menu.yml

@ -12,9 +12,9 @@ system.islandora_settings:
route_name: system.islandora_settings route_name: system.islandora_settings
description: 'Confgure core Islandora settings' description: 'Confgure core Islandora settings'
# Field to RDF property mappings # RDF property mappings
system.islandora_rdf_mappings: system.islandora_rdf_mappings:
title: 'RDF field mappings' title: 'Field and term RDF mappings'
parent: system.admin_reports parent: system.admin_reports
description: 'List of configured Drupal field to RDF property mappings.' description: 'List of configured Drupal field to RDF property mappings and taxonomy term linked data URIs.'
route_name: system.islandora_rdf_mappings route_name: system.islandora_rdf_mappings

4
islandora.routing.yml

@ -16,12 +16,12 @@ system.islandora_settings:
requirements: requirements:
_permission: 'administer site configuration' _permission: 'administer site configuration'
# RDF mappings report # RDF properties report
system.islandora_rdf_mappings: system.islandora_rdf_mappings:
path: '/admin/reports/islandora/rdf_mappings' path: '/admin/reports/islandora/rdf_mappings'
defaults: defaults:
_controller: '\Drupal\islandora\Controller\RdfMappingsReportController::main' _controller: '\Drupal\islandora\Controller\RdfMappingsReportController::main'
_title: 'Drupal field to RDF property mappings' _title: 'Field and term RDF mappings'
requirements: requirements:
_permission: 'administer site configuration' _permission: 'administer site configuration'

30
src/Controller/RdfMappingsReportController.php

@ -18,10 +18,9 @@ class RdfMappingsReportController extends ControllerBase {
* Markup of the tables. * Markup of the tables.
*/ */
public function main() { public function main() {
$markup = ''; $markup = '';
$entity_types = ['node', 'media'];
// Configured namespaces.
$namespaces = rdf_get_namespaces(); $namespaces = rdf_get_namespaces();
$namespaces_table_rows = []; $namespaces_table_rows = [];
foreach ($namespaces as $alias => $namespace_uri) { foreach ($namespaces as $alias => $namespace_uri) {
@ -38,6 +37,8 @@ class RdfMappingsReportController extends ControllerBase {
$markup .= '<details><summary>' . t('RDF namespaces used in field mappings') . $markup .= '<details><summary>' . t('RDF namespaces used in field mappings') .
'</summary><div class="details-wrapper">' . $namespaces_table_markup . '</div></details>'; '</summary><div class="details-wrapper">' . $namespaces_table_markup . '</div></details>';
// Node and media field to RDF property mappings.
$entity_types = ['node', 'media'];
$markup .= '<h2>' . t('Field mappings') . '</h2>'; $markup .= '<h2>' . t('Field mappings') . '</h2>';
foreach ($entity_types as $entity_type) { foreach ($entity_types as $entity_type) {
$bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type); $bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type);
@ -70,9 +71,11 @@ class RdfMappingsReportController extends ControllerBase {
} }
} }
// Taxonomy terms with external URIs. // Taxonomy terms with external URIs or authority links.
$markup .= '<h2>' . t('Taxonomy terms with external URIs') . '</h2>'; $markup .= '<h2>' . t('Taxonomy terms with external URIs or authority links') . '</h2>';
$utils = \Drupal::service('islandora.utils'); $utils = \Drupal::service('islandora.utils');
$uri_fields = $utils->getUriFieldNamesForTerms();
$vocabs = Vocabulary::loadMultiple(); $vocabs = Vocabulary::loadMultiple();
foreach ($vocabs as $vid => $vocab) { foreach ($vocabs as $vid => $vocab) {
$vocab_table_header = []; $vocab_table_header = [];
@ -90,16 +93,25 @@ class RdfMappingsReportController extends ControllerBase {
$markup .= $vocab_table_markup; $markup .= $vocab_table_markup;
} }
else { else {
$vocab_table_header = [t('Term'), t('Term ID'), t('External URI')]; $vocab_table_header = [
t('Term'),
t('Term ID'),
t('External URI or Authority link'),
];
$vocab_table_rows = []; $vocab_table_rows = [];
foreach ($terms as $t) { foreach ($terms as $t) {
$term = Term::load($t->tid); $term = Term::load($t->tid);
$uri = $utils->getUriForTerm($term); foreach ($uri_fields as $uri_field) {
if (is_null($uri)) { if ($term->hasField($uri_field) && !$term->get($uri_field)->isEmpty()) {
$vocab_table_rows[] = [$term->getName(), $term->id(), t('None')]; $uri = $term->get($uri_field)->first()->getValue();
continue;
}
}
if (isset($uri) && !is_null($uri) && array_key_exists('uri', $uri)) {
$vocab_table_rows[] = [$term->getName(), $term->id(), $uri['uri']];
} }
else { else {
$vocab_table_rows[] = [$term->getName(), $term->id(), $uri]; $vocab_table_rows[] = [$term->getName(), $term->id(), t('None')];
} }
} }
$vocab_table = [ $vocab_table = [

Loading…
Cancel
Save