Bladeren bron

Added views integration templates and instructions to all tripal modules

laceysanderson 14 jaren geleden
bovenliggende
commit
680e07b8d0
42 gewijzigde bestanden met toevoegingen van 4606 en 40 verwijderingen
  1. 45 0
      tripal_analysis/views/README
  2. 84 0
      tripal_analysis/views/template.node_join.views.inc
  3. 205 0
      tripal_analysis/views/template.table_defn.views.inc
  4. 45 0
      tripal_contact/views/README
  5. 84 0
      tripal_contact/views/template.node_join.views.inc
  6. 205 0
      tripal_contact/views/template.table_defn.views.inc
  7. 45 0
      tripal_core/views/README
  8. 84 0
      tripal_core/views/template.node_join.views.inc
  9. 205 0
      tripal_core/views/template.table_defn.views.inc
  10. 31 8
      tripal_cv/views/README
  11. 84 0
      tripal_cv/views/template.node_join.views.inc
  12. 205 0
      tripal_cv/views/template.table_defn.views.inc
  13. 31 8
      tripal_db/views/README
  14. 84 0
      tripal_db/views/template.node_join.views.inc
  15. 205 0
      tripal_db/views/template.table_defn.views.inc
  16. 31 8
      tripal_feature/views/README
  17. 84 0
      tripal_feature/views/template.node_join.views.inc
  18. 205 0
      tripal_feature/views/template.table_defn.views.inc
  19. 45 0
      tripal_genetic/views/README
  20. 84 0
      tripal_genetic/views/template.node_join.views.inc
  21. 205 0
      tripal_genetic/views/template.table_defn.views.inc
  22. 31 8
      tripal_library/views/README
  23. 84 0
      tripal_library/views/template.node_join.views.inc
  24. 205 0
      tripal_library/views/template.table_defn.views.inc
  25. 45 0
      tripal_natural_diversity/views/README
  26. 84 0
      tripal_natural_diversity/views/template.node_join.views.inc
  27. 205 0
      tripal_natural_diversity/views/template.table_defn.views.inc
  28. 31 8
      tripal_organism/views/README
  29. 84 0
      tripal_organism/views/template.node_join.views.inc
  30. 205 0
      tripal_organism/views/template.table_defn.views.inc
  31. 45 0
      tripal_phenotype/views/README
  32. 84 0
      tripal_phenotype/views/template.node_join.views.inc
  33. 205 0
      tripal_phenotype/views/template.table_defn.views.inc
  34. 45 0
      tripal_project/views/README
  35. 84 0
      tripal_project/views/template.node_join.views.inc
  36. 205 0
      tripal_project/views/template.table_defn.views.inc
  37. 45 0
      tripal_pub/views/README
  38. 84 0
      tripal_pub/views/template.node_join.views.inc
  39. 205 0
      tripal_pub/views/template.table_defn.views.inc
  40. 45 0
      tripal_stock/views/README
  41. 84 0
      tripal_stock/views/template.node_join.views.inc
  42. 205 0
      tripal_stock/views/template.table_defn.views.inc

+ 45 - 0
tripal_analysis/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_analysis_views_data() in ../tripal_analysis.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_analysis.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_analysis.views.inc:tripal_analysis_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_analysis/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in 
+ *        tripal_analysis_views_data() by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_analysis.views.inc --in tripal_analysis_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_analysis/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in 
+ *        tripal_analysis_views_data() by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_analysis.views.inc --in tripal_analysis_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_contact/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_contact_views_data() in ../tripal_contact.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_contact.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_contact.views.inc:tripal_contact_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_contact/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_contact.views.inc:tripal_contact_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_contact.views.inc --in tripal_contact_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_contact_views_data() --in tripal_contact.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_contact/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_contact.views.inc:tripal_contact_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_contact.views.inc --in tripal_contact_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_contact_views_data() --in tripal_contact.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_core/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_core_views_data() in ../tripal_core.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_core.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_core.views.inc:tripal_core_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_core/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_core.views.inc:tripal_core_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_core.views.inc --in tripal_core_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_core_views_data() --in tripal_core.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_core/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_core.views.inc:tripal_core_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_core.views.inc --in tripal_core_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_core_views_data() --in tripal_core.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 31 - 8
tripal_cv/views/README

@@ -1,22 +1,45 @@
-This folder contains all supplementary code needed for views integration
-of the chado cvterm and related tables.
 
-File Descriptions:
-========================================================================
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
 <chado table name>.views.inc:
 	contains a single function retrieve_<chado table name>_views_data()
 	which describes that table to views. This function is called by
-	<tripal module>_views_data() in ../<tripal module>.views.inc.
+	tripal_cv_views_data() in ../tripal_cv.views.inc.
 	For more information on the form of this data array look up the
 	views2 documentation for hook_views_data() 
 	-http://views2.logrus.com/doc/html/index.html
 	
 handlers/
-	A folder which contains symbolic links to tripal_core/views_handlers/ files.
 	Each file contained within this folder defines a views handler. Only custom
 	handlers are included in this folder and each must be described in 
-	hook_views_handlers() in ../<tripal module>.views.inc.
+	hook_views_handlers() in ../tripal_cv.views.inc.
 	A views handler does one of the following:
 		1) describe the type of a field and how it should be displayed
 		2) describe a method to sort this field
-		3) describe a method to filter this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_cv.views.inc:tripal_cv_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_cv/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_cv.views.inc:tripal_cv_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_cv.views.inc --in tripal_cv_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_cv_views_data() --in tripal_cv.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_cv/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_cv.views.inc:tripal_cv_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_cv.views.inc --in tripal_cv_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_cv_views_data() --in tripal_cv.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 31 - 8
tripal_db/views/README

@@ -1,22 +1,45 @@
-This folder contains all supplementary code needed for views integration
-of the chado dbxref and related tables.
 
-File Descriptions:
-========================================================================
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
 <chado table name>.views.inc:
 	contains a single function retrieve_<chado table name>_views_data()
 	which describes that table to views. This function is called by
-	<tripal module>_views_data() in ../<tripal module>.views.inc.
+	tripal_db_views_data() in ../tripal_db.views.inc.
 	For more information on the form of this data array look up the
 	views2 documentation for hook_views_data() 
 	-http://views2.logrus.com/doc/html/index.html
 	
 handlers/
-	A folder which contains symbolic links to tripal_core/views_handlers/ files.
 	Each file contained within this folder defines a views handler. Only custom
 	handlers are included in this folder and each must be described in 
-	hook_views_handlers() in ../<tripal module>.views.inc.
+	hook_views_handlers() in ../tripal_db.views.inc.
 	A views handler does one of the following:
 		1) describe the type of a field and how it should be displayed
 		2) describe a method to sort this field
-		3) describe a method to filter this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_db.views.inc:tripal_db_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_db/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_db.views.inc:tripal_db_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_db.views.inc --in tripal_db_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_db_views_data() --in tripal_db.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_db/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_db.views.inc:tripal_db_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_db.views.inc --in tripal_db_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_db_views_data() --in tripal_db.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 31 - 8
tripal_feature/views/README

@@ -1,22 +1,45 @@
-This folder contains all supplementary code needed for views integration
-of the chado feature and related tables.
 
-File Descriptions:
-========================================================================
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
 <chado table name>.views.inc:
 	contains a single function retrieve_<chado table name>_views_data()
 	which describes that table to views. This function is called by
-	<tripal module>_views_data() in ../<tripal module>.views.inc.
+	tripal_feature_views_data() in ../tripal_feature.views.inc.
 	For more information on the form of this data array look up the
 	views2 documentation for hook_views_data() 
 	-http://views2.logrus.com/doc/html/index.html
 	
 handlers/
-	A folder which contains symbolic links to tripal_core/views_handlers/ files.
 	Each file contained within this folder defines a views handler. Only custom
 	handlers are included in this folder and each must be described in 
-	hook_views_handlers() in ../<tripal module>.views.inc.
+	hook_views_handlers() in ../tripal_feature.views.inc.
 	A views handler does one of the following:
 		1) describe the type of a field and how it should be displayed
 		2) describe a method to sort this field
-		3) describe a method to filter this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_feature.views.inc:tripal_feature_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_feature/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_feature.views.inc:tripal_feature_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_feature.views.inc --in tripal_feature_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_feature_views_data() --in tripal_feature.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_feature/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_feature.views.inc:tripal_feature_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_feature.views.inc --in tripal_feature_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_feature_views_data() --in tripal_feature.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_genetic/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_genetic_views_data() in ../tripal_genetic.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_genetic.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_genetic.views.inc:tripal_genetic_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_genetic/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_genetic.views.inc:tripal_genetic_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_genetic.views.inc --in tripal_genetic_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_genetic_views_data() --in tripal_genetic.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_genetic/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_genetic.views.inc:tripal_genetic_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_genetic.views.inc --in tripal_genetic_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_genetic_views_data() --in tripal_genetic.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 31 - 8
tripal_library/views/README

@@ -1,22 +1,45 @@
-This folder contains all supplementary code needed for views integration
-of the chado library and related tables.
 
-File Descriptions:
-========================================================================
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
 <chado table name>.views.inc:
 	contains a single function retrieve_<chado table name>_views_data()
 	which describes that table to views. This function is called by
-	<tripal module>_views_data() in ../<tripal module>.views.inc.
+	tripal_library_views_data() in ../tripal_library.views.inc.
 	For more information on the form of this data array look up the
 	views2 documentation for hook_views_data() 
 	-http://views2.logrus.com/doc/html/index.html
 	
 handlers/
-	A folder which contains symbolic links to tripal_core/views_handlers/ files.
 	Each file contained within this folder defines a views handler. Only custom
 	handlers are included in this folder and each must be described in 
-	hook_views_handlers() in ../<tripal module>.views.inc.
+	hook_views_handlers() in ../tripal_library.views.inc.
 	A views handler does one of the following:
 		1) describe the type of a field and how it should be displayed
 		2) describe a method to sort this field
-		3) describe a method to filter this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_library.views.inc:tripal_library_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_library/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_library.views.inc:tripal_library_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_library.views.inc --in tripal_library_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_library_views_data() --in tripal_library.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_library/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_library.views.inc:tripal_library_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_library.views.inc --in tripal_library_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_library_views_data() --in tripal_library.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_natural_diversity/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_natural_diversity_views_data() in ../tripal_natural_diversity.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_natural_diversity.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_natural_diversity.views.inc:tripal_natural_diversity_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_natural_diversity/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_natural_diversity.views.inc:tripal_natural_diversity_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_natural_diversity/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_natural_diversity.views.inc:tripal_natural_diversity_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 31 - 8
tripal_organism/views/README

@@ -1,22 +1,45 @@
-This folder contains all supplementary code needed for views integration
-of the chado organism and related tables.
 
-File Descriptions:
-========================================================================
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
 <chado table name>.views.inc:
 	contains a single function retrieve_<chado table name>_views_data()
 	which describes that table to views. This function is called by
-	<tripal module>_views_data() in ../<tripal module>.views.inc.
+	tripal_organism_views_data() in ../tripal_organism.views.inc.
 	For more information on the form of this data array look up the
 	views2 documentation for hook_views_data() 
 	-http://views2.logrus.com/doc/html/index.html
 	
 handlers/
-	A folder which contains symbolic links to tripal_core/views_handlers/ files.
 	Each file contained within this folder defines a views handler. Only custom
 	handlers are included in this folder and each must be described in 
-	hook_views_handlers() in ../<tripal module>.views.inc.
+	hook_views_handlers() in ../tripal_organism.views.inc.
 	A views handler does one of the following:
 		1) describe the type of a field and how it should be displayed
 		2) describe a method to sort this field
-		3) describe a method to filter this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_organism.views.inc:tripal_organism_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_organism/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_organism.views.inc:tripal_organism_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_organism.views.inc --in tripal_organism_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_organism_views_data() --in tripal_organism.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_organism/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_organism.views.inc:tripal_organism_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_organism.views.inc --in tripal_organism_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_organism_views_data() --in tripal_organism.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_phenotype/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_phenotype_views_data() in ../tripal_phenotype.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_phenotype.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_phenotype.views.inc:tripal_phenotype_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_phenotype/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_phenotype.views.inc:tripal_phenotype_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_phenotype.views.inc --in tripal_phenotype_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_phenotype_views_data() --in tripal_phenotype.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_phenotype/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_phenotype.views.inc:tripal_phenotype_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_phenotype.views.inc --in tripal_phenotype_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_phenotype_views_data() --in tripal_phenotype.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_project/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_project_views_data() in ../tripal_project.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_project.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_project.views.inc:tripal_project_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_project/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_project.views.inc:tripal_project_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_project.views.inc --in tripal_project_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_project_views_data() --in tripal_project.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_project/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_project.views.inc:tripal_project_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_project.views.inc --in tripal_project_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_project_views_data() --in tripal_project.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_pub/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_pub_views_data() in ../tripal_pub.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_pub.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_pub.views.inc:tripal_pub_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_pub/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_pub.views.inc:tripal_pub_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_pub.views.inc --in tripal_pub_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_pub_views_data() --in tripal_pub.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_pub/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_pub.views.inc:tripal_pub_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_pub.views.inc --in tripal_pub_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_pub_views_data() --in tripal_pub.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}

+ 45 - 0
tripal_stock/views/README

@@ -0,0 +1,45 @@
+
+This directory contains all additional views code needed to integrate this module with views2.
+
+FILE/FOLDER DESCRIPTIONS
+---------------------------
+<chado table name>.views.inc:
+	contains a single function retrieve_<chado table name>_views_data()
+	which describes that table to views. This function is called by
+	tripal_stock_views_data() in ../tripal_stock.views.inc.
+	For more information on the form of this data array look up the
+	views2 documentation for hook_views_data() 
+	-http://views2.logrus.com/doc/html/index.html
+	
+handlers/
+	Each file contained within this folder defines a views handler. Only custom
+	handlers are included in this folder and each must be described in 
+	hook_views_handlers() in ../tripal_stock.views.inc.
+	A views handler does one of the following:
+		1) describe the type of a field and how it should be displayed
+		2) describe a method to sort this field
+		3) describe a method to filter this field
+
+
+STANDARDS TO FOLLOW
+---------------------------
+
+1. All table definition files should be named tablename.views.inc
+2. All handlers should be in a handlers sub-directory and follow the naming convention of
+   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
+
+Views Table Definitions:
+- Please use the template files provided whenever you are describing a new table to views.
+   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
+   follow the instructions listed at the top of the template file.
+- ONLY ONE TABLE DEFINITION PER FILE
+- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
+   basetablename.views.inc and replace all XXX with basetablename.
+   
+   NOTE: Creating the table definition file is not enough. You also need to call the 
+         retrieve_XXX_views_data() function from ../tripal_stock.views.inc:tripal_stock_views_data()
+         by adding the following line:
+            $data = array_merge($data, retrieve_XXX_views_data());
+         to the function and including the file directly above the function (blow the function 
+         header by adding:
+            require_once('views/XXX.views.inc');

+ 84 - 0
tripal_stock/views/template.node_join.views.inc

@@ -0,0 +1,84 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
+ *    (ie: If you want to join features to their drupal nodes then XXX=feature)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_stock.views.inc:tripal_stock_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_stock.views.inc --in tripal_stock_views_data()
+ *
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *        This file simply defines this linking table and joins the three tables together.
+ *        No modification of XXX.views.inc is needed.
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+ 
+/**
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ *   and other tables
+ * @see tripal_stock_views_data() --in tripal_stock.views.inc
+ *
+ * The main need for description of this table to views is to join chado data with drupal nodes
+ *
+ */
+function retrieve_chado_XXX_views_data () {
+	global $db_url;
+  $data = array();
+  
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+     // return empty data array b/c if chado is external then no join to the nodetable can be made
+     return $data;
+  }
+
+  //Basic table definition-----------------------------------
+  $data['chado_XXX']['table'] = array(
+    'field' => 'nid',
+  );
+  
+  //Relationship Definitions---------------------------------
+  // Note: No joins need to be made from $data['XXX']['table']
+  
+  // Join the chado_XXX table to XXX
+  $data['chado_XXX']['table']['join']['XXX'] = array(
+  	'left_field' => 'XXX_id',
+  	'field' => 'XXX_id',
+  );
+  
+  // Join the node table to chado_XXX
+  $data['node']['table']['join']['chado_XXX'] = array(
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );
+  
+  // Join the node table to XXX
+  $data['node']['table']['join']['XXX'] = array(
+  	'left_table' => 'chado_XXX',
+  	'left_field' => 'nid',
+  	'field' => 'nid',
+  );  
+
+	return $data;
+}

+ 205 - 0
tripal_stock/views/template.table_defn.views.inc

@@ -0,0 +1,205 @@
+<?php
+
+/*************************************************************************
+ * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
+ *
+ *   - Every instance of XXX should be replaced with the name of your table
+ *   - If this is a base table (you want a view where every row is a row from this table)
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
+ *   - Relationships between this table and others: YYY is the table you are trying to join to this
+ *     one. You want to join a table to this one if this table contains a foreign key to the other
+ *     table. If the join between this table and another is through a linking table
+ *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
+ *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
+ *   - Create a field definition for each field in this table using the example fields already
+ *     listed. Match the type of the database field to the field definition listed below.
+ *     (ie: for a text/varchar field from the database use plain_text_field below)
+ * 
+ *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *        retrieve_XXX_views_data() function from ../tripal_stock.views.inc:tripal_stock_views_data()
+ *        by adding the following line:
+ *           $data = array_merge($data, retrieve_XXX_views_data());
+ *        to the function and including the file directly above the function (blow the function 
+ *        header by adding:
+ *           require_once('views/XXX.views.inc');
+ *
+ *  REMOVE THIS COMMENT IN THE COPY!
+ */ 
+ 
+/**
+ *  @file
+ *  This file defines the data array for a given chado table. This array
+ *  is merged into a larger array containing definitions of all tables associated
+ *  with this module in:
+ *  @see tripal_stock.views.inc --in tripal_stock_views_data()
+ *
+ *  Documentation on views integration can be found at 
+ *  http://views2.logrus.com/doc/html/index.html.
+ */
+
+/*************************************************************************
+ * Purpose: this function returns the portion of the data array 
+ *   which describes the XXX table, it's fields and any joins between it and other tables
+ * @see tripal_stock_views_data() --in tripal_stock.views.inc
+ *
+ * Table: XXX
+ * @code
+ * XXX-Copy/Paste Table SQL code here-XXX
+ * @endcode
+ */
+ function retrieve_XXX_views_data() {
+  global $db_url;
+  $data = array();
+
+  // if the chado database is not local to the drupal database
+  // then we need to set the database name.  This should always
+  // be 'chado'.
+  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+    $database = 'chado';
+  }
+   
+  //Basic table definition-----------------------------------
+  $data['XXX']['table']['group'] = t('Chado XXX');
+  
+  $data['XXX']['table'] = array(
+    'field' => 'primary_id',
+    'title' => t('Chado XXX'),
+    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
+  );
+  if($database){
+     $data['XXX']['table']['database'] = $database;
+  }
+
+  
+  //Relationship Definitions---------------------------------
+  //Join: XXX => YYY
+  $data['XXX']['table']['join']['YYY'] = array(
+    'left_field' => 'primary key in YYY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  
+  //Join: XXX => XY => YYY
+  $data['XXX']['table']['join']['XY'] = array(
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );  
+  $data['XXX']['table']['join']['YYY'] => array(
+    'left_table' => 'XY',
+    'left_field' => 'matching XXX key in the XY table',
+    'field' => 'foreign key in XXX table',
+  );
+  $data['XY']['table']['join']['YYY'] = array(
+    'left_field' => 'foreign key in YYY table',
+    'field' => 'matching YYY key in the XY table',
+  );
+   
+  //Table Field Definitions----------------------------------
+      
+  //Field: XXX_id (primary key)
+  $data['XXX']['field_name'] = array(
+    'title' => t('XXX Primary Key'),
+    'help' => t('A unique index for every XXX.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  /*.......................................................
+   * Beginning of Example Field definitions
+   * Remove this section when done
+   */
+
+  //Field: plain_text_field (chado datatype)   
+  $data['XXX']['plain_text_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
+  //Field: numeric_field (chado datatype)   
+  $data['XXX']['numeric_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+
+  //Field: boolean_field (chado datatype)   
+  $data['XXX']['boolean_field'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+    ),
+  );
+
+  //Field: unix_timestamp (chado datatype)   
+  $data['XXX']['unix_timestamp'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+
+  //Field: human_readable_date (chado datatype)   
+  $data['XXX']['human_readable_date'] = array(
+    'title' => t('Human-Readable Name'),
+    'help' => t('Description of this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readble_date',
+      'click sortable' => TRUE,
+     ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+   
+   /*
+    * End of Example Field definitions
+    *......................................................./
+    
+  return $data;
+}