Tripal
Functions
tripal_core.search.inc File Reference

Functions

 tripal_core_search_include_chado_fields ()
 
 tripal_core_entity_property_info_alter (&$info)
 
 hook_tripal_search_properties_alter (&$info)
 
 tripal_search_chado_token_getter_callback ($data, $options, $field_name, $type, $info)
 
 tripal_search_chado_token_across_nodetypes_getter_callback ($data, $options, $field_name, $type, $info)
 
 tripal_core_get_token_value_for_property ($base_table, $field_name, $format, $data, $info)
 
 tripal_core_modules_enabled ($modules)
 
 tripal_search_update_default_index ()
 

Detailed Description

Adds support for Drupal indexing of Chado. It's important to note that not all of Chado is indexed but instead Only fields indicated in hook_search_include_chado_fields().

Function Documentation

◆ hook_tripal_search_properties_alter()

hook_tripal_search_properties_alter ( $info)

Allows tripal admin to alter entity property information after it has. This is currently being used to indicate chado fields to be indexed for search.

NOTE: If you simply need to add a field to be indexed, use hook_search_include_chado_fields() which provides the much easier method of simply listing fields to include.

This function is most useful if you want to change the way the value is retrieved (done by changing the 'getter callback') or add your own custom computed field.

◆ tripal_core_entity_property_info_alter()

tripal_core_entity_property_info_alter ( $info)

Implements hook_entity_property_info_alter().

This is where we actually add the properties to the node entity in order to indicate which chado fields should be indexed.

◆ tripal_core_get_token_value_for_property()

tripal_core_get_token_value_for_property (   $base_table,
  $field_name,
  $format,
  $data,
  $info 
)

Retrieve values for all tokens for an entity property getter function.

◆ tripal_core_modules_enabled()

tripal_core_modules_enabled (   $modules)

Implements hook_modules_enabled().

This hook is called when ANY module is enabled. This allows us to update the the search api "Default node index" when any Tripal module is enabled thus allowing us to catch new node types right after they're created.

◆ tripal_core_search_include_chado_fields()

tripal_core_search_include_chado_fields ( )

Implements hook_search_include_chado_fields().

This hook allows Tripal Admin/modules to specify which chado fields should be indexed for searching in a simple manner.

Returns
An array of chado fields you would like available for indexing. Each element should be the name of the table followed by the field and separated by a period. For example. feature.uniquename to indicate the uniquename field from the feature table.

◆ tripal_search_chado_token_across_nodetypes_getter_callback()

tripal_search_chado_token_across_nodetypes_getter_callback (   $data,
  $options,
  $field_name,
  $type,
  $info 
)

Implements a getter callback for foreign keys collon between content types.

Parameters
$dataThe entity object (in our case the node we need to retrieve feature properties for).
$options
$field_nameThe machine name for the entity property.
$infoThe full property definition from entity property info.
Returns
A string representing the "value" of the field.

◆ tripal_search_chado_token_getter_callback()

tripal_search_chado_token_getter_callback (   $data,
  $options,
  $field_name,
  $type,
  $info 
)

Implements a getter callback for chado token formats.

A chado token format is a string containing chado tokens.

Chado tokens are expected to follow the format of tokens auto-generated using chado_node_generate_tokens(). For example, [feature.uniquename] indicates you should return the uniquename of a feature node and [feature.organism_id>organism.species] indicates you should return the organism genus of the feature node.

The chado token format must be stored in the 'schema field' when defining the property in hook_entity_property_info() in order for this getter to work.

Parameters
$dataThe entity object (in our case the node we need to retrieve feature properties for).
$options
$field_nameThe machine name for the entity property.
$infoThe full property definition from entity property info.
Returns
A string representing the "value" of the field.

◆ tripal_search_update_default_index()

tripal_search_update_default_index ( )

The Search API provides a default node index which has a number of node-specific fields enabled by default. We want to ensure our chado fields are also enabled by default thus making for easier enabling of Tripal search.

This function should be called whenever new nodes might have been added to ensure that their fields are added as well.

We should only modify the default node index if it has no database service yet. That way we ensure we don't override user changes!