Browse Source

Continued development on pub module

spficklin 12 years ago
parent
commit
20c460c818

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

@@ -0,0 +1,199 @@
+<?php
+/**
+ * @file
+ * The Tripal Pub API
+ * 
+ * @defgroup tripal_pub_api Publication Module API
+ * @ingroup tripal_api 
+ */
+ 
+/*  
+ * Retrieves a list of publications as an associated array where
+ *  keys correspond directly with Tripal Pub CV terms.
+ *  
+ * @param remote_db
+ *    The name of the remote publication database to query. Valid values
+ *    include: 'pubmed'.
+ * @param search_array
+ *    An associate array containing the search criteria. The following key 
+ *    are expected
+ *      'num_criteria':  Specifies the number of criteria present in the search array
+ *      'days':          The number of days to include in the search starting from today
+ *      'criteria':      An associate array containing the search critiera. There should
+ *                       be no less than 'num_criteria' elements in this array.
+ *                       
+ *    The following keys are expected in the 'criteria' array
+ *      'search_terms':  A list of terms to search on, separated by spaces.
+ *      'scope':         The fields to search in the remote database. Valid values
+ *                       include: 'title', 'abstract', 'author' and 'any'
+ *      'operation':     The logical operation to use for this criteria. Valid
+ *                       values include: 'AND', 'OR' and 'NOT'.
+ * @param $num_to_retrieve
+ *    The number of records to retrieve.  In cases with large numbers of 
+ *    records to retrieve, the remote database may limit the size of each
+ *    retrieval.  
+ * @param $pager_id
+ *    Optional.  This function uses the 'tripal_pager_callback' function
+ *    to page a set of results.  This is helpful when generating results to
+ *    be view online.  The pager works identical to the pager_query function
+ *    of drupal. Simply provide a unique integer value for this argument.  Each
+ *    form on a single page should have a unique $pager_id.
+ * @param $page
+ *    Optional.  If this function is called on the command-line where the 
+ *    page for the pager cannot be set using the $_GET variable, use this
+ *    argument to specify the page to retrieve. 
+ *    
+ * @return
+ *   Returns an array of pubs where each element is
+ *   an associative array where the keys are Tripal Pub CV terms.  
+ * 
+ * @ingroup tripal_pub_api
+ */
+function tripal_pub_get_remote_search_results($remote_db, $search_array, 
+  $num_to_retrieve, $pager_id = 0, $page = 0) {
+   
+  // construct the callback function using the remote database name
+  $callback = 'tripal_pub_remote_search_' . strtolower($remote_db);
+
+  // manually set the $_GET['page'] parameter to trick the pager
+  // into giving us the requested page
+  if (is_numeric($page) and $page > 0) {
+    $_GET['page'] = $page;
+  }  
+  
+  // now call the callback function to get the rsults
+  $pubs = array();
+  if (function_exists($callback)) {
+    $pubs = call_user_func($callback, $search_array, $num_to_retrieve, $pager_id);
+  }    
+  
+  return $pubs;  
+}
+/*
+ * @ingroup tripal_pub_api
+ */
+function tripal_pub_import_publications() {
+  $num_to_retrieve = 10;
+  $pager_id = 0;
+  $page = 1;
+  $num_pubs = 0;
+  
+  // get all of the loaders
+  $sql = "SELECT * FROM {tripal_pub_import} WHERE disabled = 0";
+  $results = db_query($sql);
+  while ($import = db_fetch_object($results)) {
+     $criteria = unserialize($import->criteria); 
+     $remote_db = $criteria['remote_db'];
+     print_r($search_array);
+     do {       
+       // retrieve the pubs for this page
+       $pubs = tripal_pub_get_remote_search_results($remote_db, $criteria, $num_to_retrieve, $pager_id, $page);
+       // now add the publications
+       foreach ($pubs as $pub) {
+               
+         $p = tripal_pub_add_publication($pub);
+         $pub_id = $p->pub_id;                    
+         
+         // check to see if the pub_dbxref record already exist
+         $values = array(
+           'dbxref_id' => array(
+             'accession' => $pub['pub_accession'],
+             'db_id' => array(
+                'name' => $pub['pub_database'],
+             ),
+           ), 
+           'pub_id' => $pub_id,
+         );
+         $options = array('statement_name' => 'sel_pubdbxref_db');
+         $results = tripal_core_chado_select('pub_dbxref', array('*'), $values, $options);
+         
+         // if the pub_dbxref record doesn't exist then we need to add the associate
+         if(count($results) == 0) {
+           
+           // make sure our database already exists
+           $db = tripal_db_add_db($pub['pub_database']);
+           
+           // get the database cross-reference
+           $values = array(
+             'accession' => $pub['pub_accession'],
+             'db_id' => $db->db_id,
+           );
+           $options = array('statement_name' => 'sel_dbxref_acdb');
+           $results = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
+           // if the accession doesn't exist then add it
+           if(count($results) == 0){
+             $dbxref = tripal_db_add_dbxref($db->db_id, $pub['pub_accession']);          
+           }
+           else {
+             $dbxref = $results[0];
+           }
+           
+         }
+         else {
+           $pub_dbxref = $results[0];
+         }
+         
+
+         print $num_pubs . ".  " . $pub['pub_database'] . ' ' . $pub['pub_accession'] . "\n";                 
+         $num_pubs++;
+       }       
+       $page++;
+     } 
+     while (count($pubs) > 0);    
+  }
+}
+/*
+ * 
+ */
+function tripal_pub_add_publication($pub_details) {
+  
+   // check to see if the publication already exists
+   $pub_id = 0;
+   $values = array(
+     'title' => $pub['title'],
+     'pyear' => $pub['pyear'],
+   );
+   $options = array('statement_name' => 'pub_tipy');
+   $results = tripal_core_chado_select('pub', array('*'), $values, $options);
+   
+   // if the publication exists then return the record
+   if(count($results) == 1) {
+      return $results[0];   
+   }
+   if(count($results) > 1) {
+     watchdog('tripal_pub', "The publication with the same title is present multiple times. Cannot ".
+       "determine which to use.  Title: %title", array('%title' => $pub_details['title']), WATCHDOG_ERROR);     
+     return FALSE;          
+   }
+  
+   // if the publication does not exist then create it.      
+   $values = array(
+    'title' => $pub_details['title'],
+    'volume' => $pub_details['volume'],
+    'series_name' => $pub_details['journal_name'],
+    'issue' => $pub_details['issue'],
+    'pyear' => $pub_details['year'],
+    'pages' => $pub_details['pages'],
+    'uniquename' => $pub_details['citation'],
+    'type_id' => array(
+      'name' => 'XXXX',
+      'cv_id' => array(
+        'name' => 'tripal_pub',
+      ),
+    ),     
+  );  
+  $options = array('statment_name' => 'ins_pub_tivoseispypaunty');
+  $pub = tripal_core_chado_insert('pub', $values, $options);
+  if ($pub) {
+    watchdog('tripal_pub', "Cannot insert the publication with title: %title", array('%title' => $pub_details['title']), WATCHDOG_ERROR);
+    return FALSE;   
+  }
+ 
+  
+  // now add in any other items that remain as properties of the publication
+  foreach ($pub_details as $key => $value) {
+    
+  }
+  
+  return $pub;
+}

+ 1 - 1
tripal_pub/includes/pubmed.inc

@@ -15,7 +15,7 @@ function tripal_pub_remote_search_pubmed($search_array, $num_to_retrieve, $pager
   // convert the terms list provicded by the caller into a string with words
   // separated by a '+' symbol.
   $num_criteria = $search_array['num_criteria'];
-  $days = $search_array['num_criteria'];
+  $days = $search_array['days'];
 
   $search_str = '';
   for ($i = 0; $i <= $num_criteria; $i++) {

+ 73 - 59
tripal_pub/includes/remote_search.inc

@@ -11,6 +11,7 @@ function tripal_pub_remote_search_page() {
   
   // generate the search form 
   $form = drupal_get_form('tripal_pub_remote_search_form');
+  $output = $form;
 
   // retrieve any results
   $remote_db = $_SESSION['tripal_pub_search']['remote_db'];
@@ -26,34 +27,35 @@ function tripal_pub_remote_search_page() {
     $search_array['criteria'][$i]['scope'] = $_SESSION['tripal_pub_search']['criteria'][$i]['scope'];  
     $search_array['criteria'][$i]['operation'] = $_SESSION['tripal_pub_search']['criteria'][$i]['operation'];
   }
+  
     
-  // get the list of publications from the remote database using the search criteria.
-  $pubs = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $pager_id);
-
-  // generate the pager
-  $total_pages = $pager_total[$pager_id];
-  $total_items = $pager_total_items[$pager_id];
-  $page = isset($_GET['page']) ? $_GET['page'] : '0';
-  $pager = theme('pager');
+  if ($_SESSION['tripal_pub_search']['perform_search']) {
+    // get the list of publications from the remote database using the search criteria.  
+    $pubs = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $pager_id);
   
-  // iterate through the results and construct the table displaying the publications
-  $rows = array();
-  $i = $page * $limit + 1;
-  if (count($pubs) > 0) {
-    foreach ($pubs as $pub) {
-      $rows[] = array(number_format($i), $pub['citation']);
-      $i++;
+    // generate the pager
+    $total_pages = $pager_total[$pager_id];
+    $total_items = $pager_total_items[$pager_id];
+    $page = isset($_GET['page']) ? $_GET['page'] : '0';
+    $pager = theme('pager');
+    
+    // iterate through the results and construct the table displaying the publications
+    $rows = array();
+    $i = $page * $limit + 1;
+    if (count($pubs) > 0) {
+      foreach ($pubs as $pub) {
+        $rows[] = array(number_format($i), $pub['citation']);
+        $i++;
+      }
     }
-  }
-  $headers = array('', 'Citation');
-  $table = theme('table', $headers, $rows);
-  
-  
-  // join all to form the final page
-  $output =  $form . "<p><b>Found " . number_format($total_items) .  
-    ". Page " . ($page + 1) . " of $total_pages. " .
-    " Results</b></br>" . $table . '</p>' . $pager;    
+    $headers = array('', 'Citation');
+    $table = theme('table', $headers, $rows);   
   
+    // join all to form the results
+    $output .= "<br><p><b>Found " . number_format($total_items) .  
+      ". Page " . ($page + 1) . " of $total_pages. " .
+      " Results</b></br>" . $table . '</p>' . $pager;    
+  }
   return $output;
 }
 /*
@@ -70,11 +72,19 @@ function theme_tripal_pub_remote_search_form($form) {
         array('data' => drupal_render($element["add-$i"]) . drupal_render($element["remove-$i"]), 'width' => '5%'),
       );
     }
-  }
+  } 
   $headers = array('Operation','Scope', 'Search Terms', '');
+  
+  $markup  = '<div id="pub-search-form-row1">';
+  $markup .= '  <div id="pub-search-form-col1">' . drupal_render($form['loader_name']) . '</div>';
+  $markup .= '  <div id="pub-search-form-col2">' . drupal_render($form['remote_db']) . '</div>';
+  $markup .= '  <div id="pub-search-form-col3">' . drupal_render($form['days']) . '</div>';
+  $markup .= '</div>';
+  $markup .= theme('table', $headers, $rows);
+  
   $form['criteria'] = array(
     '#type' => 'markup',
-    '#value' =>  theme('table', $headers, $rows),
+    '#value' =>  $markup,
     '#weight' => -10,
   );
   return drupal_render($form);
@@ -91,7 +101,7 @@ function tripal_pub_remote_search_form(&$form_state = NULL) {
   $remote_db = $form_state['values']['remote_db'] ? $form_state['values']['remote_db'] : $_SESSION['tripal_pub_search']['remote_db'];
   $days = $form_state['values']['days'] ? $form_state['values']['days'] : $_SESSION['tripal_pub_search']['days']; 
   $num_criteria = $form_state['values']['num_criteria'] ? $form_state['values']['num_criteria'] : $_SESSION['tripal_pub_search']['num_criteria'];
-  $loader_name = $form_state['values']['loader_name'];
+  $loader_name = $form_state['values']['loader_name'] ? $form_state['values']['loader_name'] : $_SESSION['tripal_pub_search']['loader_name'];
   
   // change the number of criteria based on form_state post data.
   if (!$num_criteria) {
@@ -109,11 +119,12 @@ function tripal_pub_remote_search_form(&$form_state = NULL) {
     '#title'         => t('Loader Name'),
     '#description'   => t('Please provide a name for this loader setup..'),
     '#default_value' => $loader_name,
+    '#required'      => TRUE,
   );
    
   $remote_dbs = array('Pubmed' => 'Pubmed');
   $form['remote_db'] = array(
-    '#title' => t('Remote Publication Database'),
+    '#title' => t('Remote Database'),
     '#type' => 'select',
     '#options' => $remote_dbs,
     '#default_value' => $remote_db,
@@ -124,6 +135,14 @@ function tripal_pub_remote_search_form(&$form_state = NULL) {
     '#default_value' => $num_criteria,
   );
   
+  $form['days'] = array(
+    '#type'          => 'textfield',
+    '#title'         => t('Days'),
+    '#description'   => t('The number of days <br>from today to search.'),
+    '#default_value' => $days,
+    '#size'          => 5,
+  );
+  
   for($i = 0; $i <= $num_criteria; $i++) {
     $search_terms = $form_state['values']["search_terms-$i"] ? $form_state['values']["search_terms-$i"] : $_SESSION['tripal_pub_search']['criteria'][$i]['search_terms'];
     $scope = $form_state['values']["scope-$i"] ? $form_state['values']["scope-$i"] : $_SESSION['tripal_pub_search']['criteria'][$i]['scope'];
@@ -138,6 +157,7 @@ function tripal_pub_remote_search_form(&$form_state = NULL) {
       '#type'          => 'textfield',
       '#description'   => t('Please provide a list of words, separated by spaces for searching.'),
       '#default_value' => $search_terms,
+      '#required'      => TRUE,
     );
     $form['criteria'][$i]["scope-$i"] = array(
       '#type'          => 'select',
@@ -189,20 +209,12 @@ function tripal_pub_remote_search_form(&$form_state = NULL) {
       );
     }
   }
-
-  
-  $form['days'] = array(
-    '#type'          => 'textfield',
-    '#title'         => t('Number of Days'),
-    '#description'   => t('Please provide the number of days to limit your search.  For example, to search only the last 60 days, enter the number 60 in the field.'),
-    '#default_value' => $days,
-  );
   
-  $form['submit'] = array(
+  $form['test'] = array(
     '#type'         => 'submit',
     '#value'        => t('Test Criteria'),
   );
-  $form['submit'] = array(
+  $form['save'] = array(
     '#type'         => 'submit',
     '#value'        => t('Save Criteria'),
   );
@@ -217,6 +229,7 @@ function tripal_pub_remote_search_form_validate($form, &$form_state) {
   $num_criteria = $form_state['values']['num_criteria'];
   $remote_db =  $form_state['values']["remote_db"];
   $days =  trim($form_state['values']["days"]);
+  $loader_name =  trim($form_state['values']["loader_name"]);
 
   for ($i = 0; $i <= $num_criteria; $i++) {            
     $search_terms =  trim($form_state['values']["search_terms-$i"]);
@@ -226,9 +239,6 @@ function tripal_pub_remote_search_form_validate($form, &$form_state) {
     if ($days and !is_numeric($days) or preg_match('/\./', $days)) {
       form_set_error("days-$i", "Please enter a numeric, non decimal value, for the number of days.");
     }
-    if (!$search_terms) {
-      form_set_error("search_terms-$i", "Please enter a value for searching.");
-    }
   }
 }
 
@@ -236,14 +246,17 @@ function tripal_pub_remote_search_form_validate($form, &$form_state) {
  *
  */
 function tripal_pub_remote_search_form_submit($form, &$form_state) {
- 
+   
   $num_criteria = $form_state['values']['num_criteria'];
   $remote_db =  $form_state['values']["remote_db"];
   $days =  trim($form_state['values']["days"]);
+  $loader_name =  trim($form_state['values']["loader_name"]);
     
   $_SESSION['tripal_pub_search']['remote_db'] = $remote_db;
   $_SESSION['tripal_pub_search']['days'] = $days;
   $_SESSION['tripal_pub_search']['num_criteria'] = $num_criteria;
+  $_SESSION['tripal_pub_search']['loader_name'] = $loader_name;
+  unset($_SESSION['tripal_pub_search']['criteria']);
   for ($i = 0; $i <= $num_criteria; $i++) {
     $search_terms =  trim($form_state['values']["search_terms-$i"]);
     $scope =  $form_state['values']["scope-$i"];
@@ -254,23 +267,24 @@ function tripal_pub_remote_search_form_submit($form, &$form_state) {
       'scope' => $scope,
       'operation' => $operation
     );
-  } 
-}
-/*
- * 
- */
-function tripal_pub_get_remote_search_results($remote_db, $search_array, $num_to_retrieve, $pager_id) {
-   
-  // construct the callback function using the remote database name
-  $callback = 'tripal_pub_remote_search_' . strtolower($remote_db);
-   
-  // now call the callback function to get the rsults
-  $pubs = array();
-  if (function_exists($callback)) {
-    $pubs = call_user_func($callback, $search_array, $num_to_retrieve, $pager_id);
-  }    
-  
-  return $pubs;  
+  }   
+
+  if ($form_state['values']['op'] == 'Test Criteria') {
+    $_SESSION['tripal_pub_search']['perform_search'] = 1;
+  }
+  if ($form_state['values']['op'] == 'Save Criteria') {
+    unset($_SESSION['tripal_pub_search']['perform_search']);
+    $record = array(
+      'name' => $loader_name,
+      'criteria' => serialize($_SESSION['tripal_pub_search']),
+    );
+    if(drupal_write_record('tripal_pub_import', $record)){
+      drupal_set_message('Publication import settings saved');
+    }
+    else {
+      drupal_set_message('Could not save publication import settings', 'error');
+    }
+  }  
 }
 
 /*

+ 436 - 0
tripal_pub/tpub.obo

@@ -0,0 +1,436 @@
+format-version: 1.2
+date: 22:03:2013 17:53
+saved-by: ficklin
+auto-generated-by: OBO-Edit 2.1-beta18
+default-namespace: tripal_pub
+
+[Term]
+id: TPUB:0000001
+name: publication_dbxref
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000002
+name: publication
+
+[Term]
+id: TPUB:0000003
+name: citation
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000004
+name: book
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000005
+name: pub_accession
+relationship: part_of TPUB:0000001 ! publication_dbxref
+
+[Term]
+id: TPUB:0000006
+name: collective
+comment: Used when an author is a collective of individuals rather than a person.
+is_a: TPUB:0000015 ! publication_type
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000007
+name: masters_thesis
+relationship: part_of TPUB:0000006 ! collective
+
+[Term]
+id: TPUB:0000008
+name: PhD_thesis
+comment: PhD thesis or dissertation.
+relationship: part_of TPUB:0000006 ! collective
+
+[Term]
+id: TPUB:0000009
+name: pub_database
+relationship: part_of TPUB:0000001 ! publication_dbxref
+
+[Term]
+id: TPUB:0000010
+name: received_date
+is_a: TPUB:0000046 ! publication_date
+
+[Term]
+id: TPUB:0000011
+name: conference_name
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000012
+name: book_chapter
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000013
+name: unknown_type
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000014
+name: web_page
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000015
+name: publication_type
+relationship: part_of TPUB:0000002 ! publication
+
+[Term]
+id: TPUB:0000016
+name: author
+relationship: part_of TPUB:0000002 ! publication
+
+[Term]
+id: TPUB:0000017
+name: first_initials
+comment: The first initials for the author including the initial for the first name and any middle names (not the initial for the last name).
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000018
+name: surname
+synonym: "family_name" EXACT []
+synonym: "last_name" EXACT []
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000019
+name: given_name
+synonym: "first_name" EXACT []
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000020
+name: middle_names
+comment: One or more middle names for this person.
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000021
+name: middle_initials
+comment: The middle initials for this person excluding the initial for the given name and the surname.
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000022
+name: affiliation
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000023
+name: department
+comment: The department of an institution or organization.
+relationship: part_of TPUB:0000022 ! affiliation
+
+[Term]
+id: TPUB:0000024
+name: institution
+relationship: part_of TPUB:0000022 ! affiliation
+
+[Term]
+id: TPUB:0000025
+name: organization
+comment: A generic term for any organization.
+relationship: part_of TPUB:0000022 ! affiliation
+
+[Term]
+id: TPUB:0000026
+name: address
+relationship: part_of TPUB:0000016 ! author
+
+[Term]
+id: TPUB:0000027
+name: address_line1
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000028
+name: address_line2
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000029
+name: address_line3
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000030
+name: city
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000031
+name: state
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000032
+name: province
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000033
+name: country
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000034
+name: postal_code
+relationship: part_of TPUB:0000026 ! address
+
+[Term]
+id: TPUB:0000035
+name: epub_date
+is_a: TPUB:0000046 ! publication_date
+
+[Term]
+id: TPUB:0000036
+name: accepted_date
+is_a: TPUB:0000046 ! publication_date
+
+[Term]
+id: TPUB:0000037
+name: publication_details
+relationship: part_of TPUB:0000002 ! publication
+
+[Term]
+id: TPUB:0000038
+name: journal_ISO_abbreviation
+relationship: part_of TPUB:0000037 ! publication_details
+created_by: stephen
+creation_date: 2013-03-20T07:02:18Z
+
+[Term]
+id: TPUB:0000039
+name: title
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000040
+name: journal
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000041
+name: patent
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000042
+name: volume
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000043
+name: issue
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000044
+name: pages
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000045
+name: start_page
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000046
+name: publication_date
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000047
+name: authors
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000048
+name: ISSN
+comment: International Standard Serial Number (ISSN) is an eight-character value that uniquely identifies a periodicals in print or other media. There are two sub categories of ISSN: print, p-ISSN and electronic e-ISSN.
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000049
+name: DOI
+comment: Digital Object Identifier.
+is_a: TPUB:0000080 ! elocation
+
+[Term]
+id: TPUB:0000050
+name: abstract
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000051
+name: comments
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000052
+name: URL
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000053
+name: file_attachment
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000059
+name: year
+relationship: part_of TPUB:0000046 ! publication_date
+
+[Term]
+id: TPUB:0000064
+name: language
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000065
+name: keywords
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000066
+name: original_title
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000067
+name: alias
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000068
+name: journal_code
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000069
+name: pISSN
+is_a: TPUB:0000048 ! ISSN
+
+[Term]
+id: TPUB:0000070
+name: conference_proceedings
+comment: A generic term for any article, talk, workshop or poster that is part of a conference proceedings.
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000071
+name: journal_article
+is_a: TPUB:0000015 ! publication_type
+
+[Term]
+id: TPUB:0000072
+name: eISSN
+is_a: TPUB:0000048 ! ISSN
+
+[Term]
+id: TPUB:0000073
+name: proceedings_talk
+is_a: TPUB:0000070 ! conference_proceedings
+
+[Term]
+id: TPUB:0000074
+name: proceedings_article
+is_a: TPUB:0000070 ! conference_proceedings
+
+[Term]
+id: TPUB:0000075
+name: journal_name
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000076
+name: proceedings_poster
+is_a: TPUB:0000070 ! conference_proceedings
+
+[Term]
+id: TPUB:0000077
+name: conference_year
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000078
+name: proceedings_computer_demo
+is_a: TPUB:0000070 ! conference_proceedings
+
+[Term]
+id: TPUB:0000079
+name: vernacular_title
+comment: The title of a publication in its original foreign language.
+relationship: part_of TPUB:0000037 ! publication_details
+creation_date: 2013-03-22T05:35:02Z
+
+[Term]
+id: TPUB:0000080
+name: elocation
+comment: Provides an electronic location for the items. This includes Digital Object Identifiers (DOI) or Publisher Item Identifiers (PII).
+relationship: part_of TPUB:0000037 ! publication_details
+creation_date: 2013-03-22T05:36:24Z
+
+[Term]
+id: TPUB:0000081
+name: publication_model
+comment: This term is used to identify the medium/media in which the item is published. There are four possible values which are the same as used by: print, print-electronic, electronic,  electronic-print.  Further explanation:  "print", the journal is published in print format only; "print-electronic",  the journal is published in both print and electronic format; "electronic", the journal is published in electronic format only; "electronic-print", the journal is published first in electronic format followed by print.
+relationship: part_of TPUB:0000037 ! publication_details
+creation_date: 2013-03-22T02:37:00Z
+
+[Term]
+id: TPUB:0000082
+name: PII
+comment: Publisher Item Identifier.
+is_a: TPUB:0000081 ! publication_model
+
+[Term]
+id: TPUB:0000083
+name: structured_abstract_part
+comment: A subset of an abstract.  For example, abstracts that have section headers such as 'Purpose', 'Results', etc., each of these sections would be an individual part of a structured abstract.
+relationship: part_of TPUB:0000050 ! abstract
+
+[Term]
+id: TPUB:0000084
+name: copyright
+comment: Information regarding the copyright of the publication.
+relationship: part_of TPUB:0000037 ! publication_details
+
+[Term]
+id: TPUB:0000085
+name: suffix
+comment: Name suffix such as 2nd, 3rd, Jr, Sr., etc.
+relationship: part_of TPUB:0000016 ! author
+creation_date: 2013-03-22T04:10:15Z
+
+[Term]
+id: TPUB:0000087
+name: language_abbr
+comment: An abbreviation for a language (e.g. 3 letters)
+is_a: TPUB:0000064 ! language
+
+[Term]
+id: TPUB:0000100
+name: journal_country
+comment: The country where the journal was published.
+relationship: part_of TPUB:0000037 ! publication_details
+created_by: ficklin
+creation_date: 2013-03-22T05:52:57Z
+
+[Typedef]
+id: is_a
+name: is_a
+is_transitive: true
+
+[Typedef]
+id: part_of
+name: part_of
+is_transitive: true
+

+ 45 - 0
tripal_pub/tripal_pub.drush.inc

@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @file
+ * Contains function relating to drush-integration of this module.
+ */
+
+/**
+ * Describes each drush command implemented by the module
+ *
+ * @return
+ *   The first line of description when executing the help for a given command
+ */
+function tripal_pub_drush_help($command) {
+  switch ($command) {
+    case 'drush:tripal-pub-import':
+      return dt('Imports publications from remote databases using saved configuration settings.');
+  }
+}
+
+/**
+ * Registers a drush command and constructs the full help for that command
+ *
+ * @return
+ *   And array of command descriptions
+ */
+function tripal_pub_drush_command() {
+  $items = array();
+  $items['tripal-pub-import'] = array(
+    'description' => dt('Imports publications from remote databases using saved configuration settings.'),
+    'examples' => array(
+      'Standard example' => 'drush tripal-pub-import',
+    ),
+    'aliases' => array('trp-pubs'),
+  );
+  return $items;
+}
+
+/**
+ * Imports publications into Chado
+ *
+ */
+function drush_tripal_pub_import() {
+  tripal_pub_import_publications();
+}

+ 13 - 14
tripal_pub/tripal_pub.install

@@ -68,20 +68,19 @@ function tripal_pub_schema() {
     ),
     'primary key' => array('nid'),
   );
-      /*
-       //a intfield, not null and project_id is the unique_id of the project in chado
-       'pubmed_id' => array(
-          'type' => 'int',
-          'unsigned' => TRUE,
-          'not null' => FALSE,
-      ),
-      'author' => array(
-        'type' => 'text',
-        'size' => 'normal',
-        'not null' => TRUE,
-        'default' => '',
-        'description' => 'The Author Name.',
-      ),*/
+  $schema['tripal_pub_import'] = array(
+    'fields' => array(
+      'pub_import_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+      'criteria' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'Contains a serialized PHP array containing the search criteria'),
+      'disabled'  => array('type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0),      
+    ),
+    'primary key' => array('pub_import_id'),
+    'indexes' => array(
+      'name' => array('name')
+    ),
+  );
+       
   return $schema;
 }
 

+ 2 - 1
tripal_pub/tripal_pub.module

@@ -1,6 +1,6 @@
 <?php
 
-//require_once('cron.php');
+require_once "api/tripal_pub.api.inc";
 require_once "includes/tripal_pub.admin.inc";
 require_once "includes/pubmed.inc";
 require_once "includes/remote_search.inc";
@@ -21,6 +21,7 @@ require_once "includes/remote_search.inc";
  */
 function tripal_pub_init() {
   drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_pub.js');
+  drupal_add_css(drupal_get_path('theme', 'tripal') . '/css/tripal_pub.css');
 }