소스 검색

Fixing issue #423... not quite done

Stephen Ficklin 6 년 전
부모
커밋
14cec03dce
3개의 변경된 파일26개의 추가작업 그리고 15개의 파일을 삭제
  1. 1 2
      tripal_ws/api/tripal_ws.api.inc
  2. 23 11
      tripal_ws/includes/TripalFields/remote__data/remote__data.inc
  3. 2 2
      tripal_ws/includes/tripal_ws.admin.inc

+ 1 - 2
tripal_ws/api/tripal_ws.api.inc

@@ -241,11 +241,11 @@ function tripal_get_remote_content($site_id, $path = '', $query = '') {
   if ($query) {
     $ws_url = $ws_url . '?' . $query;
   }
+  dpm($ws_url);
 
   // TODO: something is wrong here, the query is not being recognized on
   // the remote Tripal site. It's just returning the default.
   $data = drupal_http_request($ws_url);
-
   if (!$data) {
     tripal_report_error('tripal_ws', TRIPAL_ERROR,
         t('Could not connect to the remote web service.'));
@@ -263,7 +263,6 @@ function tripal_get_remote_content($site_id, $path = '', $query = '') {
 
   // We got a response, so convert it to a PHP array.
   $data = drupal_json_decode($data->data);
-
   // Check if there was a Tripal Web Services error.
   if (array_key_exists('error', $data)) {
     $error = '</pre>' . print_r($data['error'], TRUE) . '</pre>';

+ 23 - 11
tripal_ws/includes/TripalFields/remote__data/remote__data.inc

@@ -143,7 +143,7 @@ class remote__data extends WebServicesField {
       return;
     }
 
-    // Get the query set by the admin for this field and replace any tokesn
+    // Get the query set by the admin for this field and replace any tokens
     $query_str = $this->instance['settings']['data_info']['query'];
     $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
     $query_str = tripal_replace_entity_tokens($query_str, $entity, $bundle);
@@ -155,10 +155,11 @@ class remote__data extends WebServicesField {
     }
 
     $total_items = $data['totalItems'];
-
+dpm($data);
     // Iterate through the members returned and save those for the field.
-    for ($i = 0; $i < count($data['members']); $i++) {
-      $member = $data['members'][$i];
+    for ($i = 0; $i < $total_items; $i++) {
+      $member = $data['member'][$i];
+      dpm($member);
 
       // Get the cotent type and remote entity id
       $content_type = $member['@type'];
@@ -199,13 +200,12 @@ class remote__data extends WebServicesField {
     *   website.
     */
    private function makeRemoteRequest($query) {
-     $ctype = $query;
-     $qdata = '';
+     $path = $query;
+     $q = '';
      if (preg_match('/\?/', $query)) {
-       list($ctype, $qdata) = explode('?', $query);
+       list($path, $q) = explode('?', $query);
      }
-
-     $data = tripal_get_remote_content($this->remote_site->id, $query);
+     $data = tripal_get_remote_content($this->remote_site->id, $path, $q);
 
      return $data;
    }
@@ -259,8 +259,20 @@ class remote__data extends WebServicesField {
     $element['data_info']['query'] = array(
       '#type' => 'textarea',
       '#title' => 'Query to Execute',
-      '#description' => 'Build the query string that should be appended after the url. The tokens
-      listed below may be used in your query build.',
+      '#description' => 'Enter the query that will retreive the remote records. ' . 
+        'If the full URL to the content web service is ' .
+        'https://[tripal_site]/web-services/content/v0.1/. Then this field should ' .
+        'contain the text immediately after the content/v0.1 portion of the URL. ' .
+        'For information about building web services queries see the ' .
+        'online documentation at ' . l('The Tripal v3 User\'s Guide', 'http://tripal.info/tutorials/v3.x/web-services') . '. ' . 
+        'For example, suppose this field is attached to an ' .
+        'Organism content type on the local site, and you want to retrieve a ' .
+        'field for the same organism on a remote Tripal site then you will ' .
+        'want to query on the genus and species. Also, you want the genus and ' .
+        'species to match the organism that this field is attached to. You can ' .
+        'use tokens to do this (see the "Available Tokesn" fieldset below). ' .
+        'For this example, the query text should be ' . 
+        'Organism?genus=[taxrank__genus]&species=[taxrank__species].',
       '#default_value' => $this->instance['settings']['data_info']['query'],
       '#rows' => 5,
       '#required' => TRUE

+ 2 - 2
tripal_ws/includes/tripal_ws.admin.inc

@@ -98,14 +98,14 @@ function tripal_ws_tripal_sites_edit_form($form, &$form_state, $tripal_site_id =
   $form['tripal_site_info']['url'] = array(
     '#title' => t('URL'),
     '#type' => 'textfield',
-    '#description' => t('The URL of the Tripal site.'),
+    '#description' => t('The URL of the Tripal site, including the "http://" or "https://" followed by the address for the site\'s home page.'),
     '#default_value' => $url,
     '#required' => TRUE
   );
   $form['tripal_site_info']['version'] = array(
     '#title' => t('Version'),
     '#type' => 'textfield',
-    '#description' => t('Web services version used by the Tripal site.'),
+    '#description' => t('Web services version used by the Tripal site (example: v0.1)'),
     '#default_value' => $version,
   );
   $form['tripal_site_info']['description'] = array(