فهرست منبع

Updated pub module to fix mistake in Tripal Pub ontology and other fixes

spficklin 12 سال پیش
والد
کامیت
01f50193ad
4فایلهای تغییر یافته به همراه20 افزوده شده و 26 حذف شده
  1. 2 2
      tripal_pub/api/tripal_pub.api.inc
  2. 13 19
      tripal_pub/includes/pub_form.inc
  3. 1 1
      tripal_pub/tpub.obo
  4. 4 4
      tripal_pub/tripal_pub.module

+ 2 - 2
tripal_pub/api/tripal_pub.api.inc

@@ -180,7 +180,7 @@ function tripal_pub_update_publications($do_contact = FALSE, $dbxref = NULL) {
     // if we've hit the maximum number to retrieve then do the search
     if($i == $num_to_retrieve) {      
       $search['num_criteria'] = $i - 1;
-      $pubs = tripal_pub_get_remote_search_results($remote_db, $search, $i, 0);
+      $pubs = tripal_pub_get_remote_search_results($remote_db, $search, $i, 0);      
       tripal_pub_add_publications($pubs, $do_contact, TRUE);
       $search['criteria'] = array();
       $i = 0;
@@ -487,7 +487,7 @@ function tripal_pub_get_pubs_by_title_type_pyear($title, $type, $pyear = '') {
 function tripal_pub_add_publication($pub_details, $do_contact = FALSE, $update = FALSE) {
   
   $pub_id = 0;
-
+  
   // first try to find the publication using the accession number. It will have
   // one if the pub has already been loaded for the publication database
   if ($pub_details['Publication Dbxref']) {

+ 13 - 19
tripal_pub/includes/pub_form.inc

@@ -34,10 +34,7 @@ function chado_pub_form($node, $form_state) {
   // on AHAH callbacks we want to keep a list of all the properties that have been removed 
   // we'll store this info in a hidden field and retrieve it here
   $d_removed = $form_state['values']['removed']; 
-  
-  // get the defaults first from the database and then from the form_state
-  $default_type = $pub->type_id->cvterm_id;
-  
+    
   // get the number of new fields that have been aded via AHAH callbacks
   $num_new = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
 
@@ -102,6 +99,7 @@ function chado_pub_form($node, $form_state) {
     '#default_value' => $d_title,
     '#required' => TRUE,
   );
+  
   $form['type_id'] = array(
     '#type' => 'select',
     '#title' => t('Publication Type'),
@@ -110,21 +108,13 @@ function chado_pub_form($node, $form_state) {
     '#default_value' => $d_type_id,
   );
     
-  $form['series_name'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Series Name (e.g. Journal Name)'),
-    '#description' => t('Full name of (journal) series.'),
-    '#default_value' => $d_series_name,
-    '#required' => TRUE,
-  );
   $form['pyear'] = array(
     '#type' => 'textfield',
     '#title' => t('Publication Year'),
     '#default_value' => $d_pyear,
     '#required' => TRUE,
     '#size' => 5,
-  );
-  
+  );  
   $form['uniquename'] = array(
     '#type' => 'textarea',
     '#title' => t('Citation'),
@@ -140,7 +130,7 @@ function chado_pub_form($node, $form_state) {
   
   // add in the properties that are actually stored in the pub table fields.
   $num_properties = chado_pub_node_form_add_pub_table_props($form, $form_state, $properties_list, 
-    $d_properties, $d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages);
+    $d_properties, $d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name);
   
   // add in the properties from the pubprop table   
   $num_properties += chado_pub_node_form_add_pubprop_table_props($form, $form_state, $pub_id, $d_properties, $d_removed);
@@ -443,7 +433,7 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
     // skip properties that are found in the pub table
     if($prop->name == "Volume" or $prop->name == "Volume Title" or 
        $prop->name == "Issue"  or $prop->name == "Pages" or
-       $prop->name == "Citation") {
+       $prop->name == "Citation" or $prop->name == "Journal Name") {
          continue;
     }
     
@@ -503,7 +493,7 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
  * 
  */
 function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $properties_list,
-    &$d_properties, &$d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages) {
+    &$d_properties, &$d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name) {
       
   $num_properties = 0;
   $rank = 0;
@@ -521,12 +511,13 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
       continue;
     }
         
-    // if any of the properties match the fields in the pub table then we want to include those 
-    // automatically
+    // if any of the properties match the fields in the pub table then we 
+    // want to include those automatically
     if (($prop->name == 'Volume' and $d_volume) or         
         ($prop->name == 'Issue' and $d_issue) or 
         ($prop->name == 'Pages' and $d_pages) or
-        ($prop->name == 'Volume Title' and $d_volumetitle)) {
+        ($prop->name == 'Volume Title' and $d_volumetitle) or
+        ($prop->name == 'Journal Name' and $d_series_name)) {
           
       $d_properties[$type_id][$rank]['name']  = $prop->name;           
       $d_properties[$type_id][$rank]['id']    = $type_id;            
@@ -545,6 +536,9 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
       if ($prop->name == 'Volume Title') {
         $d_properties[$type_id][$rank]['value'] = $d_volumetitle;
       }
+      if ($prop->name == 'Journal Name') {
+        $d_properties[$type_id][$rank]['value'] = $d_series_name;
+      }
       
       // determine how many rows we need in the textarea
       $rows = 1;

+ 1 - 1
tripal_pub/tpub.obo

@@ -83,7 +83,7 @@ is_a: TPUB:0000015 ! Publication Type
 [Term]
 id: TPUB:0000015
 name: Publication Type
-relationship: part_of TPUB:0000002 ! Publication
+relationship: part_of TPUB:0000037 ! Publication Details
 
 [Term]
 id: TPUB:0000016

+ 4 - 4
tripal_pub/tripal_pub.module

@@ -592,14 +592,14 @@ function chado_pub_update($node) {
   
   // now add in the properties by first removing any the publication
   // already has and adding the ones we have
-  tripal_core_chado_delete('pubprop', array('pub_id' => $pub_id));
+  tripal_core_chado_delete('pubprop', array('pub_id' => $pub_id));  
   foreach ($properties as $property => $elements) {
     foreach ($elements as $rank => $value) {      
       $status = tripal_pub_insert_property($pub_id, $property, $value, FALSE);
       if (!$status) {
-        drupal_set_message("Error cannot add property: $property", "error");
-        watchdog('tripal_pub', "Error cannot add property: %prop", 
-          array('%property' => $property), WATCHDOG_ERROR);
+        drupal_set_message("Error cannot add property: '$property'", "error");
+        watchdog('tripal_pub', "Error cannot add property: '%prop'", 
+          array('%prop' => $property), WATCHDOG_ERROR);
       }
     } 
   }