%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %>
<%@ page import="org.crosswire.utils.Sessions" %>
<%@ page import="org.apache.log4j.Logger" %>
<%@ page import="org.crosswire.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="org.crosswire.webtools.*" %>
<%!
@Description(value = "Retrieve task details.", name = "task/get")
public static class MyParameters extends Parameters {
@Description(value = "project id of task", example = "2", defaultValue = "")
public Integer projectID;
@Description(value = "typically a manuscript id to be assigned", example = "10046")
public Integer objectID;
@Description(value = "type of task; 1 - imaging; 2 - indexing; 3 - transcribing", example = "3")
public Integer taskTypeID;
@Description(value = "id of task to retrieve", example = "31123")
public Integer taskID;
@Description(value = "which user is assign to this task; 'none' for simply computing the progress details", defaultValue = "none", example = "joe")
public String assignedTo;
@Description(value = "progressively more detail: [header,progress]", defaultValue = "header", example = "progress")
public String detail;
@Description(value = "show usage for this web service", defaultValue = "false", example = "true")
public Boolean usage = false;
@Override
protected void afterLoad() {
assignedTo = Transcription.assureUnicode(assignedTo);
if (assignedTo == null) {
assignedTo = getUser() != null ? getUser().getUserName() : null;
}
if ("all".equals(assignedTo)) {
assignedTo = null;
}
}
@Override
protected void customValidation() {
if (projectID == null && objectID == null && taskTypeID == null && assignedTo == null && taskID == null) {
addError(-4, "Must supply at least one of {projectID}, {objectID}, {taskTypeID}, {assignedTo}, or {taskID}.");
return;
}
if (getUser() == null) {
addError(-5, "Must be logged in.");
return;
}
}
}
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response, false);
if (params.getErrors().size() == 0 && !params.usage) {
int detail = 1;
if ("progress".equals(params.detail)) detail = 6;
StringBuffer retVal = new StringBuffer();
retVal.append(
""
);
ProjectManagement.Task tasks[] = new ProjectManagement.Task[0];
if (!"none".equals(params.assignedTo)) {
//params.getLogger().info("Calling: ProjectManagement.getTasks(taskID: " + params.taskID + ", projectID: " + params.projectID + ", assignedTo: " + params.assignedTo + ", objectID: " + params.objectID + ", taskTypeID: " + params.taskTypeID + ", detail > 1: " + (detail > 1));
// special handling for global indexing tasks; TODO: remove hack
/*
if (params.taskID == null && params.projectID == null && request.getParameter("assignedTo") == null && params.objectID == null && params.taskTypeID == 2)
tasks = ProjectManagement.getIndexingStatus();
else
*/
tasks = ProjectManagement.getTasks(params.taskID, params.projectID, params.assignedTo, params.objectID, params.taskTypeID, detail > 1);
}
else {
ProjectManagement.Project p = ProjectManagement.getProject(params.projectID);
tasks = new ProjectManagement.Task[1];
tasks[0] = new ProjectManagement.Task(0, params.projectID, params.objectID, params.taskTypeID, "", p.getObjectPart(), 0);
ProjectManagement.computeAssignment(tasks[0]);
}
for (ProjectManagement.Task t : tasks) {
retVal.append(t.toFormattedXML());
}
retVal.append("");
Serializer.output(response, out, params, XMLBlock.createXMLBlock(retVal.toString()));
return;
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>