Browse Source

Posting drupal node json to middleware services endpoint. Converting to sparql and posting to fedora with namespaces declared in full. This keeps rdf in sync from Drupal to Fedora.

7.x-2.x
Daniel Lamb 10 years ago
parent
commit
fc5ebdd974
  1. 19
      islandora/include/rdf_mapping.inc
  2. 11
      islandora/islandora.module
  3. 6
      islandora_basic_image/islandora_basic_image.module
  4. 7
      islandora_collection/islandora_collection.module

19
islandora/include/rdf_mapping.inc

@ -10,13 +10,26 @@
* *
* @param string $bundle * @param string $bundle
* The bundle to associate with the RDF mapping. * The bundle to associate with the RDF mapping.
* @param string $rdf_type * @param array $rdf_types
* The RDF type to associate with the bundle. * RDF types to apply on top of the Fedora defaults.
* *
* @return array * @return array
* The default RDF mapping for Islandora content types. * The default RDF mapping for Islandora content types.
*/ */
function islandora_get_default_rdf_mapping($bundle, $rdf_types) { function islandora_get_default_rdf_mapping($bundle, $rdf_types) {
$default_rdf_types = array(
'ldp:RDFSource',
'ldp:Container',
'nt:hierarchyNode',
'nt:folder',
'nt:base',
'mix:referenceable',
'fedora:Resource',
'fedora:Container',
);
$rdf_types = array_merge($default_rdf_types, $rdf_types);
return array( return array(
array( array(
'type' => 'node', 'type' => 'node',
@ -24,7 +37,7 @@ function islandora_get_default_rdf_mapping($bundle, $rdf_types) {
'mapping' => array( 'mapping' => array(
'rdftype' => $rdf_types, 'rdftype' => $rdf_types,
'uuid' => array( 'uuid' => array(
'predicates' => array('fedora:uuid'), 'predicates' => array('nfo:uuid'),
'datatype' => 'xsd:string', 'datatype' => 'xsd:string',
), ),
ISLANDORA_FEDORA_HAS_PARENT_FIELD => array( ISLANDORA_FEDORA_HAS_PARENT_FIELD => array(

11
islandora/islandora.module

@ -13,6 +13,14 @@ define('ISLANDORA_PCDM_NAMESPACE', 'http://pcdm.org/models#');
define('ISLANDORA_PCDM_NAMESPACE_PREFIX', 'pcdm'); define('ISLANDORA_PCDM_NAMESPACE_PREFIX', 'pcdm');
define('ISLANDORA_NFO_NAMESPACE', 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/v1.2/'); define('ISLANDORA_NFO_NAMESPACE', 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/v1.2/');
define('ISLANDORA_NFO_NAMESPACE_PREFIX', 'nfo'); define('ISLANDORA_NFO_NAMESPACE_PREFIX', 'nfo');
define('ISLANDORA_LDP_NAMESPACE', 'http://www.w3.org/ns/ldp#');
define('ISLANDORA_LDP_NAMESPACE_PREFIX', 'ldp');
define('ISLANDORA_MIX_NAMESPACE', 'http://www.jcp.org/jcr/mix/1.0');
define('ISLANDORA_MIX_NAMESPACE_PREFIX', 'mix');
define('ISLANDORA_NT_NAMESPACE', 'http://www.jcp.org/jcr/nt/1.0');
define('ISLANDORA_NT_NAMESPACE_PREFIX', 'nt');
define('ISLANDORA_PCDM_COLLECTION_RDF_TYPE', 'pcdm:Collection');
define('ISLANDORA_PCDM_OBJECT_RDF_TYPE', 'pcdm:Object');
define('ISLANDORA_TN_FIELD', 'field_tn'); define('ISLANDORA_TN_FIELD', 'field_tn');
define('ISLANDORA_FEDORA_PATH_FIELD', 'field_fedora_path'); define('ISLANDORA_FEDORA_PATH_FIELD', 'field_fedora_path');
define('ISLANDORA_FEDORA_HAS_PARENT_FIELD', 'field_fedora_has_parent'); define('ISLANDORA_FEDORA_HAS_PARENT_FIELD', 'field_fedora_has_parent');
@ -38,6 +46,9 @@ function islandora_rdf_namespaces() {
ISLANDORA_FEDORA_NAMESPACE_PREFIX => ISLANDORA_FEDORA_NAMESPACE, ISLANDORA_FEDORA_NAMESPACE_PREFIX => ISLANDORA_FEDORA_NAMESPACE,
ISLANDORA_PCDM_NAMESPACE_PREFIX => ISLANDORA_PCDM_NAMESPACE, ISLANDORA_PCDM_NAMESPACE_PREFIX => ISLANDORA_PCDM_NAMESPACE,
ISLANDORA_NFO_NAMESPACE_PREFIX => ISLANDORA_NFO_NAMESPACE, ISLANDORA_NFO_NAMESPACE_PREFIX => ISLANDORA_NFO_NAMESPACE,
ISLANDORA_NT_NAMESPACE_PREFIX => ISLANDORA_NT_NAMESPACE,
ISLANDORA_MIX_NAMESPACE_PREFIX => ISLANDORA_MIX_NAMESPACE,
ISLANDORA_LDP_NAMESPACE_PREFIX => ISLANDORA_LDP_NAMESPACE,
); );
} }

6
islandora_basic_image/islandora_basic_image.module

@ -34,5 +34,9 @@ function islandora_basic_image_form($node, array &$form_state) {
*/ */
function islandora_basic_image_rdf_mapping() { function islandora_basic_image_rdf_mapping() {
module_load_include('inc', 'islandora', 'include/rdf_mapping'); module_load_include('inc', 'islandora', 'include/rdf_mapping');
return islandora_get_default_rdf_mapping(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, ISLANDORA_BASIC_IMAGE_RDF_TYPE); $rdf_types = array(
ISLANDORA_PCDM_OBJECT_RDF_TYPE,
ISLANDORA_BASIC_IMAGE_RDF_TYPE,
);
return islandora_get_default_rdf_mapping(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, $rdf_types);
} }

7
islandora_collection/islandora_collection.module

@ -43,7 +43,11 @@ function islandora_collection_form($node, array &$form_state) {
*/ */
function islandora_collection_rdf_mapping() { function islandora_collection_rdf_mapping() {
module_load_include('inc', 'islandora', 'include/rdf_mapping'); module_load_include('inc', 'islandora', 'include/rdf_mapping');
return islandora_get_default_rdf_mapping(ISLANDORA_COLLECTION_CONTENT_TYPE, ISLANDORA_COLLECTION_RDF_TYPE); $rdf_types = array(
ISLANDORA_PCDM_COLLECTION_RDF_TYPE,
ISLANDORA_COLLECTION_RDF_TYPE,
);
return islandora_get_default_rdf_mapping(ISLANDORA_COLLECTION_CONTENT_TYPE, $rdf_types);
} }
/** /**
@ -63,6 +67,7 @@ function islandora_collection_node_postinsert($node) {
} }
$node = array_pop($nodes); $node = array_pop($nodes);
$node->rdf_namespaces = rdf_get_namespaces();
$response = drupal_http_request("http://localhost:8080/islandora-services/rest/collection", $response = drupal_http_request("http://localhost:8080/islandora-services/rest/collection",
array( array(
'method' => 'POST', 'method' => 'POST',

Loading…
Cancel
Save