Selaa lähdekoodia

Fixed merge conflict

Stephen Ficklin 7 vuotta sitten
vanhempi
commit
b6314ce010

+ 1 - 1
tripal/tripal_views_query.inc

@@ -233,7 +233,7 @@ class tripal_views_query extends views_plugin_query {
 
         // Get the IDs
         $results = $query->execute();
-        $entity_ids = array_keys($results['TripalEntity']);
+        $entity_ids = (isset($results['TripalEntity']) AND is_array($results['TripalEntity'])) ? array_keys($results['TripalEntity']) : array();
 
         $this->pager->post_execute($view->result);
         if ($this->pager->use_count_query() || !empty($view->get_total_rows)) {

+ 29 - 2
tripal_chado/includes/TripalFields/sio__vocabulary/sio__vocabulary_widget.inc

@@ -22,7 +22,34 @@ class sio__vocabulary_widget extends ChadoFieldWidget {
     $field_table = $this->instance['settings']['chado_table'];
     $field_column = $this->instance['settings']['chado_column'];
 
-    $cv_id = 0;
+    // If the items array is empty then we are creating a new entity.
+    // Since this is set when the entity type is created, we don't want to allow
+    // content managers to change it. Thus we need to look up the value for the
+    // entity type and use it here.
+    if (empty($items)) {
+      // Use the bundle to get the cv_id choosen for this cvterm-based entity.
+      // ASSUMPTION: the cv_id is saved as the "type_value" of the bundle.
+      $bundle = tripal_load_bundle_entity(array('name' => $widget['#bundle']));
+      $cv = tripal_get_cv(array('cv_id' => $bundle->type_value));
+
+      // Now populate the items array with defaults based on the cv.
+      if ($cv) {
+        $items[$delta] = array(
+          'value' => $cv->name,
+          'chado-' . $field_table . '__cv_id' => $cv->cv_id,
+        );
+      }
+      else {
+        tripal_report_error(
+          $field_name,
+          TRIPAL_ERROR,
+          'Unable to determine default vocabulary for :name Tripal Content Type',
+          array(':name' => $bundle->label)
+        );
+        drupal_set_message(t('Unable to determine default vocabulary for :name Tripal Content Type',
+          array(':name' => $bundle->label)), 'error');
+      }
+    }
 
     $widget['value'] = array(
       '#type' => 'value',
@@ -30,7 +57,7 @@ class sio__vocabulary_widget extends ChadoFieldWidget {
     );
     $widget['chado-' . $field_table . '__cv_id'] = array(
       '#type' => 'value',
-      '#value' => $items[$delta]['chado-' . $field_table . '__cv_id'],
+      '#value' => array_key_exists($delta, $items) ? $items[$delta]['chado-' . $field_table . '__cv_id'] : '',
     );
     $widget['vocabulary_name'] = array(
       '#type' => 'item',

+ 14 - 12
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -136,13 +136,15 @@ function tripal_chado_load_ontologies() {
 /**
  * Prepares Chado for use by Tripal.
  */
-function tripal_chado_prepare_chado($job) {
+function tripal_chado_prepare_chado($job = NULL) {
 
   // Retrieve the job arguement in order to report progress.
   if (is_int($job)) {
     $job = new TripalJob();
     $job->load($job_id);
   }
+  $report_progress = TRUE;
+  if (!is_object($job)) { $report_progress = FALSE; }
 
   try {
 
@@ -176,19 +178,19 @@ function tripal_chado_prepare_chado($job) {
       tripal_chado_fix_v1_3_custom_tables();
     }
 
-    $job->setProgress(5);
+    if ($report_progress) { $job->setProgress(5); }
 
     // Import commonly used ontologies if needed.
     drush_print("Loading Ontologies...");
     tripal_chado_load_ontologies();
 
-    $job->setProgress(50);
+    if ($report_progress) { $job->setProgress(50); }
 
     // Populate the semantic web associations for Chado tables/fields.
     drush_print("Making semantic connections for Chado tables/fields...");
     tripal_chado_populate_chado_semweb_table();
 
-    $job->setProgress(60);
+    if ($report_progress) { $job->setProgress(60); }
 
     // Initialize the population of the chado_cvterm_mapping table.  This will
     // map existing data types already in Chado so that when users want to
@@ -196,7 +198,7 @@ function tripal_chado_prepare_chado($job) {
     drush_print("Map Chado Controlled vocabularies to Tripal Terms...");
     tripal_chado_map_cvterms();
 
-    $job->setProgress(70);
+    if ($report_progress) { $job->setProgress(70); }
 
     drush_print("Creating common Tripal Content Types...");
 
@@ -217,7 +219,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(74);
+    if ($report_progress) { $job->setProgress(74); }
 
     // Create the 'Analysis' entity type. This uses the local:analysis term.
     $error = '';
@@ -236,7 +238,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(78);
+    if ($report_progress) { $job->setProgress(78); }
 
     // Create the 'Project' entity type. This uses the local:project term.
     $error = '';
@@ -255,7 +257,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(82);
+    if ($report_progress) { $job->setProgress(82); }
 
     // Create the 'Map' entity type. This uses the local:project term.
     $error = '';
@@ -281,7 +283,7 @@ function tripal_chado_prepare_chado($job) {
     );
     $cvterm = tripal_get_cvterm($identifier);
     tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'featuremap', NULL);
-    $job->setProgress(86);
+    if ($report_progress) { $job->setProgress(86); }
 
     // Import a publication so we get all of the properties before
     // creating the content type.
@@ -323,7 +325,7 @@ function tripal_chado_prepare_chado($job) {
     );
     $result = chado_select_record('pub_dbxref', array('pub_id'), $values);
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
-    $job->setProgress(90);
+    if ($report_progress) { $job->setProgress(90); }
 
     // Create the 'Gene' entity type.
     $error = '';
@@ -343,7 +345,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(94);
+    if ($report_progress) { $job->setProgress(94); }
 
     // Create the 'mRNA' entity type.
     $error = '';
@@ -363,7 +365,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(98);
+    if ($report_progress) { $job->setProgress(98); }
 
     // Add the supported loaders
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));

+ 2 - 2
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -628,8 +628,8 @@ function tripal_chado_field_storage_query($query) {
     } // end if ($sort['type'] == 'field') {
   } // end foreach ($query->order as $index => $sort) {
 
-       dpm($cquery->__toString());
-       dpm($cquery->getArguments());
+//      dpm($cquery->__toString());
+//      dpm($cquery->getArguments());
 
   $records = $cquery->execute();
 

+ 13 - 5
tripal_ws/includes/TripalWebService/TripalEntityService_v0_1.inc

@@ -6,13 +6,15 @@ class TripalEntityService_v0_1 extends TripalWebService {
    * The human-readable label for this web service.
    */
   public static $label = 'Content Types';
+
   /**
    * A bit of text to describe what this service provides.
    */
-  public static $description = 'Provides acesss to the biological and ' .
-    'ancilliary data available on this site. Each content type represents ' .
-    'biological data that is defined in a controlled vocabulary (e.g. ' .
-    'Sequence Ontology term: gene (SO:0000704)).';
+  public static $description = 'Provides acesss to the biological and
+    ancilliary data available on this site. Each content type represents
+    biological data that is defined in a controlled vocabulary (e.g.
+    Sequence Ontology term: gene (SO:0000704)).';
+
   /**
    * A machine-readable type for this service. This name must be unique
    * among all Tripal web services and is used to form the URL to access
@@ -809,8 +811,14 @@ class TripalEntityService_v0_1 extends TripalWebService {
 
     $this->resource->initPager($num_records, $limit, $page);
 
+    // Check to make sure there are results.
+    $entity_ids = array();
+    if (isset($results['TripalEntity']) AND is_array($results['TripalEntity'])) {
+      $entity_ids = $results['TripalEntity'];
+    }
+
     // Iterate through the entities and add them to the output list.
-    foreach ($results['TripalEntity'] as $entity_id => $stub) {
+    foreach ($entity_ids as $entity_id => $stub) {
       // We don't need all of the attached fields for an entity so, we'll
       // not use the entity_load() function.  Instead just pull it from the
       // database table.