nd_experiment.views.inc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @file
  4. * This file defines the data array for a given chado table. This array
  5. * is merged into a larger array containing definitions of all tables associated
  6. * with this module in:
  7. * @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  8. *
  9. * Documentation on views integration can be found at
  10. * http://views2.logrus.com/doc/html/index.html.
  11. */
  12. /*************************************************************************
  13. * Purpose: this function returns the portion of the data array
  14. * which describes the nd_experiment table, it's fields and any joins between it and other tables
  15. * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  16. *
  17. * @todo Add relationship to nd_geolocations.views.inc
  18. *
  19. * Table: nd_experiment
  20. * @code
  21. CREATE TABLE nd_experiment (
  22. nd_experiment_id serial PRIMARY KEY NOT NULL,
  23. nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
  24. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  25. );
  26. * @endcode
  27. */
  28. function retrieve_nd_experiment_views_data() {
  29. global $db_url;
  30. $data = array();
  31. // if the chado database is not local to the drupal database
  32. // then we need to set the database name. This should always
  33. // be 'chado'.
  34. if(is_array($db_url) and array_key_exists('chado',$db_url)){
  35. $database = 'chado';
  36. }
  37. //Basic table definition-----------------------------------
  38. $data['nd_experiment']['table']['group'] = t('Chado ND Experiment');
  39. $data['nd_experiment']['table']['base'] = array(
  40. 'field' => 'nd_experiment_id',
  41. 'title' => t('Chado Natural Diversity Experiment'),
  42. 'help' => t('Represents one data point in a natural diversity project.'),
  43. );
  44. if($database){
  45. $data['nd_experiment']['table']['database'] = $database;
  46. }
  47. //Relationship Definitions---------------------------------
  48. //Join: nd_experiment => nd_experiment_contact => contact
  49. $data['nd_experiment']['table']['join']['nd_experiment_contact'] = array(
  50. 'left_field' => 'nd_experiment_id',
  51. 'field' => 'nd_experiment_id',
  52. );
  53. $data['nd_experiment']['table']['join']['contact'] = array(
  54. 'left_table' => 'nd_experiment_contact',
  55. 'left_field' => 'nd_experiment_id',
  56. 'field' => 'nd_experiment_id',
  57. );
  58. $data['nd_experiment_contact']['table']['join']['contact'] = array(
  59. 'left_field' => 'contact_id',
  60. 'field' => 'contact_id',
  61. );
  62. //Table Field Definitions----------------------------------
  63. //Field: nd_experiment_id (primary key)
  64. $data['nd_experiment']['nd_experiment_id'] = array(
  65. 'title' => t('ND Experiment Primary Key'),
  66. 'help' => t('A unique index for every nd_experiment.'),
  67. 'field' => array(
  68. 'handler' => 'views_handler_field_numeric',
  69. 'click sortable' => TRUE,
  70. ),
  71. 'sort' => array(
  72. 'handler' => 'views_handler_sort',
  73. ),
  74. 'filter' => array(
  75. 'handler' => 'views_handler_filter_numeric',
  76. ),
  77. );
  78. return $data;
  79. }