Tripal v1.0 (6.x-1.0)
chado_linking.TMP.inc
Go to the documentation of this file.
00001 <?php
00002 
00011 function tripal_views_TEMPORARY_chado_linking_data($data) {
00012   global $db_url;
00013 
00014   // if the chado database is not local to the drupal database
00015   // then we need to set the database name.  This should always
00016   // be 'chado'.
00017   if (is_array($db_url) and array_key_exists('chado', $db_url)) {
00018     // return empty data array b/c if chado is external then no join to the nodetable can be made
00019     return $data;
00020   }
00021 
00022   // FEATURE ====================================
00023   if (module_exists('tripal_feature')) {
00024     // Basic table definition
00025     $data['chado_feature']['table'] = array(
00026       'field' => 'nid',
00027       'group' => 'Chado Feature'
00028     );
00029 
00030     $data['chado_feature']['nid'] = array(
00031       'title' => t('Feature Node ID'),
00032       'help' => t('The node ID for this feature'),
00033       'field' => array(
00034         'handler' => 'views_handler_field_numeric',
00035         'click sortable' => TRUE,
00036       ),
00037       'filter' => array(
00038         'handler' => 'views_handler_filter_numeric',
00039       ),
00040       'sort' => array(
00041         'handler' => 'views_handler_sort',
00042       ),
00043     );
00044 
00045     // Note: No joins need to be made from $data['feature']['table']
00046 
00047     // Join the chado feature table to feature
00048     $data['chado_feature']['table']['join']['feature'] = array(
00049       'left_field' => 'feature_id',
00050       'field' => 'feature_id',
00051     );
00052 
00053     // Join the node table to chado feature
00054     $data['node']['table']['join']['chado_feature'] = array(
00055       'left_field' => 'nid',
00056       'field' => 'nid',
00057     );
00058 
00059     // Join the node table to feature
00060     $data['node']['table']['join']['feature'] = array(
00061       'left_table' => 'chado_feature',
00062       'left_field' => 'nid',
00063       'field' => 'nid',
00064     );
00065 
00066     // Add relationship between chado_feature and feature
00067     $data['chado_feature']['feature_nid'] = array(
00068       'group' => 'Feature',
00069       'title' => 'Feature Node',
00070       'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
00071       'real field' => 'feature_id',
00072       'relationship' => array(
00073         'handler' => 'views_handler_relationship',
00074         'title' => t('Chado => Feature'),
00075         'label' => t('Chado => Feature'),
00076         'real field' => 'feature_id',
00077         'base' => 'feature',
00078         'base field' => 'feature_id'
00079       ),
00080     );
00081 
00082     // Add node relationship to feature
00083     $data['chado_feature']['feature_chado_nid'] = array(
00084       'group' => 'Feature',
00085       'title' => 'Feature Node',
00086       'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
00087       'real field' => 'nid',
00088       'relationship' => array(
00089         'handler' => 'views_handler_relationship',
00090         'title' => t('Chado => Node'),
00091         'label' => t('Chado => Node'),
00092         'real field' => 'nid',
00093         'base' => 'node',
00094         'base field' => 'nid'
00095       ),
00096     );
00097   }
00098 
00099   // ANALYSIS ===================================
00100   if (module_exists('tripal_analysis')) {
00101     // Basic table definition
00102     $data['chado_analysis']['table'] = array(
00103       'field' => 'nid',
00104       'group' => 'Chado Analysis'
00105     );
00106 
00107     $data['chado_analysis']['nid'] = array(
00108       'title' => t('Analysis Node ID'),
00109       'help' => t('The node ID for this analysis'),
00110       'field' => array(
00111         'handler' => 'views_handler_field_numeric',
00112         'click sortable' => TRUE,
00113       ),
00114       'filter' => array(
00115         'handler' => 'views_handler_filter_numeric',
00116       ),
00117       'sort' => array(
00118         'handler' => 'views_handler_sort',
00119       ),
00120     );
00121 
00122     // Note: No joins need to be made from $data['analysis']['table']
00123 
00124     // Join the chado analysis table to analysis
00125     $data['chado_analysis']['table']['join']['analysis'] = array(
00126       'left_field' => 'analysis_id',
00127       'field' => 'analysis_id',
00128     );
00129 
00130     // Join the node table to chado analysis
00131     $data['node']['table']['join']['chado_analysis'] = array(
00132       'left_field' => 'nid',
00133       'field' => 'nid',
00134     );
00135 
00136     // Join the node table to analysis
00137     $data['node']['table']['join']['analysis'] = array(
00138       'left_table' => 'chado_analysis',
00139       'left_field' => 'nid',
00140       'field' => 'nid',
00141     );
00142 
00143     // Add relationship between chado_analysis and analysis
00144     $data['chado_analysis']['analysis_nid'] = array(
00145       'group' => 'Analysis',
00146       'title' => 'Analysis Node',
00147       'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
00148       'real field' => 'analysis_id',
00149       'relationship' => array(
00150         'handler' => 'views_handler_relationship',
00151         'title' => t('Chado => Analysis'),
00152         'label' => t('Chado => Analysis'),
00153         'real field' => 'analysis_id',
00154         'base' => 'analysis',
00155         'base field' => 'analysis_id'
00156       ),
00157     );
00158 
00159     // Add node relationship to analysis
00160     $data['chado_analysis']['analysis_chado_nid'] = array(
00161       'group' => 'Analysis',
00162       'title' => 'Analysis Node',
00163       'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
00164       'real field' => 'nid',
00165       'relationship' => array(
00166         'handler' => 'views_handler_relationship',
00167         'title' => t('Chado => Node'),
00168         'label' => t('Chado => Node'),
00169         'real field' => 'nid',
00170         'base' => 'node',
00171         'base field' => 'nid'
00172       ),
00173     );
00174   }
00175 
00176   // ORGANISM ===================================
00177   if (module_exists('tripal_organism')) {
00178     // Basic table definition
00179     $data['chado_organism']['table'] = array(
00180       'field' => 'nid',
00181       'group' => 'Chado Organism'
00182     );
00183 
00184     $data['chado_organism']['nid'] = array(
00185       'title' => t('Organism Node ID'),
00186       'help' => t('The node ID for this organism'),
00187       'field' => array(
00188         'handler' => 'views_handler_field_numeric',
00189         'click sortable' => TRUE,
00190       ),
00191       'filter' => array(
00192         'handler' => 'views_handler_filter_numeric',
00193       ),
00194       'sort' => array(
00195         'handler' => 'views_handler_sort',
00196       ),
00197     );
00198 
00199     // Note: No joins need to be made from $data['organism']['table']
00200 
00201     // Join the chado organism table to organism
00202     $data['chado_organism']['table']['join']['organism'] = array(
00203       'left_field' => 'organism_id',
00204       'field' => 'organism_id',
00205     );
00206 
00207     // Join the node table to chado organism
00208     $data['node']['table']['join']['chado_organism'] = array(
00209       'left_field' => 'nid',
00210       'field' => 'nid',
00211     );
00212 
00213     // Join the node table to organism
00214     $data['node']['table']['join']['organism'] = array(
00215       'left_table' => 'chado_organism',
00216       'left_field' => 'nid',
00217       'field' => 'nid',
00218     );
00219 
00220     // Add relationship between chado_organism and organism
00221     $data['chado_organism']['organism_id'] = array(
00222       'group' => 'Organism',
00223       'title' => 'Organism Node',
00224       'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
00225       'real field' => 'organism_id',
00226       'relationship' => array(
00227         'handler' => 'views_handler_relationship',
00228         'title' => t('Chado => Organism'),
00229         'label' => t('Chado => Organism'),
00230         'real field' => 'organism_id',
00231         'base' => 'organism',
00232         'base field' => 'organism_id'
00233       ),
00234     );
00235   /*
00236     // Add node relationship to organism
00237     $data['chado_organism']['nid'] = array(
00238       'group' => 'Organism',
00239       'title' => 'Organism Node',
00240       'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
00241       'real field' => 'nid',
00242       'relationship' => array(
00243         'handler' => 'views_handler_relationship',
00244         'title' => t('Chado => Node'),
00245         'label' => t('Chado => Node'),
00246         'real field' => 'nid',
00247         'base' => 'node',
00248         'base field' => 'nid'
00249       ),
00250     );
00251   */
00252   }
00253 
00254   // LIBRARY ====================================
00255   if (module_exists('tripal_library')) {
00256     // Basic table definition
00257     $data['chado_library']['table'] = array(
00258       'field' => 'nid',
00259       'group' => 'Chado Library'
00260     );
00261 
00262     $data['chado_library']['nid'] = array(
00263       'title' => t('Library Node ID'),
00264       'help' => t('The node ID for this library'),
00265       'field' => array(
00266         'handler' => 'views_handler_field_numeric',
00267         'click sortable' => TRUE,
00268       ),
00269       'filter' => array(
00270         'handler' => 'views_handler_filter_numeric',
00271       ),
00272       'sort' => array(
00273         'handler' => 'views_handler_sort',
00274       ),
00275     );
00276 
00277     // Note: No joins need to be made from $data['library']['table']
00278 
00279     // Join the chado library table to library
00280     $data['chado_library']['table']['join']['library'] = array(
00281       'left_field' => 'library_id',
00282       'field' => 'library_id',
00283     );
00284 
00285     // Join the node table to chado library
00286     $data['node']['table']['join']['chado_library'] = array(
00287       'left_field' => 'nid',
00288       'field' => 'nid',
00289     );
00290 
00291     // Join the node table to library
00292     $data['node']['table']['join']['library'] = array(
00293       'left_table' => 'chado_library',
00294       'left_field' => 'nid',
00295       'field' => 'nid',
00296     );
00297 
00298     // Add relationship between chado_library and library
00299     $data['chado_library']['library_nid'] = array(
00300       'group' => 'Library',
00301       'title' => 'Library Node',
00302       'help' => 'Links Chado Library Fields/Data to the Nodes in the current View.',
00303       'real field' => 'library_id',
00304       'relationship' => array(
00305         'handler' => 'views_handler_relationship',
00306         'title' => t('Chado => Library'),
00307         'label' => t('Chado => Library'),
00308         'real field' => 'library_id',
00309         'base' => 'library',
00310         'base field' => 'library_id'
00311       ),
00312     );
00313 
00314     // Add node relationship to library
00315     $data['chado_library']['library_chado_nid'] = array(
00316       'group' => 'Library',
00317       'title' => 'Library Node',
00318       'help' => 'Links Chado Library Fields/Data to the Nodes in the current View.',
00319       'real field' => 'nid',
00320       'relationship' => array(
00321         'handler' => 'views_handler_relationship',
00322         'title' => t('Chado => Node'),
00323         'label' => t('Chado => Node'),
00324         'real field' => 'nid',
00325         'base' => 'node',
00326         'base field' => 'nid'
00327       ),
00328     );
00329   }
00330 
00331   // STOCK ======================================
00332   if (module_exists('tripal_stock')) {
00333     // Basic table definition
00334     $data['chado_stock']['table'] = array(
00335       'field' => 'stock_id',
00336       'group' => 'Chado Stock',
00337     );
00338 
00339     $data['chado_stock']['nid'] = array(
00340       'title' => t('Stock Node ID'),
00341       'help' => t('The node ID for this analysis'),
00342       'field' => array(
00343         'handler' => 'views_handler_field_numeric',
00344         'click sortable' => TRUE,
00345       ),
00346       'filter' => array(
00347         'handler' => 'views_handler_filter_numeric',
00348       ),
00349       'sort' => array(
00350         'handler' => 'views_handler_sort',
00351       ),
00352     );
00353 
00354     // Note: No joins need to be made from $data['stock']['table']
00355 
00356     // Join the chado stock table to stock
00357     $data['chado_stock']['table']['join']['stock'] = array(
00358       'left_field' => 'stock_id',
00359       'field' => 'stock_id',
00360     );
00361 
00362     // Join the node table to chado stock
00363     $data['node']['table']['join']['chado_stock'] = array(
00364       'left_field' => 'nid',
00365       'field' => 'nid',
00366     );
00367 
00368     // Join the node table to stock
00369     $data['node']['table']['join']['stock'] = array(
00370       'left_table' => 'chado_stock',
00371       'left_field' => 'nid',
00372       'field' => 'nid',
00373     );
00374 
00375     // Add relationship between chado_stock and stock
00376     $data['chado_stock']['stock_nid'] = array(
00377       'group' => 'Stock',
00378       'title' => 'Stock Node',
00379       'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
00380       'real field' => 'stock_id',
00381       'relationship' => array(
00382         'handler' => 'views_handler_relationship',
00383         'title' => t('Chado => Stock'),
00384         'label' => t('Chado => Stock'),
00385         'real field' => 'stock_id',
00386         'base' => 'stock',
00387         'base field' => 'stock_id'
00388       ),
00389     );
00390 
00391     // Add node relationship to stock
00392     $data['chado_stock']['stock_chado_nid'] = array(
00393       'group' => 'Stock',
00394       'title' => 'Stock Node',
00395       'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
00396       'real field' => 'nid',
00397       'relationship' => array(
00398         'handler' => 'views_handler_relationship',
00399         'title' => t('Chado => Node'),
00400         'label' => t('Chado => Node'),
00401         'real field' => 'nid',
00402         'base' => 'node',
00403         'base field' => 'nid'
00404       ),
00405     );
00406   }
00407 
00408   return $data;
00409 }
 All Classes Files Functions Variables