From a0886358fe5b03d0cc9520c2194f58186449fa13 Mon Sep 17 00:00:00 2001 From: Daniel Lamb Date: Tue, 12 May 2015 16:23:33 -0300 Subject: [PATCH] RDF mapping refactor. --- islandora/include/rdf_mapping.inc | 73 +++++++++++++++++++ islandora/islandora.module | 10 +++ .../islandora_basic_image.info | 2 +- .../islandora_basic_image.module | 8 ++ .../islandora_collection.module | 41 +---------- 5 files changed, 94 insertions(+), 40 deletions(-) create mode 100644 islandora/include/rdf_mapping.inc diff --git a/islandora/include/rdf_mapping.inc b/islandora/include/rdf_mapping.inc new file mode 100644 index 00000000..bebc9bfc --- /dev/null +++ b/islandora/include/rdf_mapping.inc @@ -0,0 +1,73 @@ + 'node', + 'bundle' => $bundle, + 'mapping' => array( + 'rdftype' => array('islandora:collection'), + 'field_dcterms_contributor' => array( + 'predicates' => array('dc:contributor'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_coverage' => array( + 'predicates' => array('dc:coverage'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_creator' => array( + 'predicates' => array('dc:creator'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_date' => array( + 'predicates' => array('dc:date'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_description' => array( + 'predicates' => array('dc:description'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_format' => array( + 'predicates' => array('dc:format'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_identifier' => array( + 'predicates' => array('dc:identifier'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_language' => array( + 'predicates' => array('dc:language'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_publisher' => array( + 'predicates' => array('dc:publisher'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_relation' => array( + 'predicates' => array('dc:relation'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_rights' => array( + 'predicates' => array('dc:rights'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_source' => array( + 'predicates' => array('dc:source'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_subject' => array( + 'predicates' => array('dc:subject'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_title' => array( + 'predicates' => array('dc:title'), + 'datatype' => 'xsd:string', + ), + 'field_dcterms_type' => array( + 'predicates' => array('dc:type'), + 'datatype' => 'xsd:string', + ), + ), + ), + ); +} diff --git a/islandora/islandora.module b/islandora/islandora.module index c1f13991..c3155849 100644 --- a/islandora/islandora.module +++ b/islandora/islandora.module @@ -21,6 +21,16 @@ function islandora_ctools_plugin_api($owner, $api) { } } +/** + * Implements hook_rdf_namespaces(). + */ +function islandora_rdf_namespaces() { + return array( + 'islandora' => 'http://islandora.ca/ontology/v2/', + 'fedora' => 'http://fedora.info/definitions/v4/repository#', + ); +} + /** * Implements hook_default_services_endpoint(). */ diff --git a/islandora_basic_image/islandora_basic_image.info b/islandora_basic_image/islandora_basic_image.info index c7429959..024324fe 100644 --- a/islandora_basic_image/islandora_basic_image.info +++ b/islandora_basic_image/islandora_basic_image.info @@ -3,4 +3,4 @@ description = "Content type, viewer, and hooks for Basic Image objects" package = Islandora version = 7.x-dev core = 7.x -dependencies[] = islandora +dependencies[] = islandora diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index 4da3418c..656fb45c 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -27,3 +27,11 @@ function islandora_basic_image_node_info() { function islandora_basic_image_form($node, array &$form_state) { return node_content_form($node, $form_state); } + +/** + * Implements hook_rdf_mapping(). + */ +function islandora_basic_image_rdf_mapping() { + module_load_include('inc', 'islandora', 'include/rdf_mapping'); + return islandora_get_default_rdf_mapping(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE); +} diff --git a/islandora_collection/islandora_collection.module b/islandora_collection/islandora_collection.module index 2286b79c..dba7aabf 100644 --- a/islandora_collection/islandora_collection.module +++ b/islandora_collection/islandora_collection.module @@ -42,49 +42,12 @@ function islandora_collection_form($node, array &$form_state) { return node_content_form($node, $form_state); } -/** - * Implements hook_rdf_namespaces(). - */ -function islandora_collection_rdf_namespaces() { - return array( - 'islandora' => 'http://islandora.ca/ontology/v2/', - 'fedora' => 'http://fedora.info/definitions/v4/repository#', - ); -} - /** * Implements hook_rdf_mapping(). */ function islandora_collection_rdf_mapping() { - return array( - array( - 'type' => 'node', - 'bundle' => ISLANDORA_COLLECTION_CONTENT_TYPE, - 'mapping' => array( - 'rdftype' => array('islandora:collection'), - 'field_dcterms_contributor' => array( - 'predicates' => array('dc:contributor'), - 'datatype' => 'xsd:string', - ), - 'field_dcterms_coverage' => array( - 'predicates' => array('dc:coverage'), - 'datatype' => 'xsd:string', - ), - 'field_dcterms_creator' => array( - 'predicates' => array('dc:creator'), - 'datatype' => 'xsd:string', - ), - 'field_dcterms_date' => array( - 'predicates' => array('dc:date'), - 'datatype' => 'xsd:string', - ), - 'field_dcterms_description' => array( - 'predicates' => array('dc:description'), - 'datatype' => 'xsd:string', - ), - ), - ), - ); + module_load_include('inc', 'islandora', 'include/rdf_mapping'); + return islandora_get_default_rdf_mapping(ISLANDORA_COLLECTION_CONTENT_TYPE); } /**