Browse Source

Merge pull request #547 from tripal/491-Tv3-renamed_ws_content_types

Remote fields not working if content type name changed.
Lacey-Anne Sanderson 6 years ago
parent
commit
4ed513ae4f

+ 12 - 5
tripal_ws/includes/TripalFields/remote__data/remote__data.inc

@@ -153,6 +153,15 @@ class remote__data extends WebServicesField {
 
     // Make the request.
     $data = $this->makeRemoteRequest($query_str);
+    $context = [];
+    if (is_array($data['@context'])) {
+      $contenxt = $data['@context'];
+    }
+    else {
+      $context = json_decode(file_get_contents($data['@context']), TRUE);
+      $context = $context['@context'];
+    }
+
     if(!$data){
       $entity->{$field_name}['und'][0]['value'] = 'ERROR: there was a problem retrieving content for this field.';
       $entity->{$field_name}['und'][0]['admin_message'] =  "The remote service returned no data.";
@@ -201,7 +210,7 @@ class remote__data extends WebServicesField {
       $query_field = $subfields[0];
 
       // Next get the the details about this member.
-      $query_field_url =  $content_type . '/' . $remote_entity_id . '/' . $query_field;
+      $query_field_url =  $context[$content_type] . '/' . $remote_entity_id . '/' . $query_field;
       $field_data = $this->makeRemoteRequest($query_field_url);
 
       // If we encounter any type of error, we'll reset the field and return.
@@ -408,10 +417,8 @@ class remote__data extends WebServicesField {
     return $element;
   }
 
- /**
-   *
-   * @param unknown $form
-   * @param unknown $form_state
+  /**
+   * @see TripalField::instanceSettingsFormValidate()
    */
   public function instanceSettingsFormValidate($form, &$form_state) {
     $site_logo = $form_state['values']['instance']['settings']['data_info']['site_logo'];

+ 1 - 4
tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc

@@ -10,10 +10,7 @@ class TripalContentService_v0_1 extends TripalWebService {
   /**
    * A bit of text to describe what this service provides.
    */
-  public static $description = 'Provides acesss to the biological and ' .
-    'ancilliary data available on this site. Each content type represents ' .
-    'biological data that is defined in a controlled vocabulary (e.g. ' .
-    'Sequence Ontology term: gene (SO:0000704)).';
+  public static $description = 'Provides acesss to the biological and ancilliary data available on this site. Each content type represents biological data that is defined in a controlled vocabulary (e.g. Sequence Ontology term: gene (SO:0000704)).';
 
   /**
    * A machine-readable type for this service. This name must be unique