|
@@ -8,7 +8,7 @@
|
|
|
* @ingroup tripal_modules
|
|
|
*/
|
|
|
|
|
|
-require('tripal_library.api.inc');
|
|
|
+require('api/tripal_library.api.inc');
|
|
|
|
|
|
/**
|
|
|
* Display help and module information
|
|
@@ -164,7 +164,10 @@ function tripal_library_views_api() {
|
|
|
*/
|
|
|
function tripal_library_module_description_page() {
|
|
|
$text = '';
|
|
|
-
|
|
|
+ $text .= '<h3>Tripal Library Administrative Tools Quick Links:</h3>';
|
|
|
+ $text .= "<ul>
|
|
|
+ <li><a href=\"" . url("admin/tripal/tripal_library/configuration") . "\">Library Configuration</a></li>
|
|
|
+ </ul>";
|
|
|
$text .= '<h3>Module Description:</h3>';
|
|
|
$text .= '<p>The Tripal Library module is an interface for the Chado Library module which groups features (sequences) into genetic libraries.
|
|
|
This module provides support for visualization of "library" pages, editing and updating.</p>';
|
|
@@ -1484,13 +1487,15 @@ function tripal_library_taxonify_features($library_id = NULL, $job_id = NULL) {
|
|
|
* @ingroup tripal_library
|
|
|
*/
|
|
|
function chado_library_delete(&$node) {
|
|
|
- // Before removing, get library_id so we can remove it from chado database
|
|
|
- // later
|
|
|
- $sql_drupal = "SELECT library_id ".
|
|
|
- "FROM {chado_library} ".
|
|
|
- "WHERE nid = %d AND vid = %d";
|
|
|
- $library_id = db_result(db_query($sql_drupal, $node->nid, $node->vid));
|
|
|
|
|
|
+ $library_id = chado_get_id_for_node('library', $node);
|
|
|
+
|
|
|
+ // if we don't have a library id for this node then this isn't a node of
|
|
|
+ // type chado_library or the entry in the chado_library table was lost.
|
|
|
+ if (!$library_id){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// Remove data from {chado_library}, {node} and {node_revisions} tables of
|
|
|
// drupal database
|
|
|
$sql_del = "DELETE FROM {chado_library} ".
|
|
@@ -1637,73 +1642,21 @@ function get_chado_libraries() {
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
+ * Remove orphaned drupal nodes
|
|
|
+ *
|
|
|
+ * @param $dummy
|
|
|
+ * Not Used -kept for backwards compatibility
|
|
|
+ * @param $job_id
|
|
|
+ * The id of the tripal job executing this function
|
|
|
*
|
|
|
* @ingroup tripal_library
|
|
|
*/
|
|
|
function tripal_library_cleanup($dummy = NULL, $job_id = NULL) {
|
|
|
|
|
|
- // build the SQL statments needed to check if nodes point to valid analyses
|
|
|
- $dsql = "SELECT * FROM {node} WHERE type = 'chado_library' order by nid";
|
|
|
- $nsql = "SELECT * FROM {node} WHERE nid = %d";
|
|
|
- $csql = "SELECT * FROM {chado_library} where nid = %d ";
|
|
|
- $cosql= "SELECT * FROM {chado_library}";
|
|
|
- $tsql = "SELECT * FROM {library} L WHERE library_id = %d";
|
|
|
-
|
|
|
- // load into nodes array
|
|
|
- $results = db_query($dsql);
|
|
|
- $count = 0;
|
|
|
- $nodes = array();
|
|
|
- while ($node = db_fetch_object($results)) {
|
|
|
- $nodes[$count] = $node;
|
|
|
- $count++;
|
|
|
- }
|
|
|
-
|
|
|
- // load the chado_analyses into an array
|
|
|
- $results = db_query($cosql);
|
|
|
- $cnodes = array();
|
|
|
- while ($node = db_fetch_object($results)) {
|
|
|
- $cnodes[$count] = $node;
|
|
|
- $count++;
|
|
|
- }
|
|
|
- $interval = intval($count * 0.01);
|
|
|
-
|
|
|
- // iterate through all of the chado_library nodes and delete those that aren't valid
|
|
|
- foreach ($nodes as $nid) {
|
|
|
-
|
|
|
- // update the job status every 1% analyses
|
|
|
- if ($job_id and $i % $interval == 0) {
|
|
|
- tripal_job_set_progress($job_id, intval(($i/$count)*100));
|
|
|
- }
|
|
|
-
|
|
|
- // first check to see if the node has a corresponding entry
|
|
|
- // in the chado_library table. If not then delete the node.
|
|
|
- $library = db_fetch_object(db_query($csql, $nid->nid));
|
|
|
- if (!$library) {
|
|
|
- node_delete($nid->nid);
|
|
|
- $message = "Missing in chado_library table.... DELETING: $nid->nid\n";
|
|
|
- watchdog('tripal_library', $message, array(), WATCHDOG_WARNING);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $i++;
|
|
|
- }
|
|
|
-
|
|
|
- // iterate through all of the chado_library nodes and delete those that aren't valid
|
|
|
- foreach ($cnodes as $nid) {
|
|
|
- // update the job status every 1% analyses
|
|
|
- if ($job_id and $i % $interval == 0) {
|
|
|
- tripal_job_set_progress($job_id, intval(($i/$count)*100));
|
|
|
- }
|
|
|
- $node = db_fetch_object(db_query($nsql, $nid->nid));
|
|
|
- if (!$node) {
|
|
|
- db_query("DELETE FROM {chado_library} WHERE nid = '%nid'", $nid->nid);
|
|
|
- $message = "chado_library missing node.... DELETING: $nid->nid\n";
|
|
|
- watchdog('tripal_library', $message, array(), WATCHDOG_WARNING);
|
|
|
- }
|
|
|
-
|
|
|
- $i++;
|
|
|
- }
|
|
|
- return '';
|
|
|
+ return tripal_core_clean_orphaned_nodes('library', $job_id);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
/************************************************************************
|
|
|
*/
|
|
|
function theme_tripal_library_search_result($node) {
|