01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/tool/src/java/org/theospi/portfolio/matrix/control/ReviewPostProcessor.java $
03: * $Id: ReviewPostProcessor.java 29139 2007-04-18 23:27:24Z ajpoland@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.matrix.control;
21:
22: import java.util.Arrays;
23: import java.util.Collections;
24: import java.util.HashMap;
25: import java.util.List;
26: import java.util.Map;
27: import java.util.Set;
28:
29: import org.sakaiproject.component.cover.ComponentManager;
30: import org.sakaiproject.metaobj.shared.mgt.IdManager;
31: import org.sakaiproject.metaobj.shared.model.Id;
32: import org.sakaiproject.metaobj.utils.mvc.intf.Controller;
33: import org.springframework.validation.Errors;
34: import org.springframework.web.servlet.ModelAndView;
35: import org.theospi.portfolio.review.ReviewHelper;
36: import org.theospi.portfolio.shared.mgt.WorkflowEnabledManager;
37: import org.theospi.portfolio.workflow.model.Workflow;
38:
39: public class ReviewPostProcessor implements Controller {
40:
41: private IdManager idManager = null;
42:
43: public ModelAndView handleRequest(Object requestModel, Map request,
44: Map session, Map application, Errors errors) {
45: Map<String, Object> model = new HashMap<String, Object>();
46: String strId = (String) request.get("workflowId");
47: Id objId = idManager.getId((String) request.get("objId"));
48: String view = "success";
49: if (strId != null) {
50: Id id = idManager.getId(strId);
51: String manager = (String) request.get("manager");
52: getWorkflowEnabledManager(manager).processWorkflow(id,
53: objId);
54: model.put("page_id", objId);
55: } else {
56: Set workflows = (Set) session
57: .get(ReviewHelper.REVIEW_POST_PROCESSOR_WORKFLOWS);
58: List wfList = Arrays.asList(workflows.toArray());
59: Collections.sort(wfList, Workflow.getComparator());
60:
61: model.put("workflows", wfList);
62: model.put("obj_id", objId);
63: model.put("manager", request.get("manager"));
64: view = "enter";
65: }
66: return new ModelAndView(view, model);
67: }
68:
69: /**
70: * @return Returns the idManager.
71: */
72: public IdManager getIdManager() {
73: return idManager;
74: }
75:
76: /**
77: * @param idManager The idManager to set.
78: */
79: public void setIdManager(IdManager idManager) {
80: this .idManager = idManager;
81: }
82:
83: protected WorkflowEnabledManager getWorkflowEnabledManager(
84: String name) {
85: return (WorkflowEnabledManager) ComponentManager.get(name);
86: }
87:
88: }
|