01: /*
02: * Copyright (c) 2006 Your Corporation. All Rights Reserved.
03: */
04:
05: package com.technoetic.xplanner.actions;
06:
07: import java.util.ArrayList;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10:
11: import org.apache.struts.action.ActionForm;
12: import org.apache.struts.action.ActionForward;
13: import org.apache.struts.action.ActionMapping;
14:
15: import com.technoetic.xplanner.forms.ReorderStoriesForm;
16:
17: /**
18: * Created by IntelliJ IDEA.
19: * User: SG0897500
20: * Date: Mar 6, 2006
21: * Time: 11:55:25 AM
22: * To change this template use File | Settings | File Templates.
23: */
24: public class ReorderStoriesAction extends AbstractAction {
25:
26: protected ActionForward doExecute(ActionMapping actionMapping,
27: ActionForm actionForm, HttpServletRequest request,
28: HttpServletResponse reply) throws Exception {
29:
30: ReorderStoriesForm form = (ReorderStoriesForm) actionForm;
31:
32: getIteration(Integer.parseInt(form.getIterationId()))
33: .modifyStoryOrder(buildStoryIdNewOrderArray(form));
34:
35: ActionForward actionForward = actionMapping.getInputForward();
36: actionForward.setPath(actionForward.getPath() + "?oid="
37: + form.getIterationId());
38: actionForward.setRedirect(true);
39: return actionForward;
40:
41: }
42:
43: private int[][] buildStoryIdNewOrderArray(ReorderStoriesForm form) {
44: ArrayList storyIds = form.getStoryIds();
45: ArrayList orderNos = form.getOrderNos();
46: int[][] storyIdAndNewOrder = new int[storyIds.size()][2];
47: for (int index = 0; index < storyIdAndNewOrder.length; index++) {
48: storyIdAndNewOrder[index][0] = Integer.parseInt(storyIds
49: .get(index).toString());
50: storyIdAndNewOrder[index][1] = (int) Double
51: .parseDouble(orderNos.get(index).toString());
52: }
53: return storyIdAndNewOrder;
54: }
55:
56: }
|