Skip to content

Instantly share code, notes, and snippets.

@Rarian
Last active November 8, 2016 13:18
Show Gist options
  • Save Rarian/e809c39968bd6b243aaf1a030636d43b to your computer and use it in GitHub Desktop.
Save Rarian/e809c39968bd6b243aaf1a030636d43b to your computer and use it in GitHub Desktop.
Hack-ish patches for Islandora 1.7 with Fedora 3 and trippi-sparql talking to Fuseki
diff --git a/modules/islandora_scholar_embargo/islandora_scholar_embargo.module b/modules/islandora_scholar_embargo/islandora_scholar_e
index a0d3bc7..36f6937 100644
--- a/modules/islandora_scholar_embargo/islandora_scholar_embargo.module
+++ b/modules/islandora_scholar_embargo/islandora_scholar_embargo.module
@@ -210,8 +210,8 @@ WHERE {
?embargoed is:$eu ?date ;
is:$np ?notify .
FILTER(
- ?notify < '$now'^^xsd:dateTime &&
- ?date > '$pre_expiry'^^xsd:dateTime) .
+ ?notify < '$now'^^<xsd:dateTime> &&
+ ?date > '$pre_expiry'^^<xsd:dateTime>) .
}
EOQ;
diff --git a/RepositoryQuery.php b/RepositoryQuery.php
index b9cab25..dbeb418 100644
--- a/RepositoryQuery.php
+++ b/RepositoryQuery.php
@@ -91,6 +91,23 @@ class RepositoryQuery {
* The contents returned, in the $format specified.
*/
protected function internalQuery($query, $type = 'itql', $limit = -1, $format = 'Sparql') {
+ # Patch to work around the fact that fuseki does not like hyphens
+ # in prefixes and Mulgara autodefines xsd
+ # https://github.com/quoll/mulgara/blob/master/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java#L25:L26
+ $namespaces = array(
+ "fedora-model" => "info:fedora/fedora-system:def/model#",
+ "fedora-view" => "info:fedora/fedora-system:def/view#",
+ "fedora-rels-ext" => "info:fedora/fedora-system:def/relations-external#",
+ "xsd" => "http://www.w3.org/2001/XMLSchema#"
+ );
+ $prefix = function($prefix) { return "<{$prefix}:"; };
+ $uri = function($uri) { return '<' . $uri; };
+ $query = str_replace(
+ array_map($prefix, array_keys($namespaces)),
+ array_map($uri, array_values($namespaces)),
+ $query
+ );
+
// Construct the query URL.
$url = '/risearch';
$seperator = '?';
diff --git a/islandora_video.drush.inc b/islandora_video.drush.inc
index 99c275c..001c92b 100644
--- a/islandora_video.drush.inc
+++ b/islandora_video.drush.inc
@@ -79,7 +79,7 @@ EOQ;
<fedora-view:disseminates> ?ds .
?ds <fedora-view:disseminationType> <info:fedora/*/OGG> ;
<fedora-view:lastModifiedDate> ?date
- FILTER(?date > '$last_date'^^xsd:dateTime)
+ FILTER(?date > '$last_date'^^<xsd:dateTime>)
}
ORDER BY ?date
LIMIT $update_offset
@ddavis
Copy link

ddavis commented Jul 20, 2016

We are using your patches and searching Islandora code for problem queries. Hopefully in two weeks we will go live. I will report any issues and, if needed, provide fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment