Added support for simple queries.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@903 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-11-09 01:40:01 +00:00
parent 9d4b641278
commit ee37ff3a93
4 changed files with 53 additions and 8 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
# -*- mode: makefile -*-
#
# $Id: messages.properties,v 1.2 2002/11/08 21:49:17 mdb Exp $
# $Id: messages.properties,v 1.3 2002/11/09 01:40:01 mdb Exp $
#
# Translation messages for Two Due application
@@ -42,6 +42,7 @@ index.message.task_claimed = Task claimed.
index.message.task_completed = Task marked as completed.
index.error.invalid_detail_task = Task id specified for inspection not valid.
index.error.no_matching_tasks = No tasks matched that query string.
#
# edit.wm
@@ -1,5 +1,5 @@
//
// $Id: TaskRepository.java,v 1.2 2002/11/08 21:49:17 mdb Exp $
// $Id: TaskRepository.java,v 1.3 2002/11/09 01:40:01 mdb Exp $
package com.samskivert.twodue.data;
@@ -136,6 +136,19 @@ public class TaskRepository extends JORARepository
"ORDER BY PRIORITY DESC");
}
/**
* Loads up and returns all unowned, uncompleted tasks, whose summary
* or category contain the specified string, ordered by priority.
*/
public ArrayList findTasks (String query)
throws PersistenceException
{
return loadTasks("where COMPLETOR IS NULL AND OWNER IS NULL " +
" AND (SUMMARY LIKE '%" + query +
"%' OR CATEGORY LIKE '%" + query + "%') " +
"ORDER BY PRIORITY DESC");
}
/**
* Loads up all owned tasks, ordered by priority.
*/
@@ -1,5 +1,5 @@
//
// $Id: index.java,v 1.2 2002/11/08 21:49:17 mdb Exp $
// $Id: index.java,v 1.3 2002/11/09 01:40:01 mdb Exp $
package com.samskivert.twodue.logic;
@@ -89,7 +89,15 @@ public class index extends UserLogic
// load up outstanding tasks and break them down by complexity
String expand = ParameterUtil.getParameter(req, "expand", false);
ArrayList tasks = app.getRepository().loadTasks();
ArrayList tasks = null;
String query = ParameterUtil.getParameter(req, "query", false);
if (StringUtil.blank(query)) {
tasks = app.getRepository().loadTasks();
} else {
ctx.put("query", query);
tasks = app.getRepository().findTasks(query);
}
CatList[] xtasks = categorize(tasks, expand, new Categorizer() {
public String category (Task task) {
return task.complexity;
@@ -97,6 +105,10 @@ public class index extends UserLogic
});
ctx.put("xtasks", xtasks);
if (!StringUtil.blank(query) && xtasks.length == 0) {
ctx.put("error", "index.error.no_matching_tasks");
}
// load up owned tasks and break them down by owner
tasks = app.getRepository().loadOwnedTasks();
CatList[] otasks = categorize(tasks, null, new Categorizer() {
@@ -131,6 +143,10 @@ public class index extends UserLogic
protected CatList[] categorize (
ArrayList tasks, String expand, Categorizer catter)
{
if (tasks == null) {
return new CatList[0];
}
HashMap cmap = new HashMap();
int tcount = tasks.size();
for (int ii = 0; ii < tcount; ii++) {
@@ -144,7 +160,7 @@ public class index extends UserLogic
cmap.put(category, clist);
}
if (expand == null || clist.tasks.size() < 2 ||
(expand.equals(category))) {
expand.equals("all") || expand.equals(category)) {
clist.tasks.add(task);
} else {
clist.pruned++;
+18 -3
View File
@@ -6,7 +6,13 @@
<table cellpadding="0" cellspacing="15" border="0">
<tr><td width="50%"><b>Owned tasks:</b></td>
<td width="50%"><b>Outstanding tasks:</b></td></tr>
<td width="50%"><b>
#if ($query)
Tasks matching '$query':
#else
Outstanding tasks:
#end
</b></td></tr>
<tr><td valign="top">
<table cellpadding="2" cellspacing="0" border="0" width="100%">
@@ -94,8 +100,17 @@ $form.fixedHidden("task", "$task.taskId")
#end
</table>
<p>
<center class="small">Click the wrench to claim a task.</center>
<p align="center">
<table width="100%">
<tr><td class="small" valign="top">Click the wrench to claim a task.</td>
<td class="small"><form action="index.wm">
Filter on single word:<br>
<input name="query" size="10">
</form>
</center>
</td></tr>
</table>
</td></tr>