[Gmod-tripal-devel] Core API generic insert/select functions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Gmod-tripal-devel] Core API generic insert/select functions

Stephen Ficklin-2

Hi All,

 

I have uploaded a working version of the new tripal_core_chado_insert and tripal_core_chado_select functions.  You pass them the table name and an associative array of the form we discussed previously.  It will traverse the foreign key relationships that may be nested in the array and substitute in the values.  We can use this for any type of loader.  It will automatically check that no unique or primary key constraints are violated when inserting and that all required values are provided.

 

Also, the only way to make this work is to have a description of each chado table.  So, rather than reinvent the wheel I decided to use the Drupal Schema API to describe the chado tables.  This would have taken forever to do if it had not been for the Drupal Schema module which generate all of the descriptions for me.  But, Drupal does not deal with foreign key constraints.  So, anytime someone needs to program a select/insert/update on a table using this API they will need to go to the table description and add in those foreign keys until we have all the tables properly described.  The place to do this is in the file:  tripal_core/chado_tables.schema.inc.  You can copy the example for the ‘feature’, ‘cvterm’ and ‘organism’ tables which I’ve already done.  Lacey suggested we move these definitions to the modules that support those tables and use hooks to access them.  It’s a good idea and will make it more manageable, but for now, they are where they are.  We can fix it later.

 

In the tripal_core.api.inc file I have started correctly with documentation by using the Doxygen style guide the Drupal recommends:  http://drupal.org/node/1354.  I know we’re not going to have time to write up documentation later for this growing API so if we can all use this standard for documentation that would help a lot as we can generate HTML pages of our API right off of the code. 

 

I still need to write the update function but there’s enough of the code there now if someone needs it they can just copy what I’ve done and write it for themselves.

 

Stephen


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] Core API generic insert/select functions

Stephen Ficklin-2

The update function has been added this morning and committed to SVN. We should now be able to use this insert/update/select for writing our loaders in a consistent way.

 

I’m working now on the tripal_feature.feature.api.inc file so that I can create the function to insert/update features for the Excel bulk loader I’m working on.

 

Stephen

 

From: Stephen Ficklin [mailto:[hidden email]]
Sent: Friday, February 18, 2011 12:11 AM
To: [hidden email]
Subject: Core API generic insert/select functions

 

Hi All,

 

I have uploaded a working version of the new tripal_core_chado_insert and tripal_core_chado_select functions.  You pass them the table name and an associative array of the form we discussed previously.  It will traverse the foreign key relationships that may be nested in the array and substitute in the values.  We can use this for any type of loader.  It will automatically check that no unique or primary key constraints are violated when inserting and that all required values are provided.

 

Also, the only way to make this work is to have a description of each chado table.  So, rather than reinvent the wheel I decided to use the Drupal Schema API to describe the chado tables.  This would have taken forever to do if it had not been for the Drupal Schema module which generate all of the descriptions for me.  But, Drupal does not deal with foreign key constraints.  So, anytime someone needs to program a select/insert/update on a table using this API they will need to go to the table description and add in those foreign keys until we have all the tables properly described.  The place to do this is in the file:  tripal_core/chado_tables.schema.inc.  You can copy the example for the ‘feature’, ‘cvterm’ and ‘organism’ tables which I’ve already done.  Lacey suggested we move these definitions to the modules that support those tables and use hooks to access them.  It’s a good idea and will make it more manageable, but for now, they are where they are.  We can fix it later.

 

In the tripal_core.api.inc file I have started correctly with documentation by using the Doxygen style guide the Drupal recommends:  http://drupal.org/node/1354.  I know we’re not going to have time to write up documentation later for this growing API so if we can all use this standard for documentation that would help a lot as we can generate HTML pages of our API right off of the code. 

 

I still need to write the update function but there’s enough of the code there now if someone needs it they can just copy what I’ve done and write it for themselves.

 

Stephen


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel