Browse Source

updated chado_add_node_form_properties() to include better error checking and to use new chado_id and chado_id_field options

Stephen Ficklin 11 years ago
parent
commit
c3d11a97cb

+ 3 - 4
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -234,10 +234,9 @@ function chado_analysis_form($node, &$form_state) {
   // ----------------------------------
   // ----------------------------------
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $details = array(
   $details = array(
-    'property_table' => 'analysisprop',             // the name of the prop table
-    'base_foreign_key' => 'analysis_id',            // the name of the key in your base chado table
-    'base_key_value' => $analysis_id,               // the value of analysis_id for this record
-    'cv_name' => 'analysis_property',               // the cv.name of the cv governing analysisprop.type_id
+    'property_table' => 'analysisprop',       // the name of the prop table
+    'chado_id' => $analysis_id,               // the value of analysis_id for this record
+    'cv_name' => 'analysis_property',         // the cv.name of the cv governing analysisprop.type_id
     'fieldset_title' => 'Properties',
     'fieldset_title' => 'Properties',
     'additional_instructions' => $instructions
     'additional_instructions' => $instructions
   );
   );

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

@@ -197,8 +197,7 @@ function chado_contact_form(&$node, $form_state) {
 
 
   $details = array(
   $details = array(
     'property_table' => 'contactprop',
     'property_table' => 'contactprop',
-    'base_foreign_key' => 'contact_id',
-    'base_key_value' => $contact_id,
+    'chado_id' => 'contact_id',
     'cv_name' => 'tripal_contact',
     'cv_name' => 'tripal_contact',
     'select_options' => $select_options
     'select_options' => $select_options
   );
   );

+ 76 - 47
tripal_core/api/tripal_core.chado_nodes.properties.api.inc

@@ -32,8 +32,8 @@
 
 
     $details = array(
     $details = array(
       'property_table' => 'example_property',      // the name of the table linking additional properties to this node
       'property_table' => 'example_property',      // the name of the table linking additional properties to this node
-      'base_foreign_key' => 'example_id',          // key to link to the chado content created by this node
-      'base_key_value' => $example_id,             // the value of the above key
+      'chado_id_field' => 'example_id',          // key to link to the chado content created by this node
+      'chado_id' => $example_id,             // the value of the above key
       'cv_name' => 'example_prop_cv',              // the name of the cv governing the _prop.type_id
       'cv_name' => 'example_prop_cv',              // the name of the cv governing the _prop.type_id
       'fieldset_title' => 'Additional References', // the non-translated title for this fieldset
       'fieldset_title' => 'Additional References', // the non-translated title for this fieldset
       'additional_instructions' => ''              // a non-stranslated string providing additional instructions
       'additional_instructions' => ''              // a non-stranslated string providing additional instructions
@@ -105,28 +105,82 @@
  * @param $form_state
  * @param $form_state
  *   The corresponding form_state array for the form
  *   The corresponding form_state array for the form
  * @param $details
  * @param $details
- *   An array defining details needed by this form. Required Keys are:
- *     - property_table: the name of the property linking table (ie: featureprop)
- *     - base_foreign_key: the name of the foreign key linking this table to the non-property table (ie: feature_id)
- *     - base_key_value: the value of the base_foreign_key for the current form (ie: 999 if the feature_id=999)
- *   Require ONE of the following:
- *     The controlled vocabulary governing the property types
- *       -cv_id: the unique key from the cv table
- *       -cv_name: the cv.name field uniquely identifying the controlled vocab
+ *   An array defining details used by this form. 
+ *   Required keys that are always required:
+ *     - property_table: the name of the property table (e.g.: featureprop, stockprop, etc.)
+ *   Required keys for forms that update a record.
+ *     - chado_id: the id of the record to which properties will be associated (e.g.: if a
+ *       feature has a feature_id of 999 and we want to associate properties for that feature 
+ *       then the chado_id option should be 999)
+ *   Require ONE of the following to identify the controlled vocabulary containing the properties to use:
+ *     -cv_id: the unique key from the cv table
+ *     -cv_name: the cv.name field uniquely identifying the controlled vocabulary
  *   Optional keys include:
  *   Optional keys include:
- *     - fieldset_title: the non-translated title for this fieldset
- *     - additional_instructions: a non-translated string providing additional instructions
- *     - select_options: must be an array where the [key] is a valid cvterm_id and
- *       the [value] is the human-readable name of the option. This is generated from the cv_name/id by default
+ *     - chado_id_field: the foreign key field that links properties to the
+ *       chado_id record. If this value is not specified it is determined using the
+ *       traditional Chado naming scheme for property tables. 
  *
  *
  * @ingroup tripal_chado_node_api
  * @ingroup tripal_chado_node_api
  */
  */
 function chado_add_node_form_properties(&$form, &$form_state, $details) {
 function chado_add_node_form_properties(&$form, &$form_state, $details) {
 
 
+  // make sure the property table exists before proceeding.
+  if (!chado_table_exists($details['property_table'])) {
+    drupal_set_message("Cannot add property elements to the form. The property table, '" . 
+      $details['property_table'] . "', does not exists", "error");
+    tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add property elements to the form. 
+      The property table, '%name', cannot be found.", array('%name' => $details['property_table']));
+    return;
+  }
+  
+  // if the chado_id_field is not specified then set it using the
+  // typical chado naming scheme
+  if (!array_key_exists('chado_id_field', $details)) {
+    $chado_id_table = preg_replace('/prop$/', '', $details['property_table']);
+    $chado_id_field = $chado_id_table . '_id';
+    $details['chado_id_field'] = $chado_id_field;
+  }
+  
+  // make sure the specified cv exists
+  if (isset($details['cv_name'])) {
+    // make sure the cv_name is real
+    $result = chado_select_record('cv',array('cv_id'),array('name' => $details['cv_name']));
+    if (count($result) == 0) {
+      drupal_set_message("Cannot add property elements to the form. The CV name, '" .
+        $details['cv_name'] . "', does not exists", "error");
+      tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add property elements to the form.
+        The CV named, '%name', cannot be found.", array('%name' => $details['cv_name']));
+      return;
+    }
+    // add the cv_id option to the details array
+    $details['cv_id'] = $result[0]->cv_id;
+  }
+  elseif (isset($details['cv_id'])) {
+    // make sure the cv_id is real
+    $result = chado_select_record('cv', array('name'), array('cv_id' => $details['cv_id']));
+    if (count($result) == 0) {
+      drupal_set_message("Cannot add property elements to the form. The CV ID, '" .
+        $details['cv_id'] . "', does not exist", "error");
+      tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add property elements
+        to the form. The CV ID, '%id', cannot be found.", array('%id' => $details['cv_id']));
+      return;
+    }
+    // add the cv_name option to the details array
+    $details['cv_name'] = $result[0]->name;
+  }
+  else {
+    drupal_set_message("Please provide either a 'cv_name' or 'cv_id' as an 
+        option for adding properties to the form", "error");
+    tripal_report_error('tcprops_form', TRIPAL_ERROR, "Please provide either a 
+        'cv_name' or 'cv_id' as an option for adding properties to the form", array());
+    return;
+  }
+
   // Set Defaults for optional fields
   // Set Defaults for optional fields
   $details['fieldset_title'] = 'Properties';
   $details['fieldset_title'] = 'Properties';
   $details['additional_instructions'] = '';
   $details['additional_instructions'] = '';
 
 
+  
   // Get Property Types for the Select List
   // Get Property Types for the Select List
   if (isset($details['select_options'])) {
   if (isset($details['select_options'])) {
     $property_options = $details['select_options'];
     $property_options = $details['select_options'];
@@ -137,17 +191,6 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
     // if the vocabulary name is provided in the details then use that to
     // if the vocabulary name is provided in the details then use that to
     // get the terms 
     // get the terms 
     if (isset($details['cv_name'])) {
     if (isset($details['cv_name'])) {
-      // make sure the cv_name is real
-      $result = chado_select_record('cv',array('cv_id'),array('name' => $details['cv_name']));
-      if (count($result) == 0) {
-        drupal_set_message("Cannot add property elements to the form. The CV name, '" . $details['cv_name'] . "', does not exists", "error");
-        tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add property elements to the form. The CV named, '%name',
-          cannot be found.", array('%name' => $details['cv_name']));
-        return;
-      }
-      // add the cv_id option to the details array
-      $details['cv_id'] = $result[0]->cv_id;
-      
       $property_options = array();
       $property_options = array();
       $property_options[] = 'Select a Property';
       $property_options[] = 'Select a Property';
       $sql = "
       $sql = "
@@ -162,22 +205,10 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
       $prop_types = chado_query($sql, array(':cv_name' => $details['cv_name']));
       $prop_types = chado_query($sql, array(':cv_name' => $details['cv_name']));
       while ($prop = $prop_types->fetchObject()) {
       while ($prop = $prop_types->fetchObject()) {
         $property_options[$prop->cvterm_id] = $prop->name;
         $property_options[$prop->cvterm_id] = $prop->name;
-        $details['cv_id'] = $prop->cv_id;
       }
       }
     } 
     } 
     // if the cv_id is set in the $details array then use that to get the terms
     // if the cv_id is set in the $details array then use that to get the terms
-    elseif (isset($details['cv_id'])) {
-      // make sure the cv_id is real
-      $result = chado_select_record('cv', array('name'), array('cv_id' => $details['cv_id']));
-      if (count($result) == 0) {
-        drupal_set_message("Cannot add property elements to the form. The CV ID, '" . $details['cv_id'] . "', does not exist", "error");
-        tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add property elements to the form. The CV ID, '%id',
-          cannot be found.", array('%id' => $details['cv_id']));
-        return;
-      }
-      // add the cv_name option to the details array
-      $details['cv_name'] = $result[0]->name;
-      
+    elseif (isset($details['cv_id'])) {      
       $property_options = array();
       $property_options = array();
       $property_options[] = 'Select a Property';
       $property_options[] = 'Select a Property';
       $sql = "
       $sql = "
@@ -193,8 +224,6 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
       while ($prop = $prop_types->fetchObject()) {
       while ($prop = $prop_types->fetchObject()) {
         $property_options[$prop->cvterm_id] = $prop->name;
         $property_options[$prop->cvterm_id] = $prop->name;
       }
       }
-      
-
     }
     }
   }
   }
 
 
@@ -206,7 +235,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
         to the %cv_name controlled vocabulary.',
         to the %cv_name controlled vocabulary.',
         array(
         array(
           '%cv_name' => $details['cv_name'],
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/chado/tripal_cv/cv/'.$details['cv_id'].'/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/chado/tripal_cv/cv/' . $details['cv_id'] . '/cvterm/add')
         )
         )
       ),
       ),
       TRIPAL_WARNING,
       TRIPAL_WARNING,
@@ -219,7 +248,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
         a controlled vocabulary term</a> to the %cv_name controlled vocabulary.',
         a controlled vocabulary term</a> to the %cv_name controlled vocabulary.',
         array(
         array(
           '%cv_name' => $details['cv_name'],
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/chado/tripal_cv/cv/'.$details['cv_id'].'/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/chado/tripal_cv/cv/' . $details['cv_id'] . '/cvterm/add')
         )
         )
       ),
       ),
       TRIPAL_INFO,
       TRIPAL_INFO,
@@ -282,10 +311,10 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
         INNER JOIN {cvterm} CVT ON CVT.cvterm_id = PP.type_id
         INNER JOIN {cvterm} CVT ON CVT.cvterm_id = PP.type_id
         INNER JOIN {cv} CV      ON CVT.cv_id     = CV.cv_id
         INNER JOIN {cv} CV      ON CVT.cv_id     = CV.cv_id
         WHERE
         WHERE
-        PP." . $details['base_foreign_key'] . " = :base_key_value AND
+        PP." . $details['chado_id_field'] . " = :chado_id AND
         CV.name = '" .$details['cv_name']. "'
         CV.name = '" .$details['cv_name']. "'
         ORDER BY CVT.name, PP.rank",
         ORDER BY CVT.name, PP.rank",
-         array(':base_key_value' => $details['base_key_value'])
+         array(':chado_id' => $details['chado_id'])
       );
       );
     } elseif (isset($details['cv_id'])) {
     } elseif (isset($details['cv_id'])) {
       $existing_properties = chado_query(
       $existing_properties = chado_query(
@@ -294,10 +323,10 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
         INNER JOIN {cvterm} CVT ON CVT.cvterm_id = PP.type_id
         INNER JOIN {cvterm} CVT ON CVT.cvterm_id = PP.type_id
         INNER JOIN {cv} CV      ON CVT.cv_id     = CV.cv_id
         INNER JOIN {cv} CV      ON CVT.cv_id     = CV.cv_id
         WHERE
         WHERE
-        PP." . $details['base_foreign_key'] . " = :base_key_value AND
+        PP." . $details['chado_id_field'] . " = :chado_id AND
         CV.cv_id = '" .$details['cv_id']. "'
         CV.cv_id = '" .$details['cv_id']. "'
         ORDER BY CVT.name, PP.rank",
         ORDER BY CVT.name, PP.rank",
-         array(':base_key_value' => $details['base_key_value'])
+         array(':chado_id' => $details['chado_id'])
       );
       );
     }
     }
   }
   }
@@ -508,7 +537,7 @@ function chado_add_node_form_properties_add_button_submit(&$form, &$form_state)
   $rank = chado_get_table_max_rank(
   $rank = chado_get_table_max_rank(
     $details['property_table'],
     $details['property_table'],
     array(
     array(
-      $details['base_foreign_key'] => $details['base_key_value'],
+      $details['chado_id_field'] => $details['chado_id'],
       'type_id' => $property['type_id']
       'type_id' => $property['type_id']
     )
     )
   );
   );

+ 50 - 28
tripal_core/api/tripal_core.chado_nodes.relationships.api.inc

@@ -106,7 +106,7 @@
  *   An array defining details needed by this form. Required Keys are:
  *   An array defining details needed by this form. Required Keys are:
  *     - relationship_table: the name of the relationship table (ie: feature_relationship)
  *     - relationship_table: the name of the relationship table (ie: feature_relationship)
  *     - base_table: the name of the base table (ie: feature)
  *     - base_table: the name of the base table (ie: feature)
- *     - base_foreign_key: the name of the foreign key linking this table to the non-relationship table (ie: feature_id)
+ *     - base_foreign_key: the name of the foreign key in the relationship table field linking this table to the non-relationship table (ie: feature_id)
  *     - base_key_value: the value of the base_foreign_key for the current form (ie: 999 if the feature_id=999)
  *     - base_key_value: the value of the base_foreign_key for the current form (ie: 999 if the feature_id=999)
  *     - nodetype: the non-translated singular title of this node type
  *     - nodetype: the non-translated singular title of this node type
  *   One of the following:
  *   One of the following:
@@ -126,6 +126,50 @@
  */
  */
 function chado_add_node_form_relationships(&$form, &$form_state, $details) {
 function chado_add_node_form_relationships(&$form, &$form_state, $details) {
 
 
+  // make sure the property table exists before proceeding.
+  if (!chado_table_exists($details['relationship_table'])) {
+    drupal_set_message("Cannot add relationship elements to the form. The relationship table, '" .
+      $details['relationship_table'] . "', does not exists", "error");
+    tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add relationship elements to the form.
+      The relationship table, '%name', cannot be found.", array('%name' => $details['relationship_table']));
+    return;
+  }
+  
+  // make sure the specified cv exists
+  if (isset($details['cv_name'])) {
+    // make sure the cv_name is real
+    $result = chado_select_record('cv',array('cv_id'),array('name' => $details['cv_name']));
+    if (count($result) == 0) {
+      drupal_set_message("Cannot add relationship elements to the form. The CV name, '" .
+          $details['cv_name'] . "', does not exists", "error");
+          tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add relationship elements to the form.
+        The CV named, '%name', cannot be found.", array('%name' => $details['cv_name']));
+          return;
+    }
+    // add the cv_id option to the details array
+    $details['cv_id'] = $result[0]->cv_id;
+  }
+  elseif (isset($details['cv_id'])) {
+    // make sure the cv_id is real
+    $result = chado_select_record('cv', array('name'), array('cv_id' => $details['cv_id']));
+    if (count($result) == 0) {
+      drupal_set_message("Cannot add relationship elements to the form. The CV ID, '" .
+          $details['cv_id'] . "', does not exist", "error");
+          tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add relationship elements
+        to the form. The CV ID, '%id', cannot be found.", array('%id' => $details['cv_id']));
+          return;
+    }
+    // add the cv_name option to the details array
+    $details['cv_name'] = $result[0]->name;
+  }
+  else {
+    drupal_set_message("Please provide either a 'cv_name' or 'cv_id' as an
+        option for adding relationship to the form", "error");
+    tripal_report_error('tcprops_form', TRIPAL_ERROR, "Please provide either a
+        'cv_name' or 'cv_id' as an option for adding relationship to the form", array());
+    return;
+  }
+  
   $form_state['rebuild'] = TRUE;
   $form_state['rebuild'] = TRUE;
 
 
   // Set Defaults for optional fields
   // Set Defaults for optional fields
@@ -147,17 +191,6 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
   }
   }
   else {
   else {
     if (isset($details['cv_name'])) {
     if (isset($details['cv_name'])) {
-      // make sure the cv_name is real
-      $result = chado_select_record('cv',array('cv_id'),array('name' => $details['cv_name']));
-      if (count($result) == 0) {
-        drupal_set_message("Cannot add relationship elements to the form. The CV name, '" . $details['cv_name'] . "', does not exists", "error");
-        tripal_report_error('tcrels_form', TRIPAL_ERROR, "Cannot add relationship elements to the form. The CV named, '%name',
-          cannot be found.", array('%name' => $details['cv_name']));
-        return;
-      }
-      // add the cv_id option to the details array
-      $details['cv_id'] = $result[0]->cv_id;
-      
       $type_options = array();
       $type_options = array();
       $type_options[] = 'Select a Property';
       $type_options[] = 'Select a Property';
       $sql = "
       $sql = "
@@ -176,17 +209,6 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
       }
       }
     } 
     } 
     elseif (isset($details['cv_id'])) {
     elseif (isset($details['cv_id'])) {
-      // make sure the cv_id is real
-      $result = chado_select_record('cv', array('name'), array('cv_id' => $details['cv_id']));
-      if (count($result) == 0) {
-        drupal_set_message("Cannot add relationships elements to the form. The CV ID, '" . $details['cv_id'] . "', does not exist", "error");
-        tripal_report_error('tcprops_form', TRIPAL_ERROR, "Cannot add relationship elements to the form. The CV ID, '%id',
-          cannot be found.", array('%id' => $details['cv_id']));
-        return;
-      }
-      // add the cv_name option to the details array
-      $details['cv_name'] = $result[0]->name;
-      
       $type_options = array();
       $type_options = array();
       $type_options[] = 'Select a Property';
       $type_options[] = 'Select a Property';
       $sql = "
       $sql = "
@@ -209,7 +231,7 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
   // Tell tripal administrators how to add terms to the property types drop down.
   // Tell tripal administrators how to add terms to the property types drop down.
   if (empty($type_options)) {
   if (empty($type_options)) {
     $tripal_message = tripal_set_message(
     $tripal_message = tripal_set_message(
-      t('There are currently no proeprty types! To add additional properties to the drop
+      t('There are currently no property types! To add additional properties to the drop
         down list, you need to <a href="@cvtermlink">add a controlled vocabulary term</a>
         down list, you need to <a href="@cvtermlink">add a controlled vocabulary term</a>
         to the %cv_name controlled vocabulary.',
         to the %cv_name controlled vocabulary.',
         array(
         array(
@@ -227,7 +249,7 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
         a controlled vocabulary term</a> to the %cv_name controlled vocabulary.',
         a controlled vocabulary term</a> to the %cv_name controlled vocabulary.',
         array(
         array(
           '%cv_name' => $details['cv_name'],
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/chado/tripal_cv/cv/'.$details['cv_id'].'/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/chado/tripal_cv/cv/' . $details['cv_id'] . '/cvterm/add')
         )
         )
       ),
       ),
       TRIPAL_INFO,
       TRIPAL_INFO,
@@ -294,9 +316,9 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
           base2.".$details['base_name_field']." as subject_name,
           base2.".$details['base_name_field']." as subject_name,
           cvterm.name as type_name
           cvterm.name as type_name
         FROM {".$details['relationship_table']."} rel
         FROM {".$details['relationship_table']."} rel
-        LEFT JOIN {".$details['base_table']."} base1 ON base1.".$details['base_foreign_key']." = rel.".$details['object_field_name']."
-        LEFT JOIN {".$details['base_table']."} base2 ON base2.".$details['base_foreign_key']." = rel.".$details['subject_field_name']."
-        LEFT JOIN {cvterm} cvterm ON cvterm.cvterm_id = rel.type_id
+          LEFT JOIN {".$details['base_table']."} base1 ON base1.".$details['base_foreign_key']." = rel.".$details['object_field_name']."
+          LEFT JOIN {".$details['base_table']."} base2 ON base2.".$details['base_foreign_key']." = rel.".$details['subject_field_name']."
+          LEFT JOIN {cvterm} cvterm ON cvterm.cvterm_id = rel.type_id
         WHERE rel.".$details['object_field_name']." = :base_key_value
         WHERE rel.".$details['object_field_name']." = :base_key_value
             OR rel.".$details['subject_field_name']." = :base_key_value",
             OR rel.".$details['subject_field_name']." = :base_key_value",
         array(':base_key_value' => $details['base_key_value'])
         array(':base_key_value' => $details['base_key_value'])

+ 5 - 2
tripal_core/theme/css/tripal.css

@@ -192,9 +192,12 @@ div.messages.tripal-site-admin-only{
   background-color: #cce3ff;
   background-color: #cce3ff;
   margin-top: 10px;
   margin-top: 10px;
   margin-bottom: 10px;
   margin-bottom: 10px;
+  margin-left: 0px;
+  margin-right: 0px;
   border: 1px solid #7DA1D4;
   border: 1px solid #7DA1D4;
-  min-height: 50px;
+  min-height: 65px;
   clear: both;
   clear: both;
+  padding: 0px;
 }
 }
 
 
 .tripal-serverity-string {
 .tripal-serverity-string {
@@ -210,7 +213,7 @@ div.messages.tripal-site-admin-only{
 }
 }
 
 
 .tripal-site-admin-message {
 .tripal-site-admin-message {
-   padding: 10px 10px 10px 55px;
+   padding: 15px 10px 10px 70px;
    font-style: italic;
    font-style: italic;
 }
 }
 
 

+ 3 - 2
tripal_core/tripal_core.module

@@ -639,12 +639,13 @@ function tripal_core_node_view_alter(&$build) {
 
 
           $path = $cache->data[$key]['path'] . '/' . $key . '.tpl.php';
           $path = $cache->data[$key]['path'] . '/' . $key . '.tpl.php';
 
 
-          $path = theme('tripal_admin_message', array('message' => "Administrators, you can
+          $path = tripal_set_message("Administrators, you can
             customize the way the content above is presented.  Tripal provides a template
             customize the way the content above is presented.  Tripal provides a template
             file for each block of content.  To customize, copy the template file to your
             file for each block of content.  To customize, copy the template file to your
             site's default theme, edit then " .
             site's default theme, edit then " .
             l('clear the Drupal cache', 'admin/config/development/performance', array('attributes' => array('target' => '_blank'))) . ".
             l('clear the Drupal cache', 'admin/config/development/performance', array('attributes' => array('target' => '_blank'))) . ".
-            Currently, the content above is provided by this template: <br><br>$path")
+            Currently, the content above is provided by this template: <br><br>$path",
+            TRIPAL_INFO, array('return_html' => 1)
           );
           );
         }
         }
 
 

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

@@ -145,8 +145,7 @@ function chado_example_form($node, &$form_state) {
   // from it through your node form then add this section to your own node form
   // from it through your node form then add this section to your own node form
   $details = array(
   $details = array(
     'property_table' => 'exampleprop',      // the name of the prop table
     'property_table' => 'exampleprop',      // the name of the prop table
-    'base_foreign_key' => 'example_id',     // the name of the key in your base chado table
-    'base_key_value' => $example_id,        // the value of example_id for this record
+    'chado_id' => $example_id,              // the value of example_id for this record
     'cv_name' => 'example_property_types'   // the cv.name of the cv governing exampleprop.type_id
     'cv_name' => 'example_property_types'   // the cv.name of the cv governing exampleprop.type_id
   );
   );
   // Adds the form elements to your current form
   // Adds the form elements to your current form

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

@@ -217,8 +217,7 @@ function chado_feature_form($node, &$form_state) {
   //---------------------------------------------
   //---------------------------------------------
   $details = array(
   $details = array(
     'property_table' => 'featureprop',      // the name of the prop table
     'property_table' => 'featureprop',      // the name of the prop table
-    'base_foreign_key' => 'feature_id',     // the name of the key in your base chado table
-    'base_key_value' => $feature_id,        // the value of feature_id for this record
+    'chado_id' => $feature_id,              // the value of feature_id for this record
     'cv_name' => 'feature_property'         // the cv.name of the cv governing featureprop.type_id
     'cv_name' => 'feature_property'         // the cv.name of the cv governing featureprop.type_id
   );
   );
   // Adds the form elements to your current form
   // Adds the form elements to your current form

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

@@ -138,8 +138,7 @@ function chado_featuremap_form($node, &$form_state) {
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the featuremap_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the featuremap_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $details = array(
   $details = array(
     'property_table' => 'featuremapprop',
     'property_table' => 'featuremapprop',
-    'base_foreign_key' => 'featuremap_id',
-    'base_key_value' => $featuremap_id,
+    'chado_id' => $featuremap_id,
     'cv_name' => 'featuremap_property',
     'cv_name' => 'featuremap_property',
     'fieldset_name' => 'Additional Details',
     'fieldset_name' => 'Additional Details',
     'additional_instructions' => $instructions
     'additional_instructions' => $instructions

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

@@ -184,8 +184,7 @@ function chado_library_form($node, &$form_state) {
 
 
   $details = array(
   $details = array(
     'property_table' => 'libraryprop',      // the name of the prop table
     'property_table' => 'libraryprop',      // the name of the prop table
-    'base_foreign_key' => 'library_id',     // the name of the key in your base chado table
-    'base_key_value' => $library_id,        // the value of library_id for this record
+    'chado_id' => $library_id,              // the value of library_id for this record
     'cv_name' => 'library_property',        // the cv.name of the cv governing libraryprop.type_id
     'cv_name' => 'library_property',        // the cv.name of the cv governing libraryprop.type_id
     'select_options' => $select_options
     'select_options' => $select_options
   );
   );

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

@@ -176,8 +176,7 @@ function chado_organism_form($node, $form_state) {
   //---------------------------------------------
   //---------------------------------------------
   $details = array(
   $details = array(
     'property_table' => 'organismprop',      // the name of the prop table
     'property_table' => 'organismprop',      // the name of the prop table
-    'base_foreign_key' => 'organism_id',     // the name of the key in your base chado table
-    'base_key_value' => $organism_id,        // the value of organism_id for this record
+    'chado_id' => $organism_id,              // the value of organism_id for this record
     'cv_name' => 'organism_property'         // the cv.name of the cv governing organismprop.type_id
     'cv_name' => 'organism_property'         // the cv.name of the cv governing organismprop.type_id
   );
   );
   // Adds the form elements to your current form
   // Adds the form elements to your current form

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

@@ -152,8 +152,7 @@ function chado_project_form(&$node, $form_state) {
   $instructions = t('To add properties to the drop down list, you must ' . l("add terms to the project_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $instructions = t('To add properties to the drop down list, you must ' . l("add terms to the project_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $details = array(
   $details = array(
     'property_table' => 'projectprop',
     'property_table' => 'projectprop',
-    'base_foreign_key' => 'project_id',
-    'base_key_value' => $project_id,
+    'chado_id' => $project_id,
     'cv_name' => 'project_property',
     'cv_name' => 'project_property',
     'additional_instructions' => $instructions,
     'additional_instructions' => $instructions,
     'select_options' => $select_options
     'select_options' => $select_options

+ 3 - 0
tripal_pub/api/tripal_pub.api.inc

@@ -9,6 +9,9 @@
  * @ingroup tripal_api
  * @ingroup tripal_api
  * @{
  * @{
  * Provides an application programming interface (API) to manage chado publications
  * Provides an application programming interface (API) to manage chado publications
+ * 
+ * @stephen add documentation here for how to add a new importer.
+ * 
  * @}
  * @}
  */
  */
 
 

+ 5 - 8
tripal_pub/includes/tripal_pub.chado_node.inc

@@ -250,8 +250,7 @@ function chado_pub_form($node, $form_state) {
 
 
   $details = array(
   $details = array(
     'property_table' => 'pubprop',
     'property_table' => 'pubprop',
-    'base_foreign_key' => 'pub_id',
-    'base_key_value' => $pub_id,
+    'chado_id' => $pub_id,
     'cv_name' => 'tripal_pub',
     'cv_name' => 'tripal_pub',
     'select_options' => $select_options,
     'select_options' => $select_options,
   );
   );
@@ -260,13 +259,11 @@ function chado_pub_form($node, $form_state) {
   // RELATIONSHIPS FORM
   // RELATIONSHIPS FORM
   //---------------------------------------------
   //---------------------------------------------
   // We want to use the contact_relationship_types cv if there are any terms available
   // We want to use the contact_relationship_types cv if there are any terms available
-  // and if not, to default to the relationship ontology
+  // and if not, then default to the relationship ontology
   $cv_result = chado_select_record('cv',array('cv_id'),array('name' => 'pub_relationship_types'));
   $cv_result = chado_select_record('cv',array('cv_id'),array('name' => 'pub_relationship_types'));
-  $cv_id = $cv_result[0]->cv_id;
-  $select_options = tripal_cv_get_cvterm_options($cv_id);
-  if (empty($select_options)) {
-    $cv_result = chado_select_record('cv',array('cv_id'),array('name' => 'relationship'));
+  if (count($cv_result) > 0) {
     $cv_id = $cv_result[0]->cv_id;
     $cv_id = $cv_result[0]->cv_id;
+    $cv_name = 'pub_relationship_types';
     $select_options = tripal_cv_get_cvterm_options($cv_id);
     $select_options = tripal_cv_get_cvterm_options($cv_id);
   }
   }
   // D7 @TODO: tell tripal admin's about this
   // D7 @TODO: tell tripal admin's about this
@@ -277,7 +274,7 @@ function chado_pub_form($node, $form_state) {
     'base_foreign_key' => 'pub_id',             // the name of the key in your base chado table
     'base_foreign_key' => 'pub_id',             // the name of the key in your base chado table
     'base_key_value' => $pub_id,                // the value of example_id for this record
     'base_key_value' => $pub_id,                // the value of example_id for this record
     'nodetype' => 'pub',                        // the human-readable name of your node type
     'nodetype' => 'pub',                        // the human-readable name of your node type
-    'cv_name' => 'pub_relationship_types',      // the cv.name of the cv governing example_relationship.type_id
+    'cv_name' => $cv_name,                      // the cv.name of the cv containing the properties
     'base_name_field' => 'uniquename',          // the base table field you want to be used as the name
     'base_name_field' => 'uniquename',          // the base table field you want to be used as the name
     'select_options' => $select_options
     'select_options' => $select_options
   );
   );

+ 1 - 4
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -300,15 +300,13 @@ function chado_stock_form($node, $form_state) {
   //---------------------------------------------
   //---------------------------------------------
   $details = array(
   $details = array(
     'property_table' => 'stockprop',
     'property_table' => 'stockprop',
-    'base_foreign_key' => 'stock_id',
-    'base_key_value' => $stock_id,
+    'chado_id' => $stock_id,
     'cv_id' => variable_get('chado_stock_prop_types_cv', FALSE)
     'cv_id' => variable_get('chado_stock_prop_types_cv', FALSE)
   );
   );
   chado_add_node_form_properties($form, $form_state, $details);
   chado_add_node_form_properties($form, $form_state, $details);
 
 
   // ADDITIONAL DBXREFS FORM
   // ADDITIONAL DBXREFS FORM
   //---------------------------------------------
   //---------------------------------------------
-
   $details = array(
   $details = array(
     'linking_table' => 'stock_dbxref',
     'linking_table' => 'stock_dbxref',
     'base_foreign_key' => 'stock_id',
     'base_foreign_key' => 'stock_id',
@@ -318,7 +316,6 @@ function chado_stock_form($node, $form_state) {
 
 
   // RELATIONSHIPS FORM
   // RELATIONSHIPS FORM
   //---------------------------------------------
   //---------------------------------------------
-
   $details = array(
   $details = array(
     'relationship_table' => 'stock_relationship',
     'relationship_table' => 'stock_relationship',
     'base_table' => 'stock',
     'base_table' => 'stock',