Selaa lähdekoodia

Merge branch '7.x-3.x' into 759_3x_tripal-registration-form

Stephen Ficklin 5 vuotta sitten
vanhempi
commit
1c50b9a6ec

+ 0 - 8
tripal/includes/TripalFields/TripalField.inc

@@ -208,14 +208,6 @@ class TripalField {
     return $this->instance;
   }
 
-  /**
-   * When constructing a pager for use by a field, all pagers must have
-   * a unique ID
-   */
-  protected function getPagerElementID() {
-    return $this->field['id'];
-  }
-
   public function getFieldTerm() {
     return $this->term;
   }

+ 0 - 8
tripal/includes/TripalFields/TripalFieldFormatter.inc

@@ -167,14 +167,6 @@ class TripalFieldFormatter {
 
   }
 
-  /**
-   * When constructing a pager for use by a field, all pagers must have
-   * a unique ID
-   */
-  protected function getPagerElementID() {
-    return $this->field['id'];
-  }
-
   /**
    * Updates a pager generated by theme('pager') for use with AJAX.
    *

+ 2 - 5
tripal/theme/js/tripal.js

@@ -208,18 +208,15 @@
 
 // Used for ajax update of fields by links in a pager.
 function tripal_navigate_field_pager(id, page) {
-  jQuery(document).ajaxStart(function () {
-    jQuery('#' + id + '-spinner').show();
-  }).ajaxComplete(function () {
-    jQuery('#' + id + '-spinner').hide();
-  });
 
+  jQuery('#' + id + '-spinner').show();
   jQuery.ajax({
     type   : 'GET',
     url    : Drupal.settings['basePath'] + 'bio_data/ajax/field_attach/' + id,
     data   : {'page': page},
     success: function (response) {
       jQuery('#' + id + ' .field-items').replaceWith(response['content']);
+      jQuery('#' + id + '-spinner').hide();
     }
   });
 }

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

@@ -119,7 +119,7 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
     $items_per_page = array_key_exists('items_per_page', $this->instance['settings']) ? $this->instance['settings']['items_per_page'] : 10;
     $total_records = count($rows);
     $total_pages = (int) ($total_records / $items_per_page) + 1;
-    $pelement = 0; //$this->getPagerElementID();
+    $pelement = 0;
     $current_page = pager_default_initialize($total_records, $items_per_page, $pelement);
     $pager = theme('pager', [
       'tags' => [],

+ 80 - 1
tripal_chado/tripal_chado.install

@@ -29,6 +29,10 @@ function tripal_chado_install() {
       )
     ";
     chado_query($sql);
+
+    // Fix the SOFP feature_property issue from the legacy feature_property.
+    tripal_chado_fix_legacy_SOFP_7338();
+
   }
 
   tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
@@ -683,6 +687,63 @@ function tripal_chado_chado_cvterm_mapping_schema() {
   return $schema;
 }
 
+
+
+/**
+ * Fixes a problem with the legacy feature_property/SOFP
+ * ontology loaded with previous verions of Chado and all terms are
+ * relationships.
+ *
+ * This function is called by the tripal_chado_install() for a
+ * new Tripal setup, and the tripal_chado_update_7338 for an existing
+ * site.
+ */
+
+function tripal_chado_fix_legacy_SOFP_7338() {
+
+  $sofp =  chado_get_db(['name' => 'SOFP']);
+  $fp = chado_get_cv(['name' => 'feature_property']);
+
+  // No need to update unless the SOFP db exists
+  if (!$sofp || !$fp) {
+    return;
+  }
+  $terms = chado_select_record('cvterm', ['cvterm_id', 'name'], [
+    'dbxref_id' => [
+      'db_id' => [
+        'name' => 'SOFP',
+      ],
+    ],
+    'cv_id' => ['name' => 'feature_property'],
+  ]);
+
+  if (empty($terms)) {
+    return;
+  }
+
+  foreach ($terms as $term) {
+
+    $id = $term->cvterm_id;
+    $name = $term->name;
+
+    if ($name == 'linked_to') {
+      continue;
+    }
+    chado_update_record('cvterm', ['cvterm_id' => $id], ['is_relationshiptype' => 0]);
+  }
+
+  // Repopulate the mview.
+  $mview_id = chado_get_mview_id('db2cv_mview');
+  global $user;
+  tripal_add_job(
+    'Repopulating db2cv to fix legacy SOFP',
+    'tripal_chado',
+    'chado_populate_mview',
+    [$mview_id],
+    $user->uid
+  );
+}
+
 /**
  * Fixes the phase on the tripal_gffcds_temp table used for importing GFF files, and fixes the db.name term mapping.
  *
@@ -1859,7 +1920,7 @@ function tripal_chado_update_7336() {
 /**
  * Update the NCBITaxon DB entry.
  */
-function tripal_chado_update_7337(){
+function tripal_chado_update_7337() {
 
   chado_insert_db(array(
     'name' => 'NCBITaxon',
@@ -1868,3 +1929,21 @@ function tripal_chado_update_7337(){
     'urlprefix' => 'https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={accession}',
   ));
 }
+
+/**
+ * Correctly flag SOFP terms as "not" relationships, allowing the mview to
+ * populate them.
+ */
+function tripal_chado_update_7338() {
+
+  try {
+    // Get all SOFP terms and set their is_relationshiptype to 0
+
+    tripal_chado_fix_legacy_SOFP_7338();
+
+  } catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: ' . $error);
+  }
+
+}