Browse Source

Fixed API function for custom tables and mviews to remove redirects. Fixed bugs realted to deleting, editing custom tables that are materialized views

Stephen Ficklin 11 years ago
parent
commit
5fbf13ed79

+ 68 - 5
tripal_core/api/tripal_core.custom_tables.api.inc

@@ -42,6 +42,13 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_creation
   $results = db_query($sql, array(':table_id' => $table_id));
   $custom_table = $results->fetchObject();
 
+  // if this is a materialized view then don't allow editing with this function
+  if ($custom_table->mview_id) {
+    tripal_report_error('tripal_core', TRIPAL_ERROR, "Please use the tripal_edit_mview() function to edit this custom table as it is a materialized view.", array());
+    drupal_set_message("This custom table is a materialized view. Please use the "  . l('Materialized View', 'admin/tripal/schema/mviews') . " interface to edit it.", 'error');
+    return FALSE;
+  }
+  
   // if the user changed the table name, we want to drop the old one and force
   // creation of the new one.
   if ($custom_table->table_name != $table_name) {
@@ -75,7 +82,6 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_creation
         drupal_set_message(t("Custom table '%name' created", array('%name' => $table_name)));
       }
     }
-    // TODO: add FK constraints
   }
 }
 
@@ -88,6 +94,14 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_creation
  * table. This way the function cannot be used to accidentally alter existing
  * non custom tables.  If $skip_creation is set then the table is simply
  * added to the tripal_custom_tables and no table is created in Chado.
+ * 
+ * If you are creating a materialized view do not use this function, but rather 
+ * use the tripal_add_mview(). A materialized view is also considered a custom table
+ * and an entry for it will be added to both the tripal_mviews and 
+ * tripal_custom_tables tables, but only if the tripal_add_mview() function is
+ * used. The optional $mview_id parameters in this function is intended
+ * for use by the tripal_add_mview() function when it calls this function
+ * to create the table.
  *
  * @param $table
  *   The name of the table to create.
@@ -98,13 +112,17 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_creation
  *   exists.  This is useful if the table was already created through another
  *   means and you simply want to make Tripal aware of the table schema.  If the
  *   table does not exist it will be created.
- *
+ * @param $mview_id
+ *   Optional. If this custom table is also a materialized view then provide
+ *   it's mview_id. This paramter is intended only when this function
+ *   is called by the tripal_add_mview() function. When creating a custom
+ *   table you shouldn't need to use this parameter.
  * @return
  *   TRUE on success, FALSE on failure
  *
  * @ingroup tripal_custom_tables_api
  */
-function chado_create_custom_table($table, $schema, $skip_creation = 1) {
+function chado_create_custom_table($table, $schema, $skip_creation = 1, $mview_id = NULL) {
   global $databases;
   $created = 0;
   $recreated = 0;
@@ -161,6 +179,9 @@ function chado_create_custom_table($table, $schema, $skip_creation = 1) {
   $record = new stdClass();
   $record->table_name = $table;
   $record->schema = serialize($schema);
+  if ($mview_id) {
+    $record->mview_id = $mview_id;
+  }
 
   // if an entry already exists then remove it
   if ($centry) {
@@ -169,8 +190,7 @@ function chado_create_custom_table($table, $schema, $skip_creation = 1) {
   }
   $success = drupal_write_record('tripal_custom_tables', $record);
   if (!$success) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
-      "Error adding custom table %table_name.",
+    tripal_report_error('tripal_core', TRIPAL_ERROR, "Error adding custom table %table_name.",
       array('%table_name' => $table));
     drupal_set_message(t("Could not add custom table %table_name.
       Please check the schema array.", array('%table_name' => $table)), 'error');
@@ -240,3 +260,46 @@ function chado_get_custom_table_id($table_name) {
 
   return FALSE;
 }
+/**
+ * Deletes the specified custom table
+ *
+ * @param $table_id
+ *   The unique ID of the custom table for the action to be performed on
+ *
+ * @ingroup tripal_custom_tables
+ */
+function tripal_delete_custom_table($table_id) {
+  global $user;
+
+  $args = array("$table_id");
+  if (!$table_id) {
+    return '';
+  }
+
+  // get this table details
+  $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_id = :table_id";
+  $results = db_query($sql, array(':table_id' => $table_id));
+  $custom_table = $results->fetchObject();
+  
+  // if this is a materialized view then don't allow deletion with this function
+  if ($custom_table->mview_id) {
+    tripal_report_error('tripal_core', TRIPAL_ERROR, "Please use the tripal_delete_mview() function to delete this custom table as it is a materialized view. Table not deleted.", array());    
+    drupal_set_message("This custom table is a materialized view. Please use the "  . l('Materialized View', 'admin/tripal/schema/mviews') . " interface to delete it.", 'error');
+    return FALSE;
+  }
+
+  // remove the entry from the tripal_custom tables table
+  $sql = "DELETE FROM {tripal_custom_tables} WHERE table_id = $table_id";
+  $success = db_query($sql);
+  if ($success) {
+    drupal_set_message(t("Custom Table '%name' removed", array('%name' => $custom_table->table_name)));
+  }
+  
+  // drop the table from chado if it exists
+  if (db_table_exists($custom_table->table_name)) {
+    $success = chado_query("DROP TABLE %s", $custom_table->table_name);
+    if ($success) {
+      drupal_set_message(t("Custom Table '%name' dropped", array('%name' => $custom_table->table_name)));
+    }
+  }
+}

+ 11 - 18
tripal_core/api/tripal_core.mviews.api.inc

@@ -153,7 +153,7 @@ function tripal_add_mview($name, $modulename, $mv_schema, $query, $comment = NUL
         chado_query($sql);
       }
       // create the table
-      if (!chado_create_custom_table($mv_table, $mv_schema, 0)) {
+      if (!chado_create_custom_table($mv_table, $mv_schema, 0, $record->mview_id)) {
         drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."), 'error');
       }
       else {
@@ -272,7 +272,7 @@ function tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
     // re-create the table differently depending on if it the traditional method
     // or the Drupal Schema API method
     if ($create_table and $mv_schema) {
-      if (!chado_create_custom_table($mv_table, $schema_arr, 0)) {
+      if (!chado_create_custom_table($mv_table, $schema_arr, 0, $record->mview_id)) {
         drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."));
       }
       else {
@@ -334,12 +334,10 @@ function tripal_mviews_get_mview_id($view_name) {
  *
  * @param $mview_id
  *   The unique ID of the materialized view for the action to be performed on
- * @param $redirect
- *   TRUE/FALSE depending on whether you want to redirect the user to admin/tripal/mviews
  *
  * @ingroup tripal_mviews_api
  */
-function tripal_add_populate_mview($mview_id, $redirect = FALSE) {
+function tripal_add_job_populate_mview($mview_id) {
   global $user;
 
   if (!$mview_id) {
@@ -356,10 +354,6 @@ function tripal_add_populate_mview($mview_id, $redirect = FALSE) {
   tripal_add_job("Populate materialized view '$mview->name'", 'tripal_core',
      'tripal_populate_mview', $args, $user->uid);
 
-  // Redirect the user
-  if ($redirect) {
-    drupal_goto("admin/tripal/mviews");
-  }
 }
 
 /**
@@ -369,12 +363,10 @@ function tripal_add_populate_mview($mview_id, $redirect = FALSE) {
  *   The action to be taken. One of update or delete
  * @param $mview_id
  *   The unique ID of the materialized view for the action to be performed on
- * @param $redirect
- *   TRUE/FALSE depending on whether you want to redirect the user to admin/tripal/mviews
  *
  * @ingroup tripal_mviews_api
  */
-function tripal_delete_mview($mview_id, $redirect = FALSE) {
+function tripal_delete_mview($mview_id) {
   global $user;
 
   if (!$mview_id) {
@@ -397,12 +389,13 @@ function tripal_delete_mview($mview_id, $redirect = FALSE) {
   // drop the table from chado if it exists
   if ($mview_exists) {
     $sql = "DROP TABLE {" . $mview->mv_table . "}";
-    chado_query($sql);
-  }
-
-  // Redirect the user
-  if ($redirect) {
-    drupal_goto("admin/tripal/mviews");
+    $success = chado_query($sql);
+    if ($success) {
+      drupal_set_message(t("Materialized view, %name, deleted.", array('%name' => $mview->name)));
+    }
+    else {
+      drupal_set_message(t("Problem deleting materialized view, %name.", array('%name' => $mview->name)), 'error');
+    }
   }
 }
 

+ 69 - 83
tripal_core/includes/tripal_core.custom_tables.inc

@@ -57,8 +57,9 @@ function tripal_custom_table_admin_view() {
  * @ingroup tripal_custom_tables
  */
 function tripal_custom_table_new_page() {
-  $output = drupal_render(drupal_get_form('tripal_custom_tables_form'));
-  return $output;
+ 
+  $form = drupal_get_form('tripal_custom_tables_form');
+  return drupal_render($form);
 }
 
 /**
@@ -78,7 +79,7 @@ function tripal_custom_table_view($table_id) {
 
   // create a table with each row containig stats for
   // an individual job in the results set.
-  $return_url = url("admin/tripal/custom_tables/");
+  $return_url = url("admin/tripal/schema/custom_tables");
   $output .= "<p><a href=\"$return_url\">" . t("Return to list of custom tables") . "</a></p>";
   $output .= "<br />";
   $output .= "<p>Details for <b>$custom_table->table_name</b>:</p>";
@@ -110,47 +111,6 @@ function tripal_custom_table_view($table_id) {
   return $output;
 }
 
-/**
- * A template function to render a listing of all Custom tables
- *
- * @ingroup tripal_custom_tables
- */
-function tripal_custom_tables_list() {
-  $header = array('', 'Table Name', 'Description');
-  $rows = array();
-  $custom_tables = db_query("SELECT * FROM {tripal_custom_tables} ORDER BY table_name");
-
-  foreach ($custom_tables as $custom_table) {
-
-    $rows[] = array(
-      l(t('View'), "admin/tripal/custom_tables/view/$custom_table->table_id") . " | " .
-      l(t('Edit'), "admin/tripal/custom_tables/edit/$custom_table->table_id") . " | " .
-      $custom_table->table_name,
-      $custom_table->comment,
-      l(t('Delete'), "admin/tripal/custom_tables/action/delete/$custom_table->table_id"),
-    );
-  }
-
-  $rows[] = array(
-    'data' => array(
-      array('data' => l(t('Create a new custom table.'), "admin/tripal/custom_tables/new"),
-        'colspan' => 6),
-    )
-  );
-  $table = array(
-    'header' => $header,
-    'rows' => $rows,
-    'attributes' => array('class' => 'tripal-data-table'),
-    'sticky' => FALSE,
-    'caption' => '',
-    'colgroups' => array(),
-    'empty' => 'No custom tables have been added',
-  );
-
-  $page = theme_table($table);
-  return $page;
-}
-
 /**
  * A Form to Create/Edit a Custom table.
  *
@@ -180,6 +140,13 @@ function tripal_custom_tables_form($form, &$form_state = NULL, $table_id = NULL)
     $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_id = :table_id ";
     $results = db_query($sql, array(':table_id' => $table_id));
     $custom_table = $results->fetchObject();
+    
+    // if this is a materialized view then don't allow editing with this function
+    if ($custom_table->mview_id) {
+      drupal_set_message("This custom table is a materialized view. Please use the "  . l('Materialized View', 'admin/tripal/schema/mviews') . " interface to edit it.", 'error');
+      drupal_goto("admin/tripal/schema/custom_tables");
+      return array();
+    }
 
     // set the default values.  If there is a value set in the
     // form_state then let's use that, otherwise, we'll pull
@@ -194,6 +161,11 @@ function tripal_custom_tables_form($form, &$form_state = NULL, $table_id = NULL)
       $default_schema = preg_replace('/=>\s+\n\s+array/', '=> array', $default_schema);
     }
   }
+  
+  $form['return'] = array(
+    '#type' => 'markup',
+    '#markup' => "<p>" . l("Return to list of custom tables", "admin/tripal/schema/custom_tables") . "</p>",
+  );
 
   // Build the form
   $form['action'] = array(
@@ -245,7 +217,6 @@ function tripal_custom_tables_form($form, &$form_state = NULL, $table_id = NULL)
     '#value'        => t($value),
     '#executes_submit_callback' => TRUE,
   );
-  $form['#redirect'] = 'admin/tripal/custom_tables';
 
   $form['example']= array(
     '#type'          => 'item',
@@ -384,53 +355,68 @@ function tripal_custom_tables_form_submit($form, &$form_state) {
   else {
     drupal_set_message(t("No action performed."));
   }
-
-  return '';
+  
+  drupal_goto("admin/tripal/schema/custom_tables");
 }
 
 /**
- * Does the specified action for the specified custom table
- *
- * @param $op
- *   The action to be taken. Currenly only delete is available
- * @param $table_id
- *   The unique ID of the custom table for the action to be performed on
- * @param $redirect
- *   TRUE/FALSE depending on whether you want to redirect the user to admin/tripal/custom_tables
+ * Just a simple form for confirming deletion of a custom table
  *
  * @ingroup tripal_custom_tables
  */
-function tripal_custom_tables_action($op, $table_id, $redirect = FALSE) {
-  global $user;
-
-  $args = array("$table_id");
-  if (!$table_id) {
-    return '';
-  }
-
-  // get this table details
+function tripal_custom_tables_delete_form($form, &$form_state, $table_id) {
+  
+  // get details about this table entry
   $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_id = :table_id";
   $results = db_query($sql, array(':table_id' => $table_id));
-  $custom_table = $results->fetchObject();
-
-  if ($op == 'delete') {
-
-    // remove the entry from the tripal_custom tables table
-    $sql = "DELETE FROM {tripal_custom_tables} " .
-           "WHERE table_id = $table_id";
-    db_query($sql);
-
-    // drop the table from chado if it exists
-    if (db_table_exists($custom_table->table_name)) {
-      $success = chado_query("DROP TABLE %s", $custom_table->table_name);
-      if ($success) {
-        drupal_set_message(t("Custom Table '%name' dropped", array('%name' => $custom_table->table_name)));
-      }
-    }
+  $entry = $results->fetchObject();
+  
+  // if this is a materialized view then don't allow editing with this function
+  if ($entry->mview_id) {
+    drupal_set_message("This custom table is a materialized view. Please use the "  . l('Materialized View', 'admin/tripal/schema/mviews') . " interface to delete it.", 'error');
+    drupal_goto("admin/tripal/schema/custom_tables");
+    return array();
   }
+  
+  
+  $form = array();
+  $form['table_id'] = array(
+    '#type' => 'value',
+    '#value' => $table_id
+  );
+  
+  $form['sure'] = array(
+    '#type' => 'markup',
+    '#markup' => '<p>Are you sure you want to delete the "' . $entry->table_name . '" custom table?</p>'
+  );
+  $form['submit'] = array(
+    '#type'         => 'submit',
+    '#value'        => 'Delete',
+  );
+  $form['cancel'] = array(
+    '#type'         => 'submit',
+    '#value'        => 'Cancel',
+  );
+  return $form;
+}
 
-  // Redirect the user
-  if ($redirect) {
-    drupal_goto("admin/tripal/custom_tables");
+/**
+ * form submit hook for the tripal_custom_tables_delete_form form.
+ * 
+ * @param $form
+ * @param $form_state
+ */
+function tripal_custom_tables_delete_form_submit($form, &$form_state) {
+  $action   = $form_state['clicked_button']['#value'];
+  $table_id = $form_state['values']['table_id'];
+    
+  if (strcmp($action, 'Delete') == 0) {
+    tripal_delete_custom_table($table_id);
+  }
+  else {
+    drupal_set_message(t("No action performed."));
   }
+  drupal_goto("admin/tripal/schema/custom_tables");
 }
+
+

+ 67 - 63
tripal_core/includes/tripal_core.mviews.inc

@@ -126,68 +126,6 @@ function tripal_mview_report($mview_id) {
   return $output;
 }
 
-/**
- * A template function to render a listing of all Materialized Views
- *
- * @ingroup tripal_mviews
- */
-function tripal_mviews_report() {
-  $header = array('', 'MView Name', 'Last Update', 'Status', 'Description', '');
-  $rows = array();
-  $mviews = db_query("SELECT * FROM {tripal_mviews} ORDER BY name");
-
-  foreach ($mviews as $mview) {
-    if ($mview->last_update > 0) {
-      $update = format_date($mview->last_update);
-    }
-    else {
-      $update = 'Not yet populated';
-    }
-
-    $rows[] = array(
-      l(t('View'), "admin/tripal/schema/mviews/report/$mview->mview_id") . " | " .
-      l(t('Edit'), "admin/tripal/schema/mviews/edit/$mview->mview_id") . " | " .
-      l(t('Populate'), "admin/tripal/schema/mviews/action/update/$mview->mview_id"),
-      $mview->name,
-      $update,
-      $mview->status,
-      $mview->comment,
-      l(t('Delete'), "admin/tripal/schema/mviews/action/delete/$mview->mview_id"),
-    );
-  }
-
-  $rows[] = array(
-    'data' => array(
-      array('data' => l(t('Create a new materialized view.'), "admin/tripal/schema/mviews/new"),
-        'colspan' => 6),
-    )
-  );
-  $page = '</p>' . t("Materialized Views (MViews) are custom tables populated with a defined SQL statement.
-    Because Chado is highly normalized and highly constrained it serves as a wonderful
-    data storage platform, but unfortunately some queries may be slow.  MViews alleviate slowness by aggregating data
-    into tables that are more easy to query.  Use MViews to create tables for custom search pages or custom Tripal
-    module development.") . '</p>';
-  $page .= '<p><b>' . t("MViews behaves in the following way:") . '</b><ul>' .
-           '<li>' . t("The SQL statement defined for an MVIEW will be used to populate the table") . '</li>' .
-           '<li>' . t("Altering the table structure of an MView will cause the MView table to be dropped and recreated.  All records in the MView will be lost.") . '</li>' .
-           '<li>' . t("Altering the query of an existing view will not change the MView table. No records will be lost. ") . '</li>' .
-           '<li>' . t("Repopulating an MView that is already populated will result in replacement of all records.") . '</li>' .
-           '<li>' . t("A database transaction will be used when populating MViews. Therefore replacement of records does not occur until the query completes.  Any search forms or pages dependent on the MView will continue to function.") . '</li>' .
-           '</ul></p>';
-  $page .= '<b>' . t("Existing MViews") . '</b>';
-  $table = array(
-    'header' => $header,
-    'rows' => $rows,
-    'attributes' => array('class' => 'tripal-data-table'),
-    'sticky' => FALSE,
-    'caption' => '',
-    'colgroups' => array(),
-    'empty' => 'There are no materialized views',
-  );
-  $page .= theme_table($table);
-  return $page;
-}
-
 /**
  * A Form to Create/Edit a Materialized View
  *
@@ -432,7 +370,6 @@ function tripal_mviews_form($form, &$form_state = NULL, $mview_id = NULL) {
     '#value'        => t($value),
     '#executes_submit_callback' => TRUE,
   );
-  $form['#redirect'] = 'admin/tripal/schema/mviews';
   
   $form['example']= array(
     '#type'          => 'item',
@@ -601,6 +538,7 @@ function tripal_mviews_form_submit($form, &$form_state) {
     $schema_arr = array();
     eval("\$schema_arr = $schema;");
     tripal_add_mview($name, $modulename, $schema_arr, $query, $comment);
+    drupal_goto("admin/tripal/schema/mviews");
   }
   else {
     drupal_set_message(t("No action performed."));
@@ -608,3 +546,69 @@ function tripal_mviews_form_submit($form, &$form_state) {
 
   return '';
 }
+
+
+/**
+ * Just a simple form for confirming deletion of a custom table
+ *
+ * @ingroup tripal_custom_tables
+ */
+function tripal_mviews_delete_form($form, &$form_state, $mview_id) {
+
+  // get details about this table entry
+  $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id";
+  $results = db_query($sql, array(':mview_id' => $mview_id));
+  $entry = $results->fetchObject();
+
+  $form = array();
+  $form['mview_id'] = array(
+    '#type' => 'value',
+    '#value' => $mview_id
+  );
+
+  $form['sure'] = array(
+    '#type' => 'markup',
+    '#markup' => '<p>Are you sure you want to delete the "' . $entry->name . '" materialized view?</p>'
+  );
+  $form['submit'] = array(
+    '#type'         => 'submit',
+    '#value'        => 'Delete',
+  );
+  $form['cancel'] = array(
+    '#type'         => 'submit',
+    '#value'        => 'Cancel',
+  );
+  return $form;
+}
+
+/**
+ * form submit hook for the tripal_custom_tables_delete_form form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function tripal_mviews_delete_form_submit($form, &$form_state) {
+  $action   = $form_state['clicked_button']['#value'];
+  $mview_id = $form_state['values']['mview_id'];
+
+  if (strcmp($action, 'Delete') == 0) {
+    tripal_delete_mview($mview_id);
+  }
+  else {
+    drupal_set_message(t("No action performed."));
+  }
+  drupal_goto("admin/tripal/schema/mviews");
+}
+
+/**
+ * A wrapper for the tripal_add_job_populate_mview() API function, which
+ * then redirects back to the admin page for mviews.
+ * 
+ * @param $mview_id
+ */
+
+function tripal_mviews_add_populate_job($mview_id) {
+  
+  tripal_add_job_populate_mview($mview_id);
+  drupal_goto("admin/tripal/schema/mviews");
+}

+ 64 - 0
tripal_core/tripal_core.install

@@ -307,12 +307,76 @@ function tripal_core_custom_tables_schema() {
         'type' => 'text',
         'not NULL' => TRUE
       ),
+      'mview_id' => array(
+        'type' => 'int',
+        'not NULL' => FALSE
+      )
     ),
     'indexes' => array(
       'table_id' => array('table_id'),
     ),
     'primary key' => array('table_id'),
+    'foreign keys' => array(
+      'tripal_mviews' => array(
+        'table' => 'tripal_mviews',
+        'columns' => array(
+          'mview_id' => 'mview_id'
+        ),
+      ),
+    ),
   );
 
   return $schema;
 }
+
+/**
+ * Adds an mview_id column to the tripal_custom_tables table and makes an assocation between the mview and the custom table
+ *
+ */
+function tripal_core_update_7200() {
+
+  // add an mview column to the tripal_custom_tables table so we
+  // can associate which of the custom tables are also mviews
+  if (!db_field_exists('tripal_custom_tables', 'mview_id')) {
+    $spec = array(
+      'type' => 'int',
+      'not NULL' => FALSE
+    );
+    $keys = array(
+      'foreign keys' => array(
+        'tripal_mviews' => array(
+          'table' => 'tripal_mviews',
+          'columns' => array(
+            'mview_id' => 'mview_id'
+          ),
+        ),
+      ),
+    );
+    db_add_field('tripal_custom_tables', 'mview_id', $spec, $keys);
+    
+    // the foreign key specification doesn't really add one to the
+    // Drupal schema, it is just used internally, but we want one
+    db_query('
+      ALTER TABLE {tripal_custom_tables}
+      ADD CONSTRAINT {tripal_custom_tables_fk1}
+      FOREIGN KEY (mview_id) REFERENCES {tripal_mviews} (mview_id)
+      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
+    ');
+  }
+  
+  // now link the materialized view to it's custom table entry
+  $mviews = db_select('tripal_mviews', 'tmv')
+    ->fields('tmv', array('mview_id', 'mv_table'))
+    ->execute();
+  foreach ($mviews as $mview) {
+    db_update('tripal_custom_tables')
+     ->fields(array(
+       'mview_id' => $mview->mview_id
+     ))
+     ->condition('table_name', $mview->mv_table)
+     ->execute();
+     
+     
+  }
+  
+}

+ 9 - 29
tripal_core/tripal_core.module

@@ -260,16 +260,6 @@ function tripal_core_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
   );
-  /**
-  $items['admin/tripal/schema/mviews/list'] = array(
-    'title' => 'List Materialized Views',
-    'description' => 'A list of existing materialized views with the ability to edit & delete existing materialized views.',
-    'page callback' => 'tripal_mviews_report',
-    'access arguments' => array('administer tripal'),
-    'type' => MENU_NORMAL_ITEM,
-    'weight' => -10
-  );
-  */
   $items['admin/tripal/schema/mviews/report/%'] = array(
     'title' => 'Materialized View',
     'description' => 'Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.',
@@ -293,19 +283,19 @@ function tripal_core_menu() {
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/schema/mviews/action/update/%'] = array(
+  $items['admin/tripal/schema/mviews/update/%'] = array(
     'title' => 'Create Materialized View',
     'description' => 'Materialized views are used to improve speed of large or complex queries.',
-    'page callback' => 'tripal_add_populate_mview',
-    'page arguments' => array(6, "1"),
+    'page callback' => 'tripal_mviews_add_populate_job',
+    'page arguments' => array(5),
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/schema/mviews/action/delete/%'] = array(
+  $items['admin/tripal/schema/mviews/delete/%'] = array(
     'title' => 'Create Materialized View',
     'description' => 'Materialized views are used to improve speed of large or complex queries.',
-    'page callback' => 'tripal_delete_mview',
-    'page arguments' => array(6, "1"),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array(tripal_mviews_delete_form, 5),
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );
@@ -328,16 +318,6 @@ function tripal_core_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
   );
-  /**
-  $items['admin/tripal/schema/custom_tables/list'] = array(
-    'title' => 'List of Custom Tables',
-    'description' => 'Provides a list of all custom tables created by Tripal and allows for editing or removing existing custom tables.',
-    'page callback' => 'tripal_custom_tables_list',
-    'access arguments' => array('administer tripal'),
-    'type' => MENU_NORMAL_ITEM,
-    'weight' => -10
-  );
-  */
   $items['admin/tripal/schema/custom_tables/view/%'] = array(
     'title' => 'Custom Tables',
     'description' => 'Custom tables are added to Chado.',
@@ -360,11 +340,11 @@ function tripal_core_menu() {
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/schema/custom_tables/action/%/%'] = array(
+  $items['admin/tripal/schema/custom_tables/delete/%'] = array(
     'title' => 'Create Custom Table',
     'description' => 'Custom tables are added to Chado.',
-    'page callback' => 'tripal_custom_tables_action',
-    'page arguments' => array(4, 5, "1"),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_custom_tables_delete_form', 5),
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );

+ 5 - 5
tripal_core/tripal_core.views_default.inc

@@ -385,7 +385,7 @@ function tripal_core_admin_defaultview_custom_tables() {
   $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'Delete';
   $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/schema/custom_tables/action/delete/[table_id]';
+  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/schema/custom_tables/delete/[table_id]';
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_2']['id'] = 'nothing_2';
   $handler->display->display_options['fields']['nothing_2']['table'] = 'views';
@@ -594,7 +594,7 @@ function tripal_core_admin_defaultview_mviews() {
   $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'Delete';
   $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/schema/mviews/action/delete/[mview_id]';
+  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/schema/mviews/delete/[mview_id]';
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_2']['id'] = 'nothing_2';
   $handler->display->display_options['fields']['nothing_2']['table'] = 'views';
@@ -603,7 +603,7 @@ function tripal_core_admin_defaultview_mviews() {
   $handler->display->display_options['fields']['nothing_2']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_2']['alter']['text'] = 'Populate';
   $handler->display->display_options['fields']['nothing_2']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_2']['alter']['path'] = 'admin/tripal/schema/mviews/action/update/[mview_id]';
+  $handler->display->display_options['fields']['nothing_2']['alter']['path'] = 'admin/tripal/schema/mviews/update/[mview_id]';
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_3']['id'] = 'nothing_3';
   $handler->display->display_options['fields']['nothing_3']['table'] = 'views';
@@ -636,7 +636,7 @@ function tripal_core_admin_defaultview_mviews() {
   $handler->display->display_options['filters']['mv_table']['group'] = 1;
   $handler->display->display_options['filters']['mv_table']['exposed'] = TRUE;
   $handler->display->display_options['filters']['mv_table']['expose']['operator_id'] = 'mv_table_op';
-  $handler->display->display_options['filters']['mv_table']['expose']['label'] = 'Database Table';
+  $handler->display->display_options['filters']['mv_table']['expose']['label'] = 'Table Name';
   $handler->display->display_options['filters']['mv_table']['expose']['operator'] = 'mv_table_op';
   $handler->display->display_options['filters']['mv_table']['expose']['identifier'] = 'mv_table';
   $handler->display->display_options['filters']['mv_table']['expose']['remember_roles'] = array(
@@ -651,7 +651,7 @@ function tripal_core_admin_defaultview_mviews() {
   $handler->display->display_options['filters']['modulename']['group'] = 1;
   $handler->display->display_options['filters']['modulename']['exposed'] = TRUE;
   $handler->display->display_options['filters']['modulename']['expose']['operator_id'] = 'modulename_op';
-  $handler->display->display_options['filters']['modulename']['expose']['label'] = 'Module Created by';
+  $handler->display->display_options['filters']['modulename']['expose']['label'] = 'Module';
   $handler->display->display_options['filters']['modulename']['expose']['operator'] = 'modulename_op';
   $handler->display->display_options['filters']['modulename']['expose']['identifier'] = 'modulename';
   $handler->display->display_options['filters']['modulename']['expose']['remember_roles'] = array(