浏览代码

fixed merge conflict

Lacey Sanderson 11 年之前
父节点
当前提交
168abebe09

+ 1 - 2
tripal_contact/includes/tripal_contact.chado_node.inc

@@ -220,7 +220,7 @@ function chado_contact_form(&$node, $form_state) {
   // RELATIONSHIPS FORM
   //---------------------------------------------
   $relationship_cv = tripal_get_default_cv('contact_relationship', 'type_id');
-  $cv_id = $relationship_cv ? $relationship_cv->cv_id : NULL;
+  $cv_id = $relationship_cv ? $relationship_cv->cv_id : NULL;  
   $details = array(
     'relationship_table' => 'contact_relationship', // the name of the _relationship table
     'base_table' => 'contact',                      // the name of your chado base table
@@ -229,7 +229,6 @@ function chado_contact_form(&$node, $form_state) {
     'nodetype' => 'contact',                        // the human-readable name of your node type
     'cv_id' => $cv_id,                              // the cv.cv_id of the cv governing contact_relationship.type_id
     'base_name_field' => 'name',                    // the base table field you want to be used as the name
-    'select_options' => $select_options
   );
   // Adds the form elements to your current form
   chado_add_node_form_relationships($form, $form_state, $details);

+ 2 - 2
tripal_core/api/tripal_core.chado_nodes.properties.api.inc

@@ -341,7 +341,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
   else {
     $ranks = array(); // a temporary array used for calculating rank
     
-    // bulid the SQL for extracting properites already assigned to this record
+    // build the SQL for extracting properties already assigned to this record
     $sql_args = array();
     $sql_args[':chado_id'] = $details['chado_id'];
     if (array_key_exists('cv_name', $details)) {
@@ -371,7 +371,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
     // iterate through the results and get the largest rank for each type
     foreach ($existing_properties as $property) {
       if (array_key_exists($property->type_id, $ranks)) {
-        if($ranks[$property->type_id] < $propety->rank) {
+        if($ranks[$property->type_id] < $property->rank) {
           $ranks[$property->type_id] = $property->rank;
         }
       }

+ 36 - 22
tripal_core/api/tripal_core.mviews.api.inc

@@ -123,32 +123,46 @@ function tripal_add_mview($name, $modulename, $mv_schema, $query, $comment = NUL
      return NULL;
   }
 
-  // Create a new record
-  $record = new stdClass();
-  $record->name = $name;
-  $record->modulename = $modulename;
-  $record->mv_table = $mv_table;
-  $record->query = $query;
-  $record->comment = $comment;
-  $record->mv_schema = $mv_schema;
+  // see if the mv_table name already exsists
+  $mview_id = db_query(
+    'SELECT mview_id FROM {tripal_mviews} WHERE name = :name',
+    array(':name' => $name))->fetchField();
 
-  // add the record to the tripal_mviews table and if successful
-  // create the new materialized view in the chado schema
-  if (drupal_write_record('tripal_mviews', $record)) {
+  if(!$mview_id) {
 
-    // drop the table from chado if it exists
-    if (chado_table_exists($mv_table)) {
-      $sql = 'DROP TABLE {' . $mv_table . '}';
-      chado_query($sql);
-    }
-    // create the table
-    if (!chado_create_custom_table ($mv_table, $mv_schema, 0)) {
-      drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."), 'error');
-    }
-    else {
-      drupal_set_message(t("View '%name' created", array('%name' => $name)));
+    // Create a new record
+    $record = new stdClass();
+    $record->name = $name;
+    $record->modulename = $modulename;
+    $record->mv_table = $mv_table;
+    $record->query = $query;
+    $record->comment = $comment;
+    $record->mv_schema = $mv_schema;
+
+    // add the record to the tripal_mviews table and if successful
+    // create the new materialized view in the chado schema
+    if (drupal_write_record('tripal_mviews', $record)) {
+
+      // drop the table from chado if it exists
+      if (chado_table_exists($mv_table)) {
+        $sql = 'DROP TABLE {' . $mv_table . '}';
+        chado_query($sql);
+      }
+      // create the table
+      if (!chado_create_custom_table ($mv_table, $mv_schema, 0)) {
+        drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."), 'error');
+      }
+      else {
+        drupal_set_message(t("View '%name' created", array('%name' => $name)));
+      }
     }
   }
+  else {
+    tripal_report_error('tripal_cv', TRIPAL_WARNING,
+      "Materialized view, %vname, already exists. Cannot create.",
+      array('%vname' => $name));
+    drupal_set_message(t("Materialized view, $name, already exists. Cannot create.", array('%name' => $name)));
+  }
 }
 
 /**

+ 1 - 1
tripal_core/tripal_core.module

@@ -378,7 +378,7 @@ function tripal_core_menu() {
 
   // Relationshi API autocomplete callback
   $items['tripal_ajax/relationship_nodeform/%/%/name_to_id'] = array(
-    'page callback' => 'chado_node_relationships_name_to_id_callback',
+    'page callback' => 'chado_add_node_form_relationships_name_to_id_callback',
     'page arguments' => array(2,3),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK

+ 1 - 1
tripal_cv/includes/tripal_cv.cvterm_form.inc

@@ -238,7 +238,7 @@ function tripal_cv_add_cvterm_form_fields(&$form, $form_state, $cv_id = 0, $cvte
   $form['fields']['db_id'] = array(
     '#type'         => 'select',
     '#title'         => t('Database'),
-    '#description'   => t('All terms must be assocated with a database.'),
+    '#description'   => t('All terms must be assocated with a database. If the term you are adding is custom for this database, consider creating a database specific for your site and use that anytime you would like to add terms.'),
     '#options'      => $dbs,
     '#default_value' => $db_id,
     '#required' => TRUE,

+ 2 - 0
tripal_cv/tripal_cv.install

@@ -114,6 +114,8 @@ function tripal_cv_schema() {
   
   tripal_cv_get_tripal_cv_obo_table($schema);
   tripal_cv_get_tripal_cv_defaults_table($schema);
+  
+  return $schema;
 }
 /**
  * Table definition for the tripal_cv_obo table

+ 10 - 6
tripal_feature/includes/tripal_feature.chado_node.inc

@@ -139,10 +139,11 @@ function chado_feature_form($node, &$form_state) {
     '#description' => t('Enter a unique name for this feature.  This name must be unique for the organism and feature type.'),
     '#maxlength' => 255
   );
-  // get the sequence ontology CV ID
-  $values = array('name' => 'sequence');
-  $cv = chado_select_record('cv', array('cv_id'), $values);
-  $cv_id = $cv[0]->cv_id;
+  
+  $type_options = tripal_get_cvterm_default_select_options('feature', 'type_id', 'feature types');
+  $type_options[0] = 'Select a Type';
+  $type_cv = tripal_get_default_cv('feature', 'type_id');
+  $cv_id = $type_cv->cv_id;
 
   $form['feature_type'] = array(
    '#title'       => t('Feature Type'),
@@ -230,7 +231,9 @@ function chado_feature_form($node, &$form_state) {
   );
   chado_add_node_form_dbxrefs($form, $form_state, $details);
   
-  
+  // TODO: For some reason adding a relationship to the form breaks AJAX
+  // for features (works for other node type)... need to debug
+  /*
   // RELATIONSHIPS FORM
   //---------------------------------------------
   $relationship_cv = tripal_get_default_cv('feature_relationship', 'type_id');
@@ -244,6 +247,7 @@ function chado_feature_form($node, &$form_state) {
     'cv_id' => $cv_id
   );
   chado_add_node_form_relationships($form, $form_state, $details);
+  */
 
   return $form;
 }
@@ -426,7 +430,7 @@ function chado_feature_insert($node) {
 
   $feature_id = '';
 
-  // if there is an feature_id in the $node object then this must be a sync so
+  // if there is a feature_id in the $node object then this must be a sync so
   // we can skip adding the feature as it is already there, although
   // we do need to proceed with the rest of the insert
   if (!property_exists($node, 'feature_id')) {

+ 1 - 1
tripal_feature/tripal_feature.install

@@ -63,7 +63,7 @@ function tripal_feature_install() {
   // set the default vocabularies
   tripal_set_default_cv('feature', 'type_id', 'sequence');
   tripal_set_default_cv('featureprop', 'type_id', 'feature_property');
-  tripal_set_default_cv('feature_relationships', 'type_id', 'feature_relationships');
+  tripal_set_default_cv('feature_relationship', 'type_id', 'feature_relationship');
 }
 
 /**

+ 1 - 1
tripal_library/includes/tripal_library.chado_node.inc

@@ -162,7 +162,7 @@ function chado_library_form($node, &$form_state) {
   // PROPERTIES FORM
   //---------------------------------------------
   $select_options = array();
-  $prop_cv = tripal_get_default_cv('stockprop', 'type_id');
+  $prop_cv = tripal_get_default_cv('libraryprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
   // if the default is the 'library_property' vocabulary then we want
   // to exclude the 'Library Description' term since it has it's own form element above

+ 1 - 1
tripal_library/tripal_library.install

@@ -59,7 +59,7 @@ function tripal_library_install() {
   tripal_library_add_cvterms();
   
   // set the default vocabularies
-  tripal_set_default_cv('librarypprop', 'type_id', 'library_property');
+  tripal_set_default_cv('libraryprop', 'type_id', 'library_property');
   tripal_set_default_cv('library', 'type_id', 'library_type');
 }
 

+ 7 - 13
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -54,8 +54,9 @@ function chado_stock_load($nodes) {
 
   $new_nodes = array();
   foreach ($nodes as $nid => $node) {
+    
     // get the stock details from chado
-    $stock_id = chado_get_id_from_nid('stock', $node->nid);
+    $stock_id = chado_get_id_from_nid('stock', $nid);
     
     // if the nid does not have a matching record then skip this node.
     // this can happen with orphaned nodes.
@@ -68,8 +69,8 @@ function chado_stock_load($nodes) {
     $stock = chado_generate_var('stock', $values);
     
     // add in the uniquename and the description as these are both text fields
-    $stock = chado_expand_var('stock', 'field', 'stock.uniquename');
-    $stock = chado_expand_var('stock', 'field', 'stock.description');
+    $stock = chado_expand_var($stock, 'field', 'stock.uniquename');
+    $stock = chado_expand_var($stock, 'field', 'stock.description');
 
     // by default, the titles are saved using the unique constraint.  We will
     // keep it the same, but remove the duplicate name if the unique name and name
@@ -95,8 +96,6 @@ function chado_stock_load($nodes) {
 
     // add this to the node
     $node->stock = $stock;
-    
-
     $new_nodes[$nid] = $node;
 
   }
@@ -205,12 +204,7 @@ function chado_stock_form($node, $form_state) {
     $dbxref_description = $form_state['input']['db_description'];
     $dbxref_database = $form_state['input']['database'];
   }
-
-  $form['manually_edit_chado'] = array(
-    '#type' => 'hidden',
-    '#value' => TRUE,
-  );
-
+  
   $form['names'] = array(
     '#type' => 'fieldset',
     '#title' => t('Stock Name')
@@ -478,8 +472,8 @@ function chado_stock_insert($node) {
   // if there is an stock_id in the $node object then this must be a sync so
   // we can skip adding the stock to chado as it is already there, although
   // we do need to proceed with the rest of the insert
-  if (property_exists($node, 'manually_edit_chado')) {
-
+  if (!property_exists($node, 'stock_id')) {
+  
     // before we can add the stock, we must add the dbxref if one has been
     // provided by the user.
     $dbxref_status = 0;