Browse Source

Fixed some formatting issues with some templates. Fixed update_hook_N numbers. Fixed a problem with taxonomy terms being re-assigned to a field_data_taxonomyextra table during upgrade of D6 to D7

Stephen Ficklin 11 years ago
parent
commit
9bd14e2dfa

+ 42 - 0
tripal_analysis/tripal_analysis.install

@@ -251,3 +251,45 @@ function tripal_analysis_add_mview_analysis_organism() {
   tripal_add_mview($view_name, 'tripal_analysis', $schema, $sql, $comment);
 }
 
+/**
+ * This is the required update for tripal_organism when upgrading from Drupal core API 6.x.
+ *
+ */
+function tripal_analysis_update_7200() {
+
+  // During the upgrade from D6 to D7 the vocabulary terms assigned to organisms were
+  // copied to the field_data_taxonomyextra table rather than to the correct
+  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
+  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Analysis'")->fetchField();
+  if ($vid) {
+    try {
+      // first move from the field_data_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_data_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_data_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_analysis'";
+      db_query($sql);
+
+      // next move from the field_revision_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_revision_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_analysis'";
+      db_query($sql);
+    }
+    catch (\PDOException $e) {
+      $error = $e->getMessage();
+      throw new DrupalUpdateException('Could not move organism taxonomy terms: '. $error);
+    }
+  }
+}

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.install

@@ -249,7 +249,7 @@ function tripal_bulk_loader_update_6152() {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_update_7201() {
+function tripal_bulk_loader_update_7200() {
 
   db_change_field(
     'tripal_bulk_loader',

+ 1 - 1
tripal_contact/tripal_contact.install

@@ -228,7 +228,7 @@ function tripal_contact_add_custom_tables(){
  *
  * @ingroup tripal_contact
  */
-function tripal_contact_update_7000() {
+function tripal_contact_update_7200() {
 
   // add the new contact_relationship_types vocabulary
   // We cannot use the Tripal API calls in the 7000 update 

+ 2 - 1
tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc

@@ -279,7 +279,7 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
 
       $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$version]['dbxref_version'] = array(
         '#type' => 'markup',
-        '#markup' => $dbxref->version
+        '#markup' => $dbxref->version,
       );
 
       $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$version]['dbxref_accession'] = array(
@@ -337,6 +337,7 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
 
   $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_version'] = array(
     '#type' => 'textfield',
+    '#size' => 10,
   );
 
   // add button

+ 3 - 3
tripal_core/api/tripal_core.chado_nodes.relationships.api.inc

@@ -438,7 +438,7 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
 
   $form['relationships']['relationship_table']['new']['object_name'] = array(
     '#type' => 'textfield',
-    '#autocomplete_path' => 'tripal_ajax/relationship_nodeform/'.$details['base_table'].'/'.$details['base_name_field'].'/name_to_id'
+    '#autocomplete_path' => 'tripal_ajax/relationship_nodeform/' . $details['base_table'] . '/' . $details['base_name_field'].'/name_to_id'
   );
 
   $form['relationships']['relationship_table']['new']['object_is_current'] = array(
@@ -453,12 +453,12 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
 
   $form['relationships']['relationship_table']['new']['subject_name'] = array(
     '#type' => 'textfield',
-    '#autocomplete_path' => 'tripal_ajax/relationship_nodeform/'.$details['base_table'].'/'.$details['base_name_field'].'/name_to_id'
+    '#autocomplete_path' => 'tripal_ajax/relationship_nodeform/' . $details['base_table'] . '/' . $details['base_name_field'].'/name_to_id'
   );
 
   $form['relationships']['relationship_table']['new']['subject_is_current'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Current '.$details['nodetype']),
+    '#title' => t('Current ' . $details['nodetype']),
   );
 
   $form['relationships']['relationship_table']['new']['rank'] = array(

+ 4 - 1
tripal_feature/theme/tripal_feature/tripal_feature_properties.tpl.php

@@ -21,7 +21,10 @@ if(count($properties) > 0){
   foreach ($properties as $property){
     $property = tripal_core_expand_chado_vars($property,'field','featureprop.value');
     $rows[] = array(
-      ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
+      array(
+        'data' => ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
+        'width' => '20%'
+      ),
       urldecode($property->value)
     );
   }

+ 8 - 8
tripal_feature/theme/tripal_feature/tripal_feature_relationships.tpl.php

@@ -54,10 +54,10 @@ if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
           $organism_name = l("<i>" . $organism->genus . " " . $organism->species . "</i>", "node/" . $organism->nid, array('html' => TRUE));
         }
         $rows[] = array(
-          $feature_name, 
-          $object->record->object_id->uniquename,
-          $organism_name,
-          $object->record->object_id->type_id->name,
+          array('data' => $feature_name, 'width' => '30%'), 
+          array('data' => $object->record->object_id->uniquename, 'width' => '30%'),
+          array('data' => $organism_name, 'width' => '30%'),
+          array('data' => $object->record->object_id->type_id->name, 'width' => '10%'),
         ); 
        } 
        // the $table array contains the headers and rows array as well as other
@@ -112,10 +112,10 @@ if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
           $organism_name = l("<i>" . $organism->genus . " " . $organism->species . "</i>", "node/" . $organism->nid, array('html' => TRUE));
         }
         $rows[] = array(
-          $feature_name, 
-          $subject->record->subject_id->uniquename,
-          $organism_name,
-          $subject->record->subject_id->type_id->name,
+          array('data' => $feature_name, 'width' => '30%'),
+          array('data' =>$subject->record->subject_id->uniquename, 'width' => '30%'),
+          array('data' =>$organism_name, 'width' => '30%'),
+          array('data' =>$subject->record->subject_id->type_id->name, 'width' => '10%'),
         ); 
        } 
        // the $table array contains the headers and rows array as well as other

+ 1 - 1
tripal_feature/theme/tripal_feature/tripal_feature_terms.tpl.php

@@ -42,7 +42,7 @@ if (count($s_terms) > 0) { ?>
       } 
       
       $rows[] = array(
-        $accession,
+        array('data' => $accession, 'width' => '15%'),
         $term->cvterm_id->name
       );
     } 

+ 41 - 0
tripal_feature/tripal_feature.install

@@ -211,3 +211,44 @@ function tripal_feature_add_organism_count_mview() {
 
   tripal_add_mview($view_name, 'tripal_feature', $schema, $sql, $comment);
 }
+
+/**
+ * This is the required update for tripal_feature when upgrading from Drupal core API 6.x.
+ */
+function tripal_feature_update_7200() {
+  // During the upgrade from D6 to D7 the vocabulary terms assigned to features were 
+  // copied to the field_data_taxonomyextra table rather than to the correct
+  // field_data_taxonomy_vocabulary_[vid] table. We'll move them. 
+  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Feature Type'")->fetchField();
+  if ($vid) {
+    try {
+      // first move from the field_data_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_data_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_data_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_feature'";
+      db_query($sql);
+      
+      // next move from the field_revision_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_revision_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_feature'";
+      db_query($sql);
+    }
+    catch (\PDOException $e) {
+      $error = $e->getMessage();
+      throw new DrupalUpdateException('Could not move feature taxonomy terms: '. $error);
+    }
+  }
+}

+ 37 - 2
tripal_library/tripal_library.install

@@ -239,9 +239,8 @@ function tripal_library_add_cvterms() {
 /**
  * This is the required update for tripal_library when upgrading from Drupal core API 6.x.
  *
- * @ingroup tripal_library
  */
-function tripal_library_update_7000() {
+function tripal_library_update_7200() {
 
   // the library types were formerly in a vocabulary named 'tripal_library_types'.
   // rename that to just be 'library_type'. We cannot use the Tripal API calls 
@@ -312,4 +311,40 @@ function tripal_library_update_7000() {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Failed to change library_description property type to the library_property CV and update the name: '. $error);
   }
+  
+  // During the upgrade from D6 to D7 the vocabulary terms assigned to libraries were
+  // copied to the field_data_taxonomyextra table rather than to the correct
+  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
+  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Library'")->fetchField();
+  if ($vid) {
+    try {
+      // first move from the field_data_taxonomyextra table
+      $sql = "
+      INSERT INTO {field_data_taxonomy_vocabulary_$vid}
+      (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_data_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_library'";
+      db_query($sql);
+  
+      // next move from the field_revision_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_revision_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_library'";
+      db_query($sql);
+    }
+    catch (\PDOException $e) {
+      $error = $e->getMessage();
+      throw new DrupalUpdateException('Could not move library taxonomy terms: '. $error);
+    }
+  }
 }

+ 39 - 3
tripal_organism/tripal_organism.install

@@ -127,9 +127,8 @@ function tripal_organism_add_cvterms() {
 /**
  * This is the required update for tripal_organism when upgrading from Drupal core API 6.x.
  *
- * @ingroup tripal_organism
  */
-function tripal_organism_update_7000() {
+function tripal_organism_update_7200() {
 
   // add the new organism_property vocabulary
   // We cannot use the Tripal API calls in the 7000 update 
@@ -148,4 +147,41 @@ function tripal_organism_update_7000() {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Failed to add organism_property vocabulary: '. $error);
   }
-}
+  
+
+  // During the upgrade from D6 to D7 the vocabulary terms assigned to organisms were
+  // copied to the field_data_taxonomyextra table rather than to the correct
+  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
+  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Organism'")->fetchField();
+  if ($vid) {
+    try {
+      // first move from the field_data_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_data_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_data_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_organism'";
+      db_query($sql);
+
+      // next move from the field_revision_taxonomyextra table
+      $sql = "
+        INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
+          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
+        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
+         FROM field_revision_taxonomyextra
+         WHERE bundle = 'chado_feature')
+      ";
+      db_query($sql);
+      $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_organism'";
+      db_query($sql);
+    }
+    catch (\PDOException $e) {
+      $error = $e->getMessage();
+      throw new DrupalUpdateException('Could not move organism taxonomy terms: '. $error);
+    }
+  }
+}

+ 1 - 1
tripal_project/tripal_project.install

@@ -131,7 +131,7 @@ function tripal_project_add_cvterms() {
  *
  * @ingroup tripal_project
  */
-function tripal_project_update_7000() {
+function tripal_project_update_7200() {
   
   // add the project_property CV
   try {

+ 1 - 1
tripal_pub/tripal_pub.install

@@ -245,7 +245,7 @@ function tripal_pub_add_cvterms() {
  *
  * @ingroup tripal_pub
  */
-function tripal_pub_update_7000() {
+function tripal_pub_update_7200() {
 
   // add the new pub_relationship_types vocabulary
   // We cannot use the Tripal API calls in the 7000 update 

+ 1 - 1
tripal_stock/theme/tripal_stock/tripal_stock_properties.tpl.php

@@ -36,7 +36,7 @@ if(count($properties) > 0){
   foreach ($properties as $property){
     $property = tripal_core_expand_chado_vars($property,'field','stockprop.value');
     $rows[] = array(
-      ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
+      array('data' => ucfirst(preg_replace('/_/', ' ', $property->type_id->name)), 'width' => '20%'),
       urldecode($property->value)
     );
   }

+ 8 - 8
tripal_stock/theme/tripal_stock/tripal_stock_relationships.tpl.php

@@ -54,10 +54,10 @@ if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
           $organism_name = l("<i>" . $organism->genus . " " . $organism->species . "</i>", "node/" . $organism->nid, array('html' => TRUE));
         }
         $rows[] = array(
-          $stock_name, 
-          $object->record->object_id->uniquename,
-          $organism_name,
-          $object->record->object_id->type_id->name,
+          array('data' => $stock_name, 'width' => '30%'),
+          array('data' => $object->record->object_id->uniquename, 'width' => '30%'),
+          array('data' => $organism_name, 'width' => '30%'),
+          array('data' => $object->record->object_id->type_id->name, 'width' => '10%'),
         ); 
        } 
        // the $table array contains the headers and rows array as well as other
@@ -112,10 +112,10 @@ if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
           $organism_name = l("<i>" . $organism->genus . " " . $organism->species . "</i>", "node/" . $organism->nid, array('html' => TRUE));
         }
         $rows[] = array(
-          $stock_name, 
-          $subject->record->subject_id->uniquename,
-          $organism_name,
-          $subject->record->subject_id->type_id->name,
+          array('data' => $stock_name, 'width' => '30%'),
+          array('data' => $subject->record->subject_id->uniquename, 'width' => '30%'),
+          array('data' => $organism_name, 'width' => '30%'),
+          array('data' =>$subject->record->subject_id->type_id->name, 'width' => '10%'),
         ); 
        } 
        // the $table array contains the headers and rows array as well as other

+ 1 - 1
tripal_views/tripal_views.install

@@ -135,7 +135,7 @@ function tripal_views_update_6040() {
  *
  * @ingroup tripal_views
  */
-function tripal_views_update_7020() {
+function tripal_views_update_7200() {
 
   // Add relationship_handler to tripal_views_join
   db_add_field(