diff --git a/runtime/twodue/src/java/com/samskivert/twodue/data/Task.java b/runtime/twodue/src/java/com/samskivert/twodue/data/Task.java
index 67080992..dbd18222 100644
--- a/runtime/twodue/src/java/com/samskivert/twodue/data/Task.java
+++ b/runtime/twodue/src/java/com/samskivert/twodue/data/Task.java
@@ -1,16 +1,27 @@
//
-// $Id: Task.java,v 1.4 2002/11/09 02:11:22 mdb Exp $
+// $Id: Task.java,v 1.5 2002/11/12 22:32:02 mdb Exp $
package com.samskivert.twodue.data;
-import java.util.ArrayList;
import java.sql.Date;
+import java.util.ArrayList;
+
+import com.samskivert.util.StringUtil;
/**
* Contains the basic data associated with a task.
*/
public class Task
{
+ public static final String[] COMPLEXITIES = {
+ "Simple hack", "Minor feature", "Major feature",
+ "Subsystem", "Major refactor",
+ };
+
+ public static final int[] COMPLEXITY_VALUES = {
+ 5, 10, 15, 20, 25,
+ };
+
public int taskId;
public String summary;
@@ -33,16 +44,42 @@ public class Task
public String notes;
+ /**
+ * Converts numerical priority to a string.
+ */
public String getPriorityName ()
{
- switch (priority) {
- case 50: return "Urgent";
- case 25: return "Next release";
- case 15: return "Soon";
- case 10: return "Before launch";
- case 5: return "Post launch";
- case 1: return "On the list";
- default: return "Unknown";
+ if (priority > 25) {
+ return "Urgent";
+ } else if (priority > 15) {
+ return "Next release";
+ } else if (priority > 10) {
+ return "Soon";
+ } else if (priority > 5) {
+ return "Before launch";
+ } else if (priority > 1) {
+ return "Post launch";
+ } else {
+ return "On the list";
}
}
+
+ /**
+ * Converts string complexity to a value, lower meaning less complex,
+ * higher meaning more complex.
+ */
+ public int getComplexityValue ()
+ {
+ for (int ii = 0; ii < COMPLEXITIES.length; ii++) {
+ if (COMPLEXITIES[ii].equals(complexity)) {
+ return COMPLEXITY_VALUES[ii];
+ }
+ }
+ return 50;
+ }
+
+ public String getDisplayCategory ()
+ {
+ return StringUtil.replace(category, ",", "
");
+ }
}
diff --git a/runtime/twodue/src/java/com/samskivert/twodue/data/TaskRepository.java b/runtime/twodue/src/java/com/samskivert/twodue/data/TaskRepository.java
index 6cb1f12d..826cc8a6 100644
--- a/runtime/twodue/src/java/com/samskivert/twodue/data/TaskRepository.java
+++ b/runtime/twodue/src/java/com/samskivert/twodue/data/TaskRepository.java
@@ -1,5 +1,5 @@
//
-// $Id: TaskRepository.java,v 1.3 2002/11/09 01:40:01 mdb Exp $
+// $Id: TaskRepository.java,v 1.4 2002/11/12 22:32:02 mdb Exp $
package com.samskivert.twodue.data;
@@ -126,27 +126,24 @@ public class TaskRepository extends JORARepository
}
/**
- * Loads up and returns all unowned, uncompleted tasks, ordered by
- * priority.
+ * Loads up and returns all unowned, uncompleted tasks.
*/
public ArrayList loadTasks ()
throws PersistenceException
{
- return loadTasks("where COMPLETOR IS NULL AND OWNER IS NULL " +
- "ORDER BY PRIORITY DESC");
+ return loadTasks("where COMPLETOR IS NULL AND OWNER IS NULL");
}
/**
* Loads up and returns all unowned, uncompleted tasks, whose summary
- * or category contain the specified string, ordered by priority.
+ * or category contain the specified string.
*/
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");
+ "%' OR CATEGORY LIKE '%" + query + "%')");
}
/**
diff --git a/runtime/twodue/src/java/com/samskivert/twodue/logic/index.java b/runtime/twodue/src/java/com/samskivert/twodue/logic/index.java
index 83604ad0..ff2701aa 100644
--- a/runtime/twodue/src/java/com/samskivert/twodue/logic/index.java
+++ b/runtime/twodue/src/java/com/samskivert/twodue/logic/index.java
@@ -1,14 +1,15 @@
//
-// $Id: index.java,v 1.3 2002/11/09 01:40:01 mdb Exp $
+// $Id: index.java,v 1.4 2002/11/12 22:32:02 mdb Exp $
package com.samskivert.twodue.logic;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
-import com.samskivert.util.QuickSort;
import com.samskivert.util.StringUtil;
import com.samskivert.servlet.RedirectException;
@@ -89,6 +90,8 @@ public class index extends UserLogic
// load up outstanding tasks and break them down by complexity
String expand = ParameterUtil.getParameter(req, "expand", false);
+ ctx.put("expand", expand);
+
ArrayList tasks = null;
String query = ParameterUtil.getParameter(req, "query", false);
if (StringUtil.blank(query)) {
@@ -98,9 +101,12 @@ public class index extends UserLogic
tasks = app.getRepository().findTasks(query);
}
+ // sort the tasks by priority, then complexity
+ Collections.sort(tasks, PLEX_PARATOR);
+
CatList[] xtasks = categorize(tasks, expand, new Categorizer() {
public String category (Task task) {
- return task.complexity;
+ return task.getPriorityName();
}
});
ctx.put("xtasks", xtasks);
@@ -111,6 +117,7 @@ public class index extends UserLogic
// load up owned tasks and break them down by owner
tasks = app.getRepository().loadOwnedTasks();
+ Collections.sort(tasks, PLEX_PARATOR);
CatList[] otasks = categorize(tasks, null, new Categorizer() {
public String category (Task task) {
return task.owner;
@@ -147,6 +154,7 @@ public class index extends UserLogic
return new CatList[0];
}
+ ArrayList cats = new ArrayList();
HashMap cmap = new HashMap();
int tcount = tasks.size();
for (int ii = 0; ii < tcount; ii++) {
@@ -157,23 +165,34 @@ public class index extends UserLogic
clist = new CatList();
clist.name = category;
clist.tasks = new ArrayList();
+ cats.add(clist);
cmap.put(category, clist);
}
if (expand == null || clist.tasks.size() < 2 ||
- expand.equals("all") || expand.equals(category)) {
+ expand.equals("all") ||
+ (task.priority > 15) || expand.equals(category)) {
clist.tasks.add(task);
} else {
clist.pruned++;
}
}
- CatList[] ctasks = new CatList[cmap.size()];
- Iterator iter = cmap.values().iterator();
- for (int ii = 0; iter.hasNext(); ii++) {
- ctasks[ii] = (CatList)iter.next();
- }
- QuickSort.sort(ctasks);
+ CatList[] ctasks = new CatList[cats.size()];
+ cats.toArray(ctasks);
return ctasks;
}
+
+ // sorts tasks by relative complexity, simplest to most complex
+ protected static final Comparator PLEX_PARATOR = new Comparator() {
+ public int compare (Object o1, Object o2) {
+ Task t1 = (Task)o1, t2 = (Task)o2;
+ // sort first by reverse priority, then by complexity
+ if (t1.priority == t2.priority) {
+ return t1.getComplexityValue() - t2.getComplexityValue();
+ } else {
+ return t2.priority - t1.priority;
+ }
+ }
+ };
}
diff --git a/runtime/twodue/web/index.wm b/runtime/twodue/web/index.wm
index d96bf8ae..f45e2d4f 100644
--- a/runtime/twodue/web/index.wm
+++ b/runtime/twodue/web/index.wm
@@ -11,6 +11,11 @@
Tasks matching '$query':
#else
Outstanding tasks:
+#if ($expand == "all")
+[trim]
+#else
+[show all]
+#end
#end
@@ -40,7 +45,7 @@ $form.imageSubmit("submit", "", "images/complete.png", "Mark as completed")
#end
