فهرست منبع

Added journal name as a filter for the importer

spficklin 12 سال پیش
والد
کامیت
7a38b67fe7
3فایلهای تغییر یافته به همراه56 افزوده شده و 2 حذف شده
  1. 38 0
      tripal_pub/includes/importers/AGL.inc
  2. 5 2
      tripal_pub/includes/importers/PMID.inc
  3. 13 0
      tripal_pub/includes/pub_importers.inc

+ 38 - 0
tripal_pub/includes/importers/AGL.inc

@@ -3,12 +3,19 @@
  *  
  */
 function tripal_pub_remote_alter_form_AGL(&$form, $form_state) {
+  $num_criteria = $form['num_criteria']['#default_value'];
+  
   // So far we haven't been able to get AGL to filter results to only 
   // include pubs by the XX number days in the past.  So, we will
   // change the 'days' element to be the year to query
   $form['days']['#title'] = t('Year');
   $form['days']['#description']  = t('Please enter a year to limit records by the year they were published, created or modified in the database.');
   
+  // The Journal Name filter doesn't seem to work, so remove it
+  for($i = 1; $i <= $num_criteria; $i++) {
+    unset($form['criteria'][$i]["scope-$i"]['#options']['journal']);
+  }
+  
 }
 /**
  *  
@@ -161,6 +168,24 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
         $negate_abstract .= "$op ($search_terms) ";
       }
     }
+    elseif ($scope == 'journal') {
+      if ($first_journal) {
+        $journal .= "($search_terms) ";
+        $first_jounral = 0;
+      }
+      else {
+        $journal .= "$op ($search_terms) ";
+      }
+    }
+    elseif ($scope == 'negate_journal') {
+      if ($first_negate_journal) {
+        $negate_journal .= "($search_terms) ";
+        $first_negate_journal = 0;
+      }
+      else {
+        $negate_journal .= "$op ($search_terms) ";
+      }
+    }
     elseif ($scope == 'id') {
       if ($first_id) {
         $id .= "(" . preg_replace('/AGL:([^\s]*)/', '$1', $search_terms) . ") ";
@@ -201,10 +226,12 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
   // now build the CCL string in order 
   $abstract_done = 0;
   $author_done = 0;
+  $journal_done = 0;
   $title_done = 0;
   $id_done = 0;
   $any_done = 0;
   $negate_abstract_done = 0;
+  $negate_journal_done = 0;
   $negate_author_done = 0;
   $negate_title_done = 0;
   $negate_id_done = 0;
@@ -228,6 +255,15 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
       $ccl .= "not author=($negate_author) ";
       $negate_author_done = 1;
     }
+    if ($order[$i]['scope'] == 'journal' and !$journal_done) {
+      $op = $order[$i]['op'];
+      $ccl .= "$op journal=($journal) ";
+      $journal_done = 1;
+    }
+    if ($order[$i]['scope'] == 'negate_journal' and !$negate_journal_done) {
+      $ccl .= "not author=($negate_journal) ";
+      $negate_journal_done = 1;
+    }
     if ($order[$i]['scope'] == 'id' and !$id_done) {      
       $op = $order[$i]['op'];
       $ccl .= "$op id=($id) ";
@@ -289,6 +325,7 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
     "abstract" => "u=62",
     "id"       => "u=12",
     "year"     => "u=30 r=o", 
+    "journal"  => "u=1033"
   );
   yaz_ccl_conf($yazc, $fields);
     
@@ -304,6 +341,7 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
   // save the YAZ connection in the session for use by other functions
   $_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection'] = $yazc;
   
+  //dpm($search_array);
   // we want to get the list of pubs using the search terms but using a Drupal style pager
   $pubs = tripal_pager_callback('tripal_pub_AGL_range',  $num_to_retrieve, $pager_id, 
     'tripal_pub_AGL_count', $search_array);

+ 5 - 2
tripal_pub/includes/importers/PMID.inc

@@ -43,6 +43,7 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_i
   $days = $search_array['days'];
 
   $search_str = '';
+  
   for ($i = 1; $i <= $num_criteria; $i++) {
     $search_terms = trim($search_array['criteria'][$i]['search_terms']);
     $scope = $search_array['criteria'][$i]['scope'];
@@ -50,7 +51,7 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_i
     $op = $search_array['criteria'][$i]['operation'];
     
     if ($op) {
-      $search_str .= "$op";
+      $search_str .= "$op ";
     }    
     
     // if this is phrase make sure the search terms are surrounded by quotes
@@ -68,6 +69,9 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_i
     elseif ($scope == 'abstract') {
       $search_str .= $search_terms . '[Title/Abstract]';
     }
+    elseif ($scope == 'journal') {
+      $search_str .= $search_terms . '[Journal]';
+    }
     elseif ($scope == 'id') {
       $search_terms = preg_replace('/PMID:([^\s]*)/', '$1', $search_terms);
       $search_str .=  $search_terms . '[Uid]';      
@@ -86,7 +90,6 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_i
   
   $search_array['limit'] = $num_to_retrieve;
   $search_array['search_string'] = $search_str;  
-  //dpm($search_array);  
   
   unset($_SESSION['tripal_pub_PMID_query']);
   // we want to get the list of pubs using the search terms but using a Drupal style pager

+ 13 - 0
tripal_pub/includes/pub_importers.inc

@@ -296,8 +296,13 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
     'author'   => 'Author',
     'id'       => 'Accession',
     'title'    => 'Title',
+    'journal'   => 'Journal Name'
   );
 
+  $first_op_choices = array(
+    ''    => '',
+    'NOT' => 'NOT'
+  ); 
   $op_choices = array(
     'AND' => 'AND',
     'OR'  => 'OR',
@@ -346,6 +351,14 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
       '#default_value' => $is_phrase,
     );  
     
+    if ($i == 1) {
+      /*
+      $form['criteria'][$i]["operation-$i"] = array(
+        '#type'          => 'select',
+        '#options'       => $first_op_choices,
+        '#default_value' => $operation,
+      );*/
+    }
     if ($i > 1) {
       $form['criteria'][$i]["operation-$i"] = array(
         '#type'          => 'select',