From b30973e6d25d4298eb33185192a0d7ae3d5be068 Mon Sep 17 00:00:00 2001 From: ajs6f Date: Fri, 13 Nov 2015 10:08:19 -0500 Subject: [PATCH 1/6] First draft --- includes/tuque.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/tuque.inc b/includes/tuque.inc index 7aed2556..48df99e8 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -66,7 +66,7 @@ class IslandoraTuque { * @param string $url * The url to the fedora instance. */ - public function __construct($user = NULL, $url = NULL) { + public function __construct($user = NULL, $url = NULL, $sparql_endpoint = NULL) { if (!isset($user)) { global $user; } @@ -84,9 +84,13 @@ class IslandoraTuque { $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); } + if (!isset($sparql_endpoint)) { + $sparql_endpoint = variable_get('sparql_endpoint', $url); + } + if (self::exists()) { module_load_include('inc', 'islandora', 'includes/tuque_wrapper'); - $this->connection = new IslandoraRepositoryConnection($url, $user_string, $pass_string); + $this->connection = new IslandoraRepositoryConnection($url, $user_string, $pass_string, $sparql_endpoint); $this->connection->reuseConnection = TRUE; $this->api = new IslandoraFedoraApi($this->connection); $this->cache = new IslandoraSimpleCache(); From 4cf7d41716f38f8ce8360fa6b4521b4a0a35d770 Mon Sep 17 00:00:00 2001 From: ajs6f Date: Fri, 13 Nov 2015 10:12:26 -0500 Subject: [PATCH 2/6] Added PHPDoc --- includes/tuque.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/tuque.inc b/includes/tuque.inc index 48df99e8..5e5e3a02 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -65,6 +65,8 @@ class IslandoraTuque { * A Drupal user. * @param string $url * The url to the fedora instance. + * @param string $sparql_endpoint + * The URL of a SPARQL Query endpoint for this connection. */ public function __construct($user = NULL, $url = NULL, $sparql_endpoint = NULL) { if (!isset($user)) { From 397f2c0b3ace27f9ffd9508852602a7761c6b39b Mon Sep 17 00:00:00 2001 From: ajs6f Date: Fri, 13 Nov 2015 10:22:09 -0500 Subject: [PATCH 3/6] Betterifying Travis-CI config --- .travis.yml | 1 + tests/scripts/travis_setup.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f412ddd0..5dcc0769 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,3 +30,4 @@ after_failure: - $ISLANDORA_DIR/tests/scripts/travis_after_failure.sh notifications: irc: "irc.freenode.org#islandora" +sudo: required diff --git a/tests/scripts/travis_setup.sh b/tests/scripts/travis_setup.sh index db50a52d..bdb56ebc 100755 --- a/tests/scripts/travis_setup.sh +++ b/tests/scripts/travis_setup.sh @@ -73,4 +73,12 @@ drush en --user=1 --yes islandora drush cc all # The shebang in this file is a bogeyman that is haunting the web test cases. rm /home/travis/.phpenv/rbenv.d/exec/hhvm-switcher.bash -sleep 20 + +# wait for Fedora to come up +fedoraIsUp=1 +until [ $fedoraIsUp -eq "0" ]; do + echo "Waiting for Fedora to boot..." + sleep 10 + (curl http://localhost:8080/fedora) + fedoraIsUp=$? +done From 71342fc41f843aa3ac276887b3858a51318f4eb1 Mon Sep 17 00:00:00 2001 From: ajs6f Date: Fri, 13 Nov 2015 11:44:30 -0500 Subject: [PATCH 4/6] Attempting to add config to admin form --- includes/admin.form.inc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/admin.form.inc b/includes/admin.form.inc index 9f64cb6d..cd52d456 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -48,6 +48,21 @@ function islandora_repository_admin(array $form, array &$form_state) { ), ), ), + 'sparql_endpoint_externalized' => array( + '#type' => 'checkbox', + '#title' => t('Use an external SPARQL Query endpoint'), + '#description' => t('If an external query endpoint is used, the repository must be configured to update it.'), + '#default_value' => variable_get('sparql_endpoint_externalized', FALSE), + ), + 'sparql_endpoint' => array( + '#type' => 'textfield', + '#title' => t('SPARQL Query Endpoint'), + '#default_value' => variable_get('sparql_endpoint', ""), + '#description' => t("An external SPARQL Query endpoint to use."), + '#required' => FALSE, + '#states' => array( + 'invisible' => array(':input[name="sparql_endpoint_externalized"]' => array('checked' => FALSE))), + ), 'islandora_repository_pid' => array( '#type' => 'textfield', '#title' => t('Root Collection PID'), From 2cbfbe8116dc29d51d48161ab967633dbae8067e Mon Sep 17 00:00:00 2001 From: ajs6f Date: Fri, 13 Nov 2015 13:38:25 -0500 Subject: [PATCH 5/6] Better variable naming convention --- includes/admin.form.inc | 10 +++++----- includes/tuque.inc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/admin.form.inc b/includes/admin.form.inc index cd52d456..8a071873 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -48,20 +48,20 @@ function islandora_repository_admin(array $form, array &$form_state) { ), ), ), - 'sparql_endpoint_externalized' => array( + 'islandora_sparql_endpoint_externalized' => array( '#type' => 'checkbox', '#title' => t('Use an external SPARQL Query endpoint'), '#description' => t('If an external query endpoint is used, the repository must be configured to update it.'), - '#default_value' => variable_get('sparql_endpoint_externalized', FALSE), + '#default_value' => variable_get('islandora_sparql_endpoint_externalized', FALSE), ), - 'sparql_endpoint' => array( + 'islandora_sparql_endpoint' => array( '#type' => 'textfield', '#title' => t('SPARQL Query Endpoint'), - '#default_value' => variable_get('sparql_endpoint', ""), + '#default_value' => variable_get('islandora_sparql_endpoint', ""), '#description' => t("An external SPARQL Query endpoint to use."), '#required' => FALSE, '#states' => array( - 'invisible' => array(':input[name="sparql_endpoint_externalized"]' => array('checked' => FALSE))), + 'invisible' => array(':input[name="islandora_sparql_endpoint_externalized"]' => array('checked' => FALSE))), ), 'islandora_repository_pid' => array( '#type' => 'textfield', diff --git a/includes/tuque.inc b/includes/tuque.inc index 5e5e3a02..3ffa6f0c 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -87,7 +87,7 @@ class IslandoraTuque { } if (!isset($sparql_endpoint)) { - $sparql_endpoint = variable_get('sparql_endpoint', $url); + $sparql_endpoint = variable_get('islandora_sparql_endpoint', $url); } if (self::exists()) { From d3d3d458d0ec31dfab06e362446823d00f2e7848 Mon Sep 17 00:00:00 2001 From: ajs6f Date: Mon, 16 Nov 2015 13:46:59 -0500 Subject: [PATCH 6/6] Better defaulting behavior for endpoint value --- includes/tuque.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/tuque.inc b/includes/tuque.inc index 3ffa6f0c..26698e02 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -87,7 +87,12 @@ class IslandoraTuque { } if (!isset($sparql_endpoint)) { - $sparql_endpoint = variable_get('islandora_sparql_endpoint', $url); + if (variable_get('islandora_sparql_endpoint_externalized', FALSE)) { + $sparql_endpoint = variable_get('islandora_sparql_endpoint', $url); + } + else { + $sparql_endpoint = $url; + } } if (self::exists()) {