01: package com.technoetic.xplanner.actions;
02:
03: import javax.servlet.http.HttpServletRequest;
04: import javax.servlet.http.HttpServletResponse;
05:
06: import org.apache.struts.action.ActionForm;
07: import org.apache.struts.action.ActionForward;
08: import org.apache.struts.action.ActionMapping;
09:
10: import com.technoetic.xplanner.domain.Iteration;
11: import com.technoetic.xplanner.domain.UserStory;
12: import com.technoetic.xplanner.domain.repository.RepositoryException;
13: import com.technoetic.xplanner.forms.TaskEditorForm;
14:
15: public class EditTaskAction extends EditObjectAction {
16:
17: protected ActionForward doExecute(ActionMapping actionMapping,
18: ActionForm actionForm, HttpServletRequest request,
19: HttpServletResponse reply) throws Exception {
20: TaskEditorForm form = (TaskEditorForm) actionForm;
21: ActionForward forward = super .doExecute(actionMapping,
22: actionForm, request, reply);
23: setTaskDisposition(form, request);
24: return forward;
25: }
26:
27: private void setTaskDisposition(TaskEditorForm form,
28: HttpServletRequest request) throws RepositoryException {
29: if (!form.isSubmitted()) {
30: String oid = form.getOid();
31: if (oid == null) {
32: int storyId = Integer.parseInt(request
33: .getParameter("fkey"));
34: UserStory story = (UserStory) getRepository(
35: UserStory.class).load(storyId);
36: form.setDispositionName(getTaskDisposition(story));
37: }
38: }
39: }
40:
41: private String getTaskDisposition(UserStory story)
42: throws RepositoryException {
43: Iteration iteration = (Iteration) getRepository(Iteration.class)
44: .load(story.getIterationId());
45: return iteration.getNewTaskDispositionName(story);
46: }
47:
48: }
|