1 package com.germinus.merlin.manager;
2
3 import javax.portlet.RenderRequest;
4 import javax.portlet.RenderResponse;
5
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8
9 import com.germinus.merlin.dao.CourseDao;
10 import com.germinus.merlin.model.Course;
11 import com.germinus.merlin.model.Page;
12 import com.germinus.merlin.model.assignment.Assignment;
13 import com.germinus.liferay.util.ILiferayUtil;
14 import com.germinus.merlin.util.PagesUtil;
15
16
17
18
19
20
21
22 public class CourseManager
23 {
24 private ILiferayUtil liferayUtil;
25 private CourseDao courseDao;
26 private Assignment assignment;
27 private PagesUtil pageUtil;
28
29
30
31
32 private static final Log log = LogFactory.getLog(CourseManager.class);
33
34 public CourseManager()
35 {
36 log.debug("-------------Load courses-------------");
37
38 }
39
40
41
42
43
44
45
46 public void setCourse(Course course)
47 {
48 log.debug("Adding course: " + course);
49
50 }
51
52
53
54
55
56
57
58 public void deleteCourse(String id)
59 {
60 log.debug("Removing course: " + id);
61
62 }
63
64
65
66
67 public Assignment getAssignment() {
68 return assignment;
69 }
70
71
72
73
74
75 public void setAssignment(Assignment assignment) {
76 this.assignment = assignment;
77 }
78
79
80
81
82
83
84 public Course getCourse(Long courseId)
85 {
86 return courseDao.get(courseId);
87 }
88
89
90
91
92 public CourseDao getCourseDao() {
93 return courseDao;
94 }
95
96
97
98
99 public void setCourseDao(CourseDao daoCourse) {
100 this.courseDao = daoCourse;
101 }
102
103 public Page loadPageCourse(RenderRequest request, RenderResponse response)
104 {
105 long courseId = liferayUtil.getComunityGroupId(request, response);
106
107 Course course = getCourseDao().get(courseId);
108
109 long tabPlid = liferayUtil.getTabPlid(request, response);
110
111 Page page = pageUtil.getPage(course, tabPlid);
112
113 page.setBlogPageUrl(pageUtil.getBlogPage(page, request, response));
114
115 page.setForumPageUrl(pageUtil.getForumPage(page, request, response));
116
117 page.setDocumentPageUrl(pageUtil.getDocumentPage(page, request, response));
118
119 if (!pageUtil.pageAdded(course, tabPlid))
120 {
121 if (!pageUtil.urlPageEmpty(page))
122 {
123 course.getPages().add(page);
124
125 getCourseDao().save(course);
126 }
127 }
128 return page;
129 }
130
131
132
133
134 public ILiferayUtil getLiferayUtil() {
135 return liferayUtil;
136 }
137
138
139
140
141 public void setLiferayUtil(ILiferayUtil liferayUtil) {
142 this.liferayUtil = liferayUtil;
143 }
144
145
146
147
148 public PagesUtil getPageUtil() {
149 return pageUtil;
150 }
151
152
153
154
155 public void setPageUtil(PagesUtil pageUtil) {
156 this.pageUtil = pageUtil;
157 }
158 }