Browse Source

Fix for issue #430

Stephen Ficklin 6 years ago
parent
commit
0bea4a5c3d

+ 1 - 2
tripal/api/tripal.entities.api.inc

@@ -358,8 +358,7 @@ function tripal_load_bundle_entity($values) {
 }
 
 /**
- * Allows a module to write to the admin notification table
- * during the cron run.
+ * Allows a module to write to the admin notification table.
  *
  * @param $title
  *   A generic phrase indicating what the notification is for.

+ 28 - 1
tripal/api/tripal.terms.api.inc

@@ -389,7 +389,34 @@ function tripal_get_term_details($vocabulary, $accession) {
     $module = $stores[$keys[0]]['module'];
     $function = $module . '_vocab_get_term';
     if (function_exists($function)) {
-      return $function($vocabulary, $accession);
+      $term = $function($vocabulary, $accession);
+      
+      // Make sure the term has a URL. If it does not, then use the Tripal
+      // interface as the URL for the term.
+      $url_missing = FALSE;
+      if (!$term['url']) {
+        $url_missing = TRUE;
+        $term['url'] = url('cv/lookup/' . $term['vocabulary']['short_name'] . '/' . $term['accession'], ['absolute' => TRUE]);
+      }
+      if (!$term['vocabulary']['sw_url']) {
+        $url_missing = TRUE;
+        $term['vocabulary']['sw_url'] = url('cv/lookup/' . $term['vocabulary']['short_name'] . '/' . $term['accession'], ['absolute' => TRUE]);
+      }
+      // Let the user know that the vocabulary is missing.
+      if ($url_missing) {
+        tripal_add_notification(
+          "Missing CV term URL", 
+          t("The controlled vocabulary, %vocab, is missing a URL. Tripal will handle " .
+            "this by linking to the cv/lookup page of this site. However, the correct " .
+            "should be updated for this site", 
+            ['%vocab' => $term['vocabulary']['short_name']]),
+          'Controlled Vocabularies', 
+          NULL, 
+          'mising-vocab-' . $term['vocabulary']['short_name']
+        );
+      }
+      
+      return $term;
     }
   }
 }

+ 0 - 5
tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc

@@ -996,11 +996,6 @@ class TripalContentService_v0_1 extends TripalWebService {
       $member->addContextItem($accession, 'vocab:' . $accession);
       $member->setType($accession);
 
-      // Make sure the term has a URL.
-      $url = $term['url'];
-      if (!$url) {
-        throw new Exception(t('Missing a URL for the term: @term.', array('@term' => $term['vocabulary']['short_name'] . ':' . $term['accession'])));
-      }
       $this->addResourceProperty($member, $label, $bundle->label . ' Collection');
       $member->addContextItem('description', 'rdfs:comment');
       // Get the bundle description. If no description is provided then