%@ page import="org.w3c.dom.Node "%>
<%@ page import="org.crosswire.xml.XMLRepo"%>
<%@ page import="org.crosswire.xml.XMLBlock"%>
<%@ page import="org.crosswire.xml.XMLObject"%>
<%@ page import="org.crosswire.xml.XMLMetaData"%>
<%@ page import="org.crosswire.community.data.User"%>
<%@ page import="org.crosswire.community.data.Project"%>
<%@ page import="org.crosswire.community.Task"%>
<%!
public static class Tasks extends XMLObject {
public Tasks(XMLObject other) {
super(other);
init();
}
public Tasks() {
super(XMLBlock.createXMLBlock(""));
init();
}
public Tasks(String id) {
super(XMLBlock.createXMLBlock(""));
setID(id);
init();
}
private void init() {
setKey(XMLMetaData.TYPE, "projects");
setKey(XMLMetaData.KEY1, getID());
}
public void setID(String id) {
setAttribute("oid", id);
setKey(XMLMetaData.KEY1, id);
}
public String getID() {
return getAttribute("oid");
}
public static class Task extends XMLBlock {
public Task(Node node) {
super(node);
}
public XMLBlock[] getSubTasks() {
return getBlocks("SubTask");
}
public String getTaskName() { return getAttribute("name"); }
public void setTaskName(String name) { setAttribute("name", name); }
}
public Task[] getTasks() {
return (Task[])getBlocks("Task", Task.class);
}
public Task getTask(String name) {
for (Task p : getTasks()) {
if (p.getTaskName().equals(name)) return p;
}
return null;
}
public Task addTask(String name) {
Task t = getTask(name);
if (t == null) {
t = new Task(createBlock("Task").getNode());
t.setTaskName(name);
}
return t;
}
}
public static class ITSEETask extends org.crosswire.community.Task {
private static final int INITIAL_TRANSCRIPTION_1 = 0;
private static final int INITIAL_TRANSCRIPTION_2 = 1;
private static final int RECONCILED_TRANSCRIPTION = 2;
Tasks.Task taskBlock = null;
String root = null;
public ITSEETask(Tasks.Task taskBlock, String root) {
super(lookupDocName(taskBlock));
this.taskBlock = taskBlock;
this.root = root;
}
// ITSEE has 3 required subtasks to complete a task
public int getTaskPartCount() { return 3; }
public String getTaskPartDescription(int taskPartNum) {
switch (taskPartNum) {
case INITIAL_TRANSCRIPTION_1:
return "Output 1";
case INITIAL_TRANSCRIPTION_2:
return "Output 2";
case RECONCILED_TRANSCRIPTION:
return "Reconciled Transcription";
}
return "strange things are afoot at the (K)";
}
public String getAssignee() { return ""; }
public String getHeading() { return "Manuscript"; }
public String getPartHeading() { return "Task"; }
public String [] getAddHeadings() { return new String[] {
"Images", "Difficulty", "Difficulty Notes", "Coll/Transc", "Validated File", "Page Layout", "Edition", "Notes" }; }
public String [] getAddCells() { return new String[] {
"",
"****", "", "", "", "", "",
"" }; }
// TODO: optional tasks submitted, but not required
public String getTaskPartAssignee(int taskPartNum) {
switch (taskPartNum) {
case INITIAL_TRANSCRIPTION_1:
try { return taskBlock.getBlock("SubTask", "n", "1").getAttribute("assignee"); } catch (Exception e) { return null; }
case INITIAL_TRANSCRIPTION_2:
try { return taskBlock.getBlock("SubTask", "n", "2").getAttribute("assignee"); } catch (Exception e) { return null; }
case RECONCILED_TRANSCRIPTION:
try { return taskBlock.getBlock("SubTask", "n", "3").getAttribute("assignee"); } catch (Exception e) { return null; }
}
return "strange things are afoot at the (K)";
}
public float getTaskPartPercentComplete(int taskPartNum) { return 0; }
public String [] getTaskPartAddCells(int taskPartNum) { return new String[] {
"", "", "", (taskPartNum < 2) ? "" : "", "", "", "", "" }; }
private static String lookupDocName(Tasks.Task taskBlock) { return taskBlock.getTaskName(); }
}
%>
<%
String root = session.getServletContext().getContextPath();
XMLRepo repo = XMLRepo.instance(pageContext);
User user = (User)session.getAttribute("user");
Project project = (Project)repo.get(new Project("transcribing"), false);
Tasks tasksStorage = (Tasks)repo.get(new Tasks("transcribing"), false);
Tasks.Task tasksFromDisk[] = tasksStorage.getTasks();
ITSEETask []tasks = new ITSEETask[tasksFromDisk.length];
for (int i = 0; i < tasksFromDisk.length; ++i) {
tasks[i] = new ITSEETask(tasksFromDisk[i], root);
}
%>
<%
boolean shownHeaders = false;
for (Task t: tasks) {
if (!shownHeaders) {
shownHeaders = true;
%>
<%= t.getHeading() %> |
<%= t.getPartHeading() %> |
Progress |
Responsibility |
<%
for (String h: t.getAddHeadings()) {
%>
<%= h %> |
<%
}
%>
<%
}
%>
<%= t.getDescription() %> |
|
<%= t.getPercentComplete() %>% |
<%= (t.getAssignee() == null) ? "-unassigned-" : t.getAssignee() %> |
<%
for (String a: t.getAddCells()) {
%>
<%= a %> |
<%
}
%>
<%
for (int i = 0; i < t.getTaskPartCount(); ++i) {
%>
| <%= t.getTaskPartDescription(i) %> |
<%= (int)t.getTaskPartPercentComplete(i) %>% |
|
<%
for (String a: t.getTaskPartAddCells(i)) {
%>
<%= a %> |
<%
}
%>
<% } %>
<% } %>