|
@@ -209,6 +209,111 @@ class obi__organism extends ChadoField {
|
|
|
return $element;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @see ChadoField::viewsData()
|
|
|
+ */
|
|
|
+ public function viewsData($view_base_id) {
|
|
|
+ $data = array();
|
|
|
+ $options = array('return_object' => TRUE);
|
|
|
+
|
|
|
+ // Add a views field for the field.
|
|
|
+ $field_name = $this->field['field_name'];
|
|
|
+ $data[$view_base_id][$field_name] = array(
|
|
|
+ 'title' => $this->instance['label'],
|
|
|
+ 'help' => $this->instance['description'],
|
|
|
+ 'field' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_field',
|
|
|
+ 'click sortable' => TRUE,
|
|
|
+ ),
|
|
|
+ 'filter' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_filter_string',
|
|
|
+ ),
|
|
|
+ 'sort' => array(
|
|
|
+ 'handler' => 'views_handler_sort',
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ // Add a views field for the genus.
|
|
|
+ $cvterm = tripal_get_chado_semweb_term('organism', 'genus', $options);
|
|
|
+ $term = tripal_get_term_details($cvterm->dbxref_id->db_id->name, $cvterm->dbxref_id->accession);
|
|
|
+ $element_name = tripal_format_views_field_element($field_name, $term);
|
|
|
+ $data[$view_base_id][$element_name] = array(
|
|
|
+ 'title' => ucfirst($term['name']),
|
|
|
+ 'help' => $term['definition'],
|
|
|
+ 'field' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_field_element',
|
|
|
+ 'click sortable' => TRUE,
|
|
|
+ ),
|
|
|
+ 'filter' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_filter_element_string',
|
|
|
+ ),
|
|
|
+ 'sort' => array(
|
|
|
+ 'handler' => 'views_handler_sort',
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ // Add a views field for the species.
|
|
|
+ $cvterm = tripal_get_chado_semweb_term('organism', 'species', $options);
|
|
|
+ $term = tripal_get_term_details($cvterm->dbxref_id->db_id->name, $cvterm->dbxref_id->accession);
|
|
|
+ $element_name = tripal_format_views_field_element($field_name, $term);
|
|
|
+ $data[$view_base_id][$element_name] = array(
|
|
|
+ 'title' => ucfirst($term['name']),
|
|
|
+ 'help' => $term['definition'],
|
|
|
+ 'field' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_field_element',
|
|
|
+ 'click sortable' => TRUE,
|
|
|
+ ),
|
|
|
+ 'filter' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_filter_element_string',
|
|
|
+ ),
|
|
|
+ 'sort' => array(
|
|
|
+ 'handler' => 'views_handler_sort',
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ // Suppor the Chado v1.3 fields.
|
|
|
+ if(chado_get_version() >= '1.3') {
|
|
|
+ // Add a views field for the infraspecific name.
|
|
|
+ $cvterm = tripal_get_chado_semweb_term('organism', 'infraspecific_name', $options);
|
|
|
+ $term = tripal_get_term_details($cvterm->dbxref_id->db_id->name, $cvterm->dbxref_id->accession);
|
|
|
+ $element_name = tripal_format_views_field_element($field_name, $term);
|
|
|
+ $data[$view_base_id][$element_name] = array(
|
|
|
+ 'title' => ucfirst($term['name']),
|
|
|
+ 'help' => $term['definition'],
|
|
|
+ 'field' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_field_element',
|
|
|
+ 'click sortable' => TRUE,
|
|
|
+ ),
|
|
|
+ 'filter' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_filter_element_string',
|
|
|
+ ),
|
|
|
+ 'sort' => array(
|
|
|
+ 'handler' => 'views_handler_sort',
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ // Add a views field for the infraspecific type.
|
|
|
+ $cvterm = tripal_get_chado_semweb_term('organism', 'type_id', $options);
|
|
|
+ $term = tripal_get_term_details($cvterm->dbxref_id->db_id->name, $cvterm->dbxref_id->accession);
|
|
|
+ $element_name = tripal_format_views_field_element($field_name, $term);
|
|
|
+ $data[$view_base_id][$element_name] = array(
|
|
|
+ 'title' => ucfirst($term['name']),
|
|
|
+ 'help' => $term['definition'],
|
|
|
+ 'field' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_field_element',
|
|
|
+ 'click sortable' => TRUE,
|
|
|
+ ),
|
|
|
+ 'filter' => array(
|
|
|
+ 'handler' => 'tripal_views_handler_filter_element_string',
|
|
|
+ ),
|
|
|
+ 'sort' => array(
|
|
|
+ 'handler' => 'views_handler_sort',
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @see ChadoField::query()
|
|
|
*/
|
|
@@ -216,6 +321,11 @@ class obi__organism extends ChadoField {
|
|
|
$alias = $this->field['field_name'];
|
|
|
$operator = $condition['operator'];
|
|
|
|
|
|
+ $genus_term = tripal_get_chado_semweb_term('organism', 'genus');
|
|
|
+ $species_term = tripal_get_chado_semweb_term('organism', 'species');
|
|
|
+ $infraspecific_name_term = tripal_get_chado_semweb_term('organism', 'infraspecific_name');
|
|
|
+ $infraspecific_type_term = tripal_get_chado_semweb_term('organism', 'type_id');
|
|
|
+
|
|
|
$query->join('organism', $alias, "base.organism_id = $alias.organism_id");
|
|
|
|
|
|
// If the column is the field name.
|
|
@@ -224,16 +334,16 @@ class obi__organism extends ChadoField {
|
|
|
}
|
|
|
|
|
|
// If the column is a subfield.
|
|
|
- if ($condition['column'] == 'organism.species') {
|
|
|
+ if ($condition['column'] == $species_term) {
|
|
|
$query->condition("$alias.species", $condition['value'], $operator);
|
|
|
}
|
|
|
- if ($condition['column'] == 'organism.genus') {
|
|
|
+ if ($condition['column'] == $genus_term) {
|
|
|
$query->condition("$alias.genus", $condition['value'], $operator);
|
|
|
}
|
|
|
- if ($condition['column'] == 'organism.infraspecies') {
|
|
|
+ if ($condition['column'] == $infraspecific_name_term) {
|
|
|
$query->condition("$alias.infraspecific_name", $condition['value'], $operator);
|
|
|
}
|
|
|
- if ($condition['column'] == 'organism.infraspecific_taxon') {
|
|
|
+ if ($condition['column'] == $infraspecific_type_term) {
|
|
|
$query->join('cvterm', 'CVT', "base.type_id = CVT.cvterm_id");
|
|
|
$query->condition("CVT.name", $condition['value'], $operator);
|
|
|
}
|