Rev 1945 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1626 | jmachado | 1 | package pt.estgp.estgweb.web.controllers.courses; |
2 | |||
1670 | jmachado | 3 | import org.apache.struts.action.ActionForm; |
4 | import org.json.JSONObject; |
||
5 | import pt.estgp.estgweb.domain.CourseDepartmentImpl; |
||
1626 | jmachado | 6 | import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController; |
1670 | jmachado | 7 | import pt.estgp.estgweb.web.utils.RequestUtils; |
8 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
9 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
1626 | jmachado | 10 | |
1670 | jmachado | 11 | import javax.servlet.http.HttpServletRequest; |
12 | import javax.servlet.http.HttpServletResponse; |
||
13 | |||
1626 | jmachado | 14 | /** |
15 | * Created by jorgemachado on 21/01/17. |
||
16 | */ |
||
17 | public class CourseDepartmentController extends AbstractWidgetAjaxController |
||
18 | { |
||
1814 | jmachado | 19 | |
20 | //TODO manter a sigla antiga e colocar um campo para uma nova no json |
||
1670 | jmachado | 21 | public JSONObject updateCourseDepartment(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
22 | 1.5.0/docs/api/java/lang/String.html">String courseDepartmentJson = request.getParameter("courseDepartmentJson"); |
||
1626 | jmachado | 23 | |
1670 | jmachado | 24 | |
25 | IServiceManager sm = ServiceManager.getInstance(); |
||
26 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
27 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{courseDepartmentJson}; |
||
28 | CourseDepartmentImpl d = (CourseDepartmentImpl) sm.execute(RequestUtils.getRequester(request, response), "UpdateCourseDepartment", args, names); |
||
1779 | jmachado | 29 | JSONObject tJson = d.toJsonObject(); |
1670 | jmachado | 30 | addMessage(request,"course.update.department.success",d.getName()); |
31 | return tJson; |
||
32 | } |
||
33 | |||
34 | public JSONObject removeCourseDepartment(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
35 | 1.5.0/docs/api/java/lang/String.html">String courseDepartmentJson = request.getParameter("courseDepartmentJson"); |
||
36 | |||
37 | |||
38 | IServiceManager sm = ServiceManager.getInstance(); |
||
39 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
40 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{courseDepartmentJson}; |
||
41 | CourseDepartmentImpl d = (CourseDepartmentImpl) sm.execute(RequestUtils.getRequester(request, response), "RemoveCourseDepartment", args, names); |
||
1779 | jmachado | 42 | JSONObject tJson = d.toJsonObject(); |
1670 | jmachado | 43 | addMessage(request, "course.removed.department.success", d.getName()); |
44 | return tJson; |
||
45 | } |
||
46 | |||
47 | public JSONObject newCourseDepartment(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
48 | |||
49 | IServiceManager sm = ServiceManager.getInstance(); |
||
50 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
51 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{}; |
||
52 | CourseDepartmentImpl d = (CourseDepartmentImpl) sm.execute(RequestUtils.getRequester(request, response), "NewCourseDepartment", args, names); |
||
1779 | jmachado | 53 | JSONObject tJson = d.toJsonObject(); |
1670 | jmachado | 54 | addMessage(request,"course.new.department.success",d.getName()); |
55 | return tJson; |
||
56 | } |
||
1626 | jmachado | 57 | } |