Browse Source

allow sbo__relationship tripal field to work on publications

dsenalik 4 years ago
parent
commit
b81881de93

+ 8 - 1
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship.inc

@@ -249,8 +249,8 @@ class sbo__relationship extends ChadoField {
       case 'element_relationship':
       case 'project_relationship':
       case 'pub_relationship':
+        $this->base_name_columns = ['title'];
         $this->base_type_column = 'table_name';
-        $this->base_name_columns = ['name'];
       break;
 
       case 'organism_relationship':
@@ -419,6 +419,13 @@ class sbo__relationship extends ChadoField {
     // @todo grab these separately like it was before.
     $subject_pkey = $object_pkey = $this->base_schema['primary key'][0];
 
+    // A publication title can exceed the character limit for chado_expand_var()
+    // so make sure it has been added.
+    // TODO Should this step be generalized to other content type that could have a long name?
+    if (in_array('pub.title', $relationship->expandable_fields)) {
+      $relationship = chado_expand_var($relationship, 'field', 'pub.title', []);
+    }
+
     $entity->{$field_name}['und'][$delta]['value'] = [
       'local:relationship_subject' => $this->getRelationshipSubject($relationship),
       'local:relationship_type' => $relationship->type_id->name,