Browse Source

Updates to pub AGL importer and attempts to add code to let user change analysis type (not working yet)

Stephen Ficklin 11 years ago
parent
commit
f1253790c6

+ 32 - 6
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -47,7 +47,7 @@ function tripal_analysis_node_info() {
  */
 function chado_analysis_form($node, &$form_state) {
   $form = array();
-
+  
   // Default values can come in the following ways:
   //
   // 1) as elements of the $node object.  This occurs when editing an existing analysis
@@ -86,6 +86,8 @@ function chado_analysis_form($node, &$form_state) {
     $sourceuri      = $analysis->sourceuri;
     $timeexecuted   = $analysis->timeexecuted;
     $description    = $analysis->description;
+    $analysis_type  = $node->type;
+    
 
     // set the analysis_id in the form
     $form['analysis_id'] = array(
@@ -107,6 +109,7 @@ function chado_analysis_form($node, &$form_state) {
     $description    = $form_state['values']['description'];
     $d_removed      = $form_state['values']['removed'];
     $num_new        = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
+    $analysis_type  = $form_state['values']['analysis_type'];
   }
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
@@ -122,6 +125,7 @@ function chado_analysis_form($node, &$form_state) {
     $description    = $form_state['input']['description'];
     $d_removed      = $form_state['input']['removed'];
     $num_new        = $form_state['input']['num_new'] ? $form_state['input']['num_new'] : 0;
+    $analysis_type  = $form_state['input']['analysis_type'];
   }
 
   $form['title']= array(
@@ -224,11 +228,30 @@ function chado_analysis_form($node, &$form_state) {
        for collection of the source data and performing the analysis'),
   );
 
-
-  $exclude = array();
-  $include = array();
-
-
+  /*
+  // get node types from analysis extension modules
+  $sql = "SELECT modulename FROM {tripal_analysis}";
+  $modules = db_query($sql);  
+  $node_types = array();
+  $node_types['chado_analysis'] = 'Analysis';
+  foreach($modules as $module) {
+    $mtypes = call_user_func($module->modulename . "_node_info");
+    foreach ($mtypes as $mtypename => $mtype) {
+      $node_types[$mtypename] = $mtype['name'];
+    }
+  }
+  
+  if (count($node_types) > 0) {
+    $form['analysis_type'] = array(
+      '#title'         => t('Analysis Type'),
+      '#type'          => t('select'),
+      '#description'   => t("You can change this analysis type to be any other analysis type currently supported by Tripal.  Simply change this value and click 'Save'.  Then click 'Edit' again to supply additional values."),
+      '#required'      => TRUE,
+      '#default_value' => $analysis_type,
+      '#options'       => $node_types,
+    );
+  } */
+  
   // Properties Form
   // ----------------------------------
   $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") . ".");
@@ -671,6 +694,8 @@ function tripal_analysis_node_presave($node) {
     if ($name) {
       $node->title = $name;
     }
+    // reset the type 
+    //$node->type = $node->analysis_type;
   }
   else if (property_exists($node, 'analysis')) {
     $name           = $node->analysis->name;
@@ -682,5 +707,6 @@ function tripal_analysis_node_presave($node) {
     if ($name) {
       $node->title = $name;
     }
+    //$node->type = $node->analysis_type;
   }
 }

+ 3 - 9
tripal_pub/includes/importers/tripal_pub.AGL.inc

@@ -449,13 +449,7 @@ function tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $tot
   for($i = $start; $i < $start + $num_to_retrieve; $i++) {
     // retrieve the XML results
     $pub_xml = yaz_record($yazc, $i + 1, 'xml; charset=marc-8,utf-8');
-    
-    // the XML is encoded twice, one to convert UTF-8 characters to 
-    // unicode HTML entities and second with URL encoding. We must
-    // reverse the encoding
-    //$pub_xml = urldecode($pub_xml);
-    //$pub_xml = mb_convert_encoding($pub_xml, 'UTF-8', 'HTML-ENTITIES');
-    
+
     // parse the pub XML
     $pub     = tripal_pub_AGL_parse_pubxml($pub_xml);
     $pubs[]  = $pub;
@@ -906,8 +900,8 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
     $pub['Authors'] = $pub['Author List'];
   }
 
-  // for Title, Abstract, Athors, convert the html entity and remove special unicode chars that are not meant for display
-  $pub['Title'] =preg_replace( '/[\p{So}]/u', '', mb_convert_encoding($pub['Title'], 'UTF-8', 'HTML-ENTITIES'));
+  // for Title, Abstract, Authors, convert the html entity and remove special unicode chars that are not meant for display
+  $pub['Title'] = preg_replace( '/[\p{So}]/u', '', mb_convert_encoding($pub['Title'], 'UTF-8', 'HTML-ENTITIES'));
   if (key_exists('Abstract', $pub)) {
     $pub['Abstract'] =preg_replace( '/[\p{So}]/u', '',mb_convert_encoding($pub['Abstract'], 'UTF-8', 'HTML-ENTITIES'));
   }