All Call-specific functionality/details should be in the same class.
This is designed to make it easy to create a custom call, as well as, to make it easy to extend or understand an existing call.
Retrieving results via Query
Step 4: Create your query in db.inc file to match the call name by adding 'tripal_wsdb' prefix, in our call the final function name for the query is tripal_ws_db_mystocks(). Configuration values can be accessed through the only parameter to the function and query can be customized accordingly for each configuration. See mystocks db query function in db.inc.
Currently, the query for a DB call is in a hook; instead the query should be part of the call class. For example, the tripal_ws_db_mystocks should instead be TripalWebServiceBrapiV1Mystocks::getResults.
Call configuration
// Call to chado table mapping.
// Call name or title => chado stock table.
$map = [...];
Instead of having these properties in a general config file, they should be in the appropriate call class. For example, the following would be added to the TripalWebServiceBrapiV1Mystocks class. Then it could be accessed using $class::$chado_table.
/**
* The chado table the current call pulls it's results from.
*/
public static $chado_table = 'stock';
Call Alias'
If two calls return the same results, then one should simply inherit from the previous one without the need to alter anything. For example, for BrAPI1.2:crops => BrAPI1.3:commoncropnames you would have the following:
class TripalWebServiceBrapiV1Crops extends TripalWebServiceBrapiV1Commoncropnames {
/** Current contents of TripalWebServiceBrapiV1Crops */
/** No need to add getResults() implementation
since it is inherited from the commoncropnames call */
}
All Call-specific functionality/details should be in the same class.
This is designed to make it easy to create a custom call, as well as, to make it easy to extend or understand an existing call.
Retrieving results via Query
Currently, the query for a DB call is in a hook; instead the query should be part of the call class. For example, the
tripal_ws_db_mystocks
should instead beTripalWebServiceBrapiV1Mystocks::getResults
.Call configuration
Instead of having these properties in a general config file, they should be in the appropriate call class. For example, the following would be added to the
TripalWebServiceBrapiV1Mystocks
class. Then it could be accessed using$class::$chado_table
.Call Alias'
If two calls return the same results, then one should simply inherit from the previous one without the need to alter anything. For example, for
BrAPI1.2:crops
=>BrAPI1.3:commoncropnames
you would have the following: