View Javadoc

1   package com.germinus.merlin.controller.assignments;
2   
3   import java.util.Map;
4   
5   import javax.portlet.ActionRequest;
6   import javax.portlet.ActionResponse;
7   import javax.portlet.RenderRequest;
8   import javax.portlet.RenderResponse;
9   
10  import org.apache.commons.logging.Log;
11  import org.apache.commons.logging.LogFactory;
12  import org.springframework.beans.factory.InitializingBean;
13  import org.springframework.web.portlet.ModelAndView;
14  import org.springframework.web.portlet.mvc.AbstractController;
15  
16  import com.germinus.liferay.util.ILiferayUtil;
17  import com.germinus.merlin.manager.AssignmentManager;
18  import com.germinus.merlin.manager.CourseManager;
19  import com.germinus.merlin.model.Course;
20  import com.germinus.merlin.util.IMerlinUtil;
21  import com.liferay.portal.kernel.dao.search.SearchContainer;
22  /**
23   * 
24   * 
25   * @author Jesús Rodríguez, Germinus XXI
26   * @version 
27   * @since 1.0
28   */
29  public class AssignmentPermissionsController extends AbstractController implements
30  		InitializingBean {
31  
32  	private ILiferayUtil liferayUtil;
33  	private IMerlinUtil merlinUtil;
34  	
35  	private static final Log log = LogFactory.getLog(AssignmentRemoveController.class);
36  	private AssignmentManager assignmentManager;
37  	
38  	private CourseManager courseManager;
39  
40  	public void afterPropertiesSet() throws Exception {
41  	}
42  
43  	/**
44  	 * @return the assignmentManager
45  	 */
46  	public AssignmentManager getAssignmentManager() {
47  		return assignmentManager;
48  	}
49  
50  	/**
51  	 * @return the courseManager
52  	 */
53  	public CourseManager getCourseManager() {
54  		return courseManager;
55  	}
56  
57  	/**
58  	 * Process the action request. There is nothing to return.
59  	 * @param request
60  	 * @param response
61  	 * @throws Exception
62  	 */
63  	public void handleActionRequestVoid(ActionRequest request,
64  			ActionResponse response) throws Exception {
65  	}
66  
67  	/**
68  	 * Process the render request and return a ModelAndView object which the
69  	 * DispatcherPortlet will render.
70  	 * Get the id of the assignment to be deleted and deleted from the database.
71  	 * When the assignment is deleted its rendered the page of assignments list.
72  	 * @param request
73  	 * @param response
74  	 * @throws Exception
75  	 * @return ModelAndView
76  	 */
77  	@SuppressWarnings("unchecked")
78  	public ModelAndView handleRenderRequestInternal(RenderRequest request,
79  			RenderResponse response) throws Exception {
80  		log.debug("Permissions Controller");
81  		
82  		//get the courseId of the assignment to delete
83  		long courseId = liferayUtil.getComunityGroupId(request, response);
84  		Course course = courseManager.getCourse(courseId);
85  		
86  		//delete the assignment
87  		assignmentManager.changePermissionsAssignment(request,response);
88  		
89  		//create the new searchContainer:
90  		Map<String, SearchContainer> model;
91  		String usertype= merlinUtil.getUserType(request, response, courseId);
92  		model= assignmentManager.listAssignment(request, response, course, usertype);
93  		return new ModelAndView("assignments/listAssignment/teacherAssignmentsList", "model", model);
94  	}
95  
96  	/**
97  	 * @param assignmentManager the assignmentManager to set
98  	 */
99  	public void setAssignmentManager(AssignmentManager assignmentsManagement) {
100 		this.assignmentManager = assignmentsManagement;
101 	}
102 
103 	/**
104 	 * @param courseManager the courseManager to set
105 	 */
106 	public void setCourseManager(CourseManager courseManager) {
107 		this.courseManager = courseManager;
108 	}
109 	
110 	/**
111 	 * @return the liferayUtil
112 	 */
113 	public ILiferayUtil getLiferayUtil() {
114 		return liferayUtil;
115 	}
116 
117 	/**
118 	 * @param liferayUtil the liferayUtil to set
119 	 */
120 	public void setLiferayUtil(ILiferayUtil liferayUtil) {
121 		this.liferayUtil = liferayUtil;
122 	}
123 
124 	/**
125 	 * @return the merlinUtil
126 	 */
127 	public IMerlinUtil getMerlinUtil() {
128 		return merlinUtil;
129 	}
130 
131 	/**
132 	 * @param merlinUtil the merlinUtil to set
133 	 */
134 	public void setMerlinUtil(IMerlinUtil merlinUtil) {
135 		this.merlinUtil = merlinUtil;
136 	}
137 }