Browse Source

Fixed some bugs still related to table changes

Stephen Ficklin 9 years ago
parent
commit
ab1e0eebde

+ 6 - 4
tripal_chado/includes/tripal_chado.entity.inc

@@ -38,10 +38,12 @@ function tripal_chado_entity_presave($entity, $type) {
  */
 function tripal_chado_entity_postsave($entity, $type) {
 
-  // Set the title for this entity.
-  // This needs to be done post save because it uses the saved data and a format.
-  $ec = new TripalEntityController($entity->type);
-  $ec->setTitle($entity);
+  if ($type == 'TripalEntity') {
+    // Set the title for this entity.
+    // This needs to be done post save because it uses the saved data and a format.
+    $ec = new TripalEntityController($entity->type);
+    $ec->setTitle($entity);
+  }
 
 }
 

+ 1 - 0
tripal_chado/tripal_chado.module

@@ -607,6 +607,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
 
   // Check to see if there are any kv-property tables associated to this
   // base table. If so, add the fields for that type of table.
+  // TODO: the 'featurprop' table should not be hardcoded.
   tripal_chado_add_bundle_kvproperty_adder_field($entity_type, $bundle_name, 'featureprop');
 }
 

+ 4 - 4
tripal_entities/includes/TripalEntityUIController.inc

@@ -168,10 +168,10 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
    // Retrieve a pages list of all tripal entitles (ie: biological data).
    // This will return the 25 most recently created entities.
    $entities = db_select('tripal_entity', 'td')
-   ->fields('td')
-   ->orderBy('created', 'DESC')
-   ->range(0,25)
-   ->execute();
+     ->fields('td')
+     ->orderBy('created', 'DESC')
+     ->range(0,25)
+     ->execute();
 
    $headers = array('Title', 'Vocabulary', 'Term', 'Author', 'Status', 'Updated', 'Operations');
    $rows = array();

+ 12 - 5
tripal_entities/tripal_entities.module

@@ -347,7 +347,7 @@ function tripal_entities_entity_info() {
       'bundle' => 'bundle'
     ),
     'bundle keys' => array (
-      'bundle' => 'bundle'
+      'bundle' => 'name'
     ),
 
     // Callback function for access to this entity.
@@ -398,7 +398,7 @@ function tripal_entities_entity_info() {
     'exportable' => FALSE,
     'entity keys' => array (
       'id' => 'id',
-      'name' => 'bundle',
+      'name' => 'name',
       'label' => 'label'
     ),
     'access callback' => 'tripal_bundle_access',
@@ -454,6 +454,10 @@ function tripal_entities_entity_info_alter(&$entity_info){
 /**
  * Menu argument loader; Load a tripal data type by string.
  *
+ *
+ * This function is not meant to be used as an API function. It is only mean
+ * for use in the menu to resolve the %tripal_entity wildcard.
+ *
  * @param $type
  *   The machine-readable name of a tripal data type to load.
  * @return
@@ -463,7 +467,7 @@ function tripal_entities_entity_info_alter(&$entity_info){
 function tripal_bundle_load($bundle_type, $reset = FALSE) {
   // Get the type of entity by the ID.
   $bundle = db_select('tripal_bundle', 'tdt')
-    ->fields('tdt', array('id', 'type'))
+    ->fields('tdt')
     ->condition('name', $bundle_type)
     ->execute()
     ->fetchObject();
@@ -480,6 +484,9 @@ function tripal_bundle_load($bundle_type, $reset = FALSE) {
  * Make sure that the wildcard you choose in the tripal_entity entity
  * definition fits the function name here.
  *
+ * This function is not meant to be used as an API function. It is only mean
+ * for use in the menu to resolve the %tripal_entity wildcard.
+ *
  * @param $id
  *   Integer specifying the tripal_entity id.
  * @param $reset
@@ -490,7 +497,7 @@ function tripal_bundle_load($bundle_type, $reset = FALSE) {
  * @see tripal_entity_load_multiple()
  */
 function tripal_entity_load($id, $reset = FALSE) {
-    $entity = entity_load('TripalEntity', array($id), array(), $reset);
-    return reset($entity);
+  $entity = entity_load('TripalEntity', array($id), array(), $reset);
+  return reset($entity);
 }
 

+ 9 - 9
tripal_fields_layout/tripal_fields_layout.module

@@ -35,7 +35,7 @@ function tripal_fields_layout_form_field_ui_display_overview_form_alter(&$form,
   // Get the bundle record.
   $bundle = db_select('tripal_bundle', 'tb')
     ->fields('tb')
-    ->condition('bundle', $bundle_name)
+    ->condition('name', $bundle_name)
     ->execute()
     ->fetchObject();
 
@@ -108,12 +108,12 @@ function tripal_fields_layout_form_field_ui_display_overview_form_alter(&$form,
   $default_panel = 'te_base';
 
   foreach (element_children($fields) as $field_name) {
-    $field_instance = field_info_instance($entity_type, $field_name, $bundle_id);
+    $field_instance = field_info_instance($entity_type, $field_name, $bundle_name);
     $panel_id = db_select('tripal_panel_fields', 'tpf')
-    ->fields('tpf', array('panel_id'))
-    ->condition('field_id', $field_instance['id'])
-    ->execute()
-    ->fetchField();
+      ->fields('tpf', array('panel_id'))
+      ->condition('field_id', $field_instance['id'])
+      ->execute()
+      ->fetchField();
     if ($panel_id) {
       $default_panel = db_select('tripal_panels', 'tp')
       ->fields('tp', array('name'))
@@ -817,8 +817,8 @@ function tripal_fields_layout_entity_view($entity, $type, $view_mode, $langcode)
       if ($view_mode == 'full') {
 
         $bundle = db_select('tripal_bundle', 'tb')
-          ->fields('tb', array('id', 'bundle', 'label'))
-          ->condition('name', $entity->name)
+          ->fields('tb', array('id', 'name', 'label'))
+          ->condition('name', $entity->bundle)
           ->execute()
           ->fetchObject();
 
@@ -845,7 +845,7 @@ function tripal_fields_layout_entity_view($entity, $type, $view_mode, $langcode)
 
         // Organize fields into panels
         foreach (element_children($entity->content) as $field_name) {
-          $field_instance = field_info_instance ($type, $field_name, $entity->name);
+          $field_instance = field_info_instance ($type, $field_name, $entity->bundle);
           // Get default panel_id
           $default_panel_id = db_select('tripal_panels', 'tp')
             ->fields('tp', array('panel_id'))