Explorar o código

Moved obo loading temp table to CV module install file

Stephen Ficklin %!s(int64=11) %!d(string=hai) anos
pai
achega
e100340662

+ 1 - 41
tripal_cv/api/tripal_cv.api.inc

@@ -736,7 +736,7 @@ function tripal_cv_add_cvterm($term, $defaultcv = '_global', $is_relationship =
       return 0;
     } 
     $result = chado_query($cvtermsql, array(':accession' => $accession, ':name' => $dbname));
-    $cvterm = $result->fetchObject();   
+    $cvterm = $result->fetchObject();
   }
   // upate the cvterm
   elseif ($update) { 
@@ -763,46 +763,6 @@ function tripal_cv_add_cvterm($term, $defaultcv = '_global', $is_relationship =
   return $cvterm;
 }
 
-
-/**
- * This function defines the custom tables that will be created 
- * in the chado schema.
- *
- * @ingroup tripal_cv_api
- */
-function tripal_cv_get_custom_tables($table = NULL) {
-
- if (!$table or strcmp($table, 'tripal_obo_temp')==0) {
-    $schema['tripal_obo_temp'] = array(
-      'table' => 'tripal_obo_temp',
-      'fields' => array(
-        'id' => array(
-          'type' => 'varchar',
-          'length' => '255',
-          'not null' => TRUE,
-        ),
-        'stanza' => array(
-          'type' => 'text',
-          'not null' => TRUE,
-        ),
-        'type' => array(
-          'type' => 'varchar',
-          'length' => '50',
-          'not null' => TRUE,
-        ),
-      ),
-      'indexes' => array(
-        'tripal_obo_temp_idx0' => array('id'),
-        'tripal_obo_temp_idx0' => array('type'),
-      ),
-      'unique keys' => array(
-        'tripal_obo_temp_uq0' => array('id'),
-      ),
-    );
-  }
-  return $schema;
-}
-
 /**
  * This function allows other modules to programatically
  * submit an ontology for loading into Chado.  This function

+ 1 - 8
tripal_cv/includes/obo_loader.inc

@@ -223,14 +223,7 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
     
   // make sure our temporary table exists
   $ret = array(); 
-  if (!chado_table_exists('tripal_obo_temp')) { 
-    $schema = tripal_cv_get_custom_tables('tripal_obo_temp');  
-    $success = tripal_core_create_custom_table('tripal_obo_temp', $schema['tripal_obo_temp']);
-    if (!$success) {
-      watchdog('T_obo_loader', "Cannot create temporary loading table", array(), WATCHDOG_ERROR); 
-      return;
-    } 
-  }
+
   // empty the temp table
   $sql = "DELETE FROM {tripal_obo_temp}";
   chado_query($sql);

+ 38 - 1
tripal_cv/tripal_cv.install

@@ -49,8 +49,11 @@ function tripal_cv_install() {
   // add the cv_root_mview
   tripal_cv_add_cv_root_mview();
 
-  // create the tables that correlate OBO files/references with a chado CV
+  // add defaults to the tables that correlate OBO files/references with a chado CV
   tripal_cv_add_obo_defaults();
+  
+  // add the custom tables to Chado
+  tripal_cv_add_custom_tables();
 }
 /**
  * Implementation of hook_uninstall().
@@ -95,6 +98,7 @@ function tripal_cv_schema() {
     ),
     'primary key' => array('obo_id'),
   );
+  
 
   return $schema;
 }
@@ -170,3 +174,36 @@ function tripal_cv_add_obo_defaults() {
     db_query("INSERT INTO {tripal_cv_obo} (name,path) VALUES (:name, :path)", array(':name' => $o[0], ':path' => $o[1]));
   }
 }
+
+/**
+ * 
+ */
+function tripal_cv_add_custom_tables() {
+  $schema = array(
+    'table' => 'tripal_obo_temp',
+    'fields' => array(
+      'id' => array(
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+      ),
+      'stanza' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+      'type' => array(
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE,
+      ),
+    ),
+    'indexes' => array(
+      'tripal_obo_temp_idx0' => array('id'),
+      'tripal_obo_temp_idx0' => array('type'),
+    ),
+    'unique keys' => array(
+      'tripal_obo_temp_uq0' => array('id'),
+    ),
+  );
+  tripal_core_create_custom_table('tripal_obo_temp', $schema, TRUE);
+}