Browse Source

Added support for featuremap/project migration. Fixed bugs for linker_contact, linker_prop, relationship fields.

Chun-Huai Cheng 8 years ago
parent
commit
9186fbf098

+ 3 - 0
tripal_chado/includes/TripalFields/chado_linker__contact/chado_linker__contact.inc

@@ -73,6 +73,9 @@ class chado_linker__contact extends ChadoField {
     $schema = chado_get_schema($field_table);
     $base_table = $details['record']->tablename;
     $pkey = $schema['primary key'][0];
+    if (!isset($schema['foreign keys'][$base_table]['columns'])) {
+      return;
+    }
     $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
     $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
 

+ 4 - 1
tripal_chado/includes/TripalFields/chado_linker__prop/chado_linker__prop.inc

@@ -80,7 +80,10 @@ class chado_linker__prop extends ChadoField {
 
     // Get the FK that links to the base record.
     $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
+    $pkey = $schema['primary key'][0];    
+    if (!isset($schema['foreign keys'][$base_table]['columns'])) {
+      return;
+    }
     $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
     $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
 

+ 2 - 0
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship.inc

@@ -497,6 +497,8 @@ class sbo__relationship extends ChadoField {
       case 'has origin':
       case 'has part':
       case 'has quality':
+      case 'is a maternal parent of':
+      case 'is a paternal parent of':
       case 'is consecutive sequence of':
       case 'maximally overlaps':
       case 'overlaps':

+ 57 - 0
tripal_chado/includes/tripal_chado.migrate.inc

@@ -194,6 +194,42 @@ function tripal_chado_migrate_form($form, &$form_state) {
           $no_data = FALSE;
         }
       }
+      else if ($table == 'project') {
+        $sql =
+        "SELECT count(*)
+              FROM {project} P
+              INNER JOIN public.chado_project CP ON P.project_id = CP.project_id
+              LEFT JOIN public.chado_entity CE ON CE.record_id = P.project_id
+                AND CE.data_table = 'project'
+              WHERE CE.record_id IS NULL";
+        $proj_count = chado_query($sql)->fetchField();
+        if ($proj_count > 0) {
+          $key = urlencode('tv3_content_type--local--project--project');
+          $form['step2']['step2_container']['tv3_content_type'][$key] = array(
+            '#type' => 'checkbox',
+            '#title' => 'Project (' . $proj_count . ')',
+          );
+          $no_data = FALSE;
+        }
+      }
+      else if ($table == 'featuremap') {
+        $sql =
+        "SELECT count(*)
+              FROM {featuremap} M
+              INNER JOIN public.chado_featuremap CM ON M.featuremap_id = CM.featuremap_id
+              LEFT JOIN public.chado_entity CE ON CE.record_id = M.featuremap_id
+                AND CE.data_table = 'featuremap'
+              WHERE CE.record_id IS NULL";
+        $map_count = chado_query($sql)->fetchField();
+        if ($map_count > 0) {
+          $key = urlencode('tv3_content_type--data--1274--map');
+          $form['step2']['step2_container']['tv3_content_type'][$key] = array(
+            '#type' => 'checkbox',
+            '#title' => 'Map (' . $map_count . ')',
+          );
+          $no_data = FALSE;
+        }
+      }
       if ($no_data) {
         unset($form['step2']['step2_container']['tv3_content_type']['tv3_migrate_all']);
         drupal_set_message('No data for migration or all have been migrated.', 'warning');
@@ -612,6 +648,27 @@ function tripal_chado_migrate_map_types($tv2_content_types) {
         )
       ));
     }
+    else if ($table == 'project') {
+      array_push($types, array(
+        'vocabulary' => 'local',
+        'accession' => 'project',
+        'term_name' => 'project',
+        'storage_args' => array (
+          'data_table' => $table
+        )
+      ));
+    }
+    else if ($table == 'featuremap') {
+      array_push($types, array(
+        'vocabulary' => 'data',
+        'accession' => '1274',
+        'term_name' => 'map',
+        'storage_args' => array (
+          'data_table' => $table
+        )
+    ));
+  }
+
   }
   return $types;
 }