Added ability to delete a task; modified scripts to share standard error
messages. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1034 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TaskRepository.java,v 1.4 2002/11/12 22:32:02 mdb Exp $
|
||||
// $Id: TaskRepository.java,v 1.5 2003/01/23 21:22:56 mdb Exp $
|
||||
|
||||
package com.samskivert.twodue.data;
|
||||
|
||||
@@ -249,6 +249,33 @@ public class TaskRepository extends JORARepository
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified task.
|
||||
*/
|
||||
public void deleteTask (final int taskId)
|
||||
throws PersistenceException
|
||||
{
|
||||
execute(new Operation () {
|
||||
public Object invoke (Connection conn, DatabaseLiaison liaison)
|
||||
throws PersistenceException, SQLException
|
||||
{
|
||||
String query = "delete from TASKS where TASK_ID = ?";
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try {
|
||||
stmt = conn.prepareStatement(query);
|
||||
stmt.setInt(1, taskId);
|
||||
JDBCUtil.checkedUpdate(stmt, 1);
|
||||
|
||||
} finally {
|
||||
JDBCUtil.close(stmt);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a task that was previously loaded from the repository.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: detail.java,v 1.1 2002/11/08 21:49:17 mdb Exp $
|
||||
// $Id: detail.java,v 1.2 2003/01/23 21:22:56 mdb Exp $
|
||||
|
||||
package com.samskivert.twodue.logic;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class detail extends UserLogic
|
||||
// load up the task in question
|
||||
Task task = app.getRepository().loadTask(taskId);
|
||||
if (task == null) {
|
||||
ctx.put("error", "task.error.no_such_task");
|
||||
ctx.put("error", "error.no_such_task");
|
||||
} else {
|
||||
// format the notes and stuff those in the context
|
||||
ctx.put("notes", formatNotes(task.notes));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: edit.java,v 1.1 2002/11/08 21:49:17 mdb Exp $
|
||||
// $Id: edit.java,v 1.2 2003/01/23 21:22:56 mdb Exp $
|
||||
|
||||
package com.samskivert.twodue.logic;
|
||||
|
||||
@@ -36,12 +36,13 @@ public class edit extends UserLogic
|
||||
// load up the task in question
|
||||
Task task = app.getRepository().loadTask(taskId);
|
||||
if (task == null) {
|
||||
ctx.put("error", "edit.error.no_such_task");
|
||||
} else {
|
||||
// stick the task in the context
|
||||
ctx.put("task", task);
|
||||
ctx.put("error", "error.no_such_task");
|
||||
return;
|
||||
}
|
||||
|
||||
// stick the task in the context
|
||||
ctx.put("task", task);
|
||||
|
||||
// if they've submitted the form, we update the task database
|
||||
if (ParameterUtil.parameterEquals(
|
||||
ctx.getRequest(), "action", "update")) {
|
||||
@@ -72,6 +73,12 @@ public class edit extends UserLogic
|
||||
app.getRepository().updateTask(task);
|
||||
ctx.put("error", "edit.message.task_updated");
|
||||
|
||||
} else if (ParameterUtil.parameterEquals(
|
||||
ctx.getRequest(), "action", "delete")) {
|
||||
app.getRepository().deleteTask(taskId);
|
||||
ctx.put("error", "edit.message.task_deleted");
|
||||
ctx.remove("task"); // clear out the task
|
||||
|
||||
} else if (ParameterUtil.parameterEquals(
|
||||
ctx.getRequest(), "action", "reopen")) {
|
||||
// clear out the completor and completion dates
|
||||
|
||||
Reference in New Issue
Block a user