Runs the system scheduler to start the scheduling for opening gate and
- * closing gate. It invlovs a couple of steps to start the scheduler:
- *
1. Initialize the resource needed by scheduling job by setting
- * them into the job data map.
- *
- *
2. Create customized triggers for the scheduling.
- *
3. start the scheduling job
- *
- * @param scheduleGate the gate that needs to be scheduled.
- */
- private void runGateScheduler(ScheduleGateActivity scheduleGate)
- {
- //if(log.isDebugEnabled())
- log.info("Running scheduler for gate "+scheduleGate.getActivityId()+"...");
- JobDetail openScheduleGateJob = getOpenScheduleGateJob();
- JobDetail closeScheduleGateJob = getCloseScheduleGateJob();
- //setup the message for scheduling job
- openScheduleGateJob.setName("openGate");
- openScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
- closeScheduleGateJob.setName("closeGate");
- closeScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
- //create customized triggers
- Trigger openGateTrigger = new SimpleTrigger("openGateTrigger",
- Scheduler.DEFAULT_GROUP,
- scheduleGate.getRealGateOpenTime());
- Trigger closeGateTrigger = new SimpleTrigger("closeGateTrigger",
- Scheduler.DEFAULT_GROUP,
- scheduleGate.getRealGateCloseTime());
- //start the scheduling job
- try
- {
- scheduler.scheduleJob(openScheduleGateJob, openGateTrigger);
- scheduler.scheduleJob(closeScheduleGateJob, closeGateTrigger);
- }
- catch (SchedulerException e)
- {
- throw new MonitoringServiceException("Error occurred at " +
- "[runGateScheduler]- fail to start scheduling",e);
- }
- //if(log.isDebugEnabled())
- log.info("Scheduler for Gate "+scheduleGate.getActivityId()+" started...");
- }
-
- /**
* @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#openGate(org.lamsfoundation.lams.learningdesign.GateActivity)
*/
public void openGate(Long gateId)
@@ -367,9 +325,205 @@
// TODO Auto-generated method stub
}
+
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllLessons()
+ */
+ public String getAllLessons() throws IOException{
+ List lessons = lessonDAO.getAllLessons();
+ return requestLessonList(lessons);
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllLessons(java.lang.Integer)
+ */
+ public String getAllLessons(Integer userID)throws IOException{
+ List lessons = lessonDAO.getLessonsForUser(userID);
+ return requestLessonList(lessons);
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLessonDetails(java.lang.Long)
+ */
+ public String getLessonDetails(Long lessonID)throws IOException{
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ if(lesson!=null){
+ flashMessage = new FlashMessage("getLessonDetails",lesson.getLessonDetails());
+ }else
+ flashMessage = new FlashMessage("getLessonDetails",
+ "No such Lesson with a lessonID of :" + lessonID + " exists.",
+ FlashMessage.ERROR);
+ return flashMessage.serializeMessage();
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLessonLearners(java.lang.Long)
+ */
+ public String getLessonLearners(Long lessonID)throws IOException{
+ Vector lessonLearners = new Vector();
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ if(lesson!=null){
+ Iterator iterator = lesson.getLessonClass().getLearners().iterator();
+ while(iterator.hasNext()){
+ User user = (User)iterator.next();
+ lessonLearners.add(user.getUserDTO());
+ }
+ flashMessage = new FlashMessage("getLessonLearners",lessonLearners);
+ }else
+ flashMessage = new FlashMessage("getLessonLearners",
+ "No such lesson with a lesson_id of :"+ lessonID + " exists",
+ FlashMessage.ERROR);
+ return flashMessage.serializeMessage();
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLearningDesignDetails(java.lang.Long)
+ */
+ public String getLearningDesignDetails(Long lessonID)throws IOException{
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ return authoringService.getLearningDesignDetails(lesson.getLearningDesign().getLearningDesignId());
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllLearnersProgress(java.lang.Long)
+ */
+ public String getAllLearnersProgress(Long lessonID)throws IOException {
+ Vector progressData = new Vector();
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ if(lesson!=null){
+ Iterator iterator = lesson.getLearnerProgresses().iterator();
+ while(iterator.hasNext()){
+ LearnerProgress learnerProgress = (LearnerProgress)iterator.next();
+ progressData.add(learnerProgress.getLearnerProgressData());
+ }
+ flashMessage = new FlashMessage("getAllLearnersProgress",progressData);
+ }else{
+ flashMessage = new FlashMessage("getAllLearnersProgress",
+ "No such lesson with a lesson_id of :"+ lessonID + " exists",
+ FlashMessage.ERROR);
+ }
+ return flashMessage.serializeMessage();
+ }
+
+ /**
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityById(long)
+ */
+ public Activity getActivityById(long activityId)
+ {
+ return activityDAO.getActivityByActivityId(new Long(activityId));
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllContributeActivities(java.lang.Long)
+ */
+ public String getAllContributeActivities(Long lessonID)throws IOException{
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ if(lesson!=null){
+ Vector sortedSet = getOrderedActivityTree(lesson.getLearningDesign());
+ flashMessage = new FlashMessage("getAllContributeActivities",sortedSet);
+ }else{
+ flashMessage = new FlashMessage("getAllContributeActivities",
+ "No such lesson with a lesson_id of " + lessonID + "exists",
+ FlashMessage.ERROR);
+ }
+ return flashMessage.serializeMessage();
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLearnerActivityURL(java.lang.Long, java.lang.Integer)
+ */
+ public String getLearnerActivityURL(Long activityID,Integer userID)throws IOException, LamsToolServiceException{
+ Activity activity = activityDAO.getActivityByActivityId(activityID);
+ User user = userDAO.getUserById(userID);
+ if(activity==null || user==null){
+ flashMessage = new FlashMessage("getLearnerActivityURL",
+ "Invalid activityID/User :" + activityID + " : " + userID,
+ FlashMessage.ERROR);
+ }else{
+ if(activity.isToolActivity()){
+ ToolActivity toolActivity = (ToolActivity)activity;
+ String toolURL = lamsCoreToolService.getLearnerToolURLByMode(toolActivity,user,ToolAccessMode.TEACHER);
+ flashMessage = new FlashMessage("getLearnerActivityURL",new ProgressActivityDTO(activityID,toolURL));
+ }else{
+ flashMessage = new FlashMessage("getLearnerActivityURL",
+ "Invalid Activity type: " + activity.getActivityId()+ "\n Only ToolActivity allowed.",
+ FlashMessage.ERROR);
+ }
+ }
+
+ return flashMessage.serializeMessage();
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityContributionURL(java.lang.Long)
+ */
+ public String getActivityContributionURL(Long activityID)throws IOException{
+ Activity activity = activityDAO.getActivityByActivityId(activityID);
+ if(activity!=null){
+ if(activity.isToolActivity()){
+ ToolActivity toolActivity = (ToolActivity)activity;
+ String contributionURL = toolActivity.getTool().getContributeUrl();
+ flashMessage = new FlashMessage("getActivityContributionURL",contributionURL);
+ }
+ }else
+ flashMessage = FlashMessage.getNoSuchActivityExists("getActivityContributionURL",activityID);
+
+ return flashMessage.serializeMessage();
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#moveLesson(java.lang.Long, java.lang.Integer, java.lang.Integer)
+ */
+ public String moveLesson(Long lessonID, Integer targetWorkspaceFolderID,Integer userID)throws IOException{
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ if(lesson!=null){
+ if(lesson.getUser().getUserId().equals(userID)){
+ WorkspaceFolder workspaceFolder = workspaceFolderDAO.getWorkspaceFolderByID(targetWorkspaceFolderID);
+ if(workspaceFolder!=null){
+ LearningDesign learningDesign = lesson.getLearningDesign();
+ learningDesign.setWorkspaceFolder(workspaceFolder);
+ learningDesignDAO.update(learningDesign);
+ flashMessage = new FlashMessage("moveLesson",targetWorkspaceFolderID);
+ }
+ else
+ flashMessage = FlashMessage.getNoSuchWorkspaceFolderExsists("moveLesson",targetWorkspaceFolderID);
+ }else
+ flashMessage = FlashMessage.getUserNotAuthorized("moveLesson",userID);
+ }else{
+ flashMessage = new FlashMessage("moveLesson",
+ "No such lesson with a lesson_id of :" + lessonID +" exists.",
+ FlashMessage.ERROR);
+
+ }
+ return flashMessage.serializeMessage();
+
+ }
+ /**
+ * (non-Javadoc)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#renameLesson(java.lang.Long, java.lang.String, java.lang.Integer)
+ */
+ public String renameLesson(Long lessonID, String newName, Integer userID)throws IOException{
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ if(lesson!=null){
+ if(lesson.getUser().getUserId().equals(userID)){
+ lesson.setLessonName(newName);
+ lessonDAO.updateLesson(lesson);
+ flashMessage = new FlashMessage("renameLesson",newName);
+ }else
+ flashMessage = FlashMessage.getUserNotAuthorized("renameLesson",userID);
+ }else
+ flashMessage = new FlashMessage("renameLesson",
+ "No such lesson with a lesson_id of :" + lessonID +" exists.",
+ FlashMessage.ERROR);
+ return flashMessage.serializeMessage();
+ }
+
//---------------------------------------------------------------------
- // Helper Methods
+ // Helper Methods - create lesson
//---------------------------------------------------------------------
/**
* Create a new lesson and setup all the staffs and learners who will be
@@ -447,7 +601,10 @@
{
return toolActivity.getTool().getServiceName().equals("surveyService");
}
-
+
+ //---------------------------------------------------------------------
+ // Helper Methods - start lesson
+ //---------------------------------------------------------------------
/**
* Create lams tool session for requested learner in the lesson. After the
* creation of lams tool session, it delegates to the tool instances to
@@ -498,15 +655,7 @@
return activity.isToolActivity()
&& !((ToolActivity) activity).getApplyGrouping().booleanValue();
}
-
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllLessons()
- */
- public String getAllLessons() throws IOException{
- List lessons = lessonDAO.getAllLessons();
- return requestLessonList(lessons);
- }
+
/**
* This method returns the list of lessons in WDDX format
*
@@ -524,136 +673,7 @@
FlashMessage flashMessage = new FlashMessage("getAllLessons",lessonObjects);
return flashMessage.serializeMessage();
}
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllLessons(java.lang.Integer)
- */
- public String getAllLessons(Integer userID)throws IOException{
- List lessons = lessonDAO.getLessonsForUser(userID);
- return requestLessonList(lessons);
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLessonDetails(java.lang.Long)
- */
- public String getLessonDetails(Long lessonID)throws IOException{
- Lesson lesson = lessonDAO.getLesson(lessonID);
- if(lesson!=null){
- flashMessage = new FlashMessage("getLessonDetails",lesson.getLessonDetails());
- }else
- flashMessage = new FlashMessage("getLessonDetails",
- "No such Lesson with a lessonID of :" + lessonID + " exists.",
- FlashMessage.ERROR);
- return flashMessage.serializeMessage();
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLessonLearners(java.lang.Long)
- */
- public String getLessonLearners(Long lessonID)throws IOException{
- Vector lessonLearners = new Vector();
- Lesson lesson = lessonDAO.getLesson(lessonID);
- if(lesson!=null){
- Iterator iterator = lesson.getLessonClass().getLearners().iterator();
- while(iterator.hasNext()){
- User user = (User)iterator.next();
- lessonLearners.add(user.getUserDTO());
- }
- flashMessage = new FlashMessage("getLessonLearners",lessonLearners);
- }else
- flashMessage = new FlashMessage("getLessonLearners",
- "No such lesson with a lesson_id of :"+ lessonID + " exists",
- FlashMessage.ERROR);
- return flashMessage.serializeMessage();
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLearningDesignDetails(java.lang.Long)
- */
- public String getLearningDesignDetails(Long lessonID)throws IOException{
- Lesson lesson = lessonDAO.getLesson(lessonID);
- return authoringService.getLearningDesignDetails(lesson.getLearningDesign().getLearningDesignId());
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllLearnersProgress(java.lang.Long)
- */
- public String getAllLearnersProgress(Long lessonID)throws IOException {
- Vector progressData = new Vector();
- Lesson lesson = lessonDAO.getLesson(lessonID);
- if(lesson!=null){
- Iterator iterator = lesson.getLearnerProgresses().iterator();
- while(iterator.hasNext()){
- LearnerProgress learnerProgress = (LearnerProgress)iterator.next();
- progressData.add(learnerProgress.getLearnerProgressData());
- }
- flashMessage = new FlashMessage("getAllLearnersProgress",progressData);
- }else{
- flashMessage = new FlashMessage("getAllLearnersProgress",
- "No such lesson with a lesson_id of :"+ lessonID + " exists",
- FlashMessage.ERROR);
- }
- return flashMessage.serializeMessage();
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getAllContributeActivities(java.lang.Long)
- */
- public String getAllContributeActivities(Long lessonID)throws IOException{
- Lesson lesson = lessonDAO.getLesson(lessonID);
- if(lesson!=null){
- Vector sortedSet = getOrderedActivityTree(lesson.getLearningDesign());
- flashMessage = new FlashMessage("getAllContributeActivities",sortedSet);
- }else{
- flashMessage = new FlashMessage("getAllContributeActivities",
- "No such lesson with a lesson_id of " + lessonID + "exists",
- FlashMessage.ERROR);
- }
- return flashMessage.serializeMessage();
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getLearnerActivityURL(java.lang.Long, java.lang.Integer)
- */
- public String getLearnerActivityURL(Long activityID,Integer userID)throws IOException, LamsToolServiceException{
- Activity activity = activityDAO.getActivityByActivityId(activityID);
- User user = userDAO.getUserById(userID);
- if(activity==null || user==null){
- flashMessage = new FlashMessage("getLearnerActivityURL",
- "Invalid activityID/User :" + activityID + " : " + userID,
- FlashMessage.ERROR);
- }else{
- if(activity.isToolActivity()){
- ToolActivity toolActivity = (ToolActivity)activity;
- String toolURL = lamsCoreToolService.getLearnerToolURLByMode(toolActivity,user,ToolAccessMode.TEACHER);
- flashMessage = new FlashMessage("getLearnerActivityURL",new ProgressActivityDTO(activityID,toolURL));
- }else{
- flashMessage = new FlashMessage("getLearnerActivityURL",
- "Invalid Activity type: " + activity.getActivityId()+ "\n Only ToolActivity allowed.",
- FlashMessage.ERROR);
- }
- }
-
- return flashMessage.serializeMessage();
- }
/**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityContributionURL(java.lang.Long)
- */
- public String getActivityContributionURL(Long activityID)throws IOException{
- Activity activity = activityDAO.getActivityByActivityId(activityID);
- if(activity!=null){
- if(activity.isToolActivity()){
- ToolActivity toolActivity = (ToolActivity)activity;
- String contributionURL = toolActivity.getTool().getContributeUrl();
- flashMessage = new FlashMessage("getActivityContributionURL",contributionURL);
- }
- }else
- flashMessage = FlashMessage.getNoSuchActivityExists("getActivityContributionURL",activityID);
-
- return flashMessage.serializeMessage();
- }
- /**
* This method assigns an orderID to all the activties in the LearningDesign
* based on the transitions. Once this is done it just packages it in a container
* to be serialized and sent to flash
@@ -705,67 +725,68 @@
}
return activitySet;
}
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#moveLesson(java.lang.Long, java.lang.Integer, java.lang.Integer)
- */
- public String moveLesson(Long lessonID, Integer targetWorkspaceFolderID,Integer userID)throws IOException{
- Lesson lesson = lessonDAO.getLesson(lessonID);
- if(lesson!=null){
- if(lesson.getUser().getUserId().equals(userID)){
- WorkspaceFolder workspaceFolder = workspaceFolderDAO.getWorkspaceFolderByID(targetWorkspaceFolderID);
- if(workspaceFolder!=null){
- LearningDesign learningDesign = lesson.getLearningDesign();
- learningDesign.setWorkspaceFolder(workspaceFolder);
- learningDesignDAO.update(learningDesign);
- flashMessage = new FlashMessage("moveLesson",targetWorkspaceFolderID);
- }
- else
- flashMessage = FlashMessage.getNoSuchWorkspaceFolderExsists("moveLesson",targetWorkspaceFolderID);
- }else
- flashMessage = FlashMessage.getUserNotAuthorized("moveLesson",userID);
- }else{
- flashMessage = new FlashMessage("moveLesson",
- "No such lesson with a lesson_id of :" + lessonID +" exists.",
- FlashMessage.ERROR);
-
- }
- return flashMessage.serializeMessage();
-
- }
- /**
- * (non-Javadoc)
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#renameLesson(java.lang.Long, java.lang.String, java.lang.Integer)
- */
- public String renameLesson(Long lessonID, String newName, Integer userID)throws IOException{
- Lesson lesson = lessonDAO.getLesson(lessonID);
- if(lesson!=null){
- if(lesson.getUser().getUserId().equals(userID)){
- lesson.setLessonName(newName);
- lessonDAO.updateLesson(lesson);
- flashMessage = new FlashMessage("renameLesson",newName);
- }else
- flashMessage = FlashMessage.getUserNotAuthorized("renameLesson",userID);
- }else
- flashMessage = new FlashMessage("renameLesson",
- "No such lesson with a lesson_id of :" + lessonID +" exists.",
- FlashMessage.ERROR);
- return flashMessage.serializeMessage();
- }
-
+
+ //---------------------------------------------------------------------
+ // Helper Methods - scheduling
+ //---------------------------------------------------------------------
/**
- *
+ *
Runs the system scheduler to start the scheduling for opening gate and
+ * closing gate. It invlovs a couple of steps to start the scheduler:
+ *
1. Initialize the resource needed by scheduling job by setting
+ * them into the job data map.
+ *
+ *
2. Create customized triggers for the scheduling.
+ *
3. start the scheduling job
+ *
+ * @param scheduleGate the gate that needs to be scheduled.
*/
+ private void runGateScheduler(ScheduleGateActivity scheduleGate)
+ {
+ if(log.isDebugEnabled())
+ log.debug("Running scheduler for gate "+scheduleGate.getActivityId()+"...");
+ JobDetail openScheduleGateJob = getOpenScheduleGateJob();
+ JobDetail closeScheduleGateJob = getCloseScheduleGateJob();
+ //setup the message for scheduling job
+ openScheduleGateJob.setName("openGate");
+ openScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
+ closeScheduleGateJob.setName("closeGate");
+ closeScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
+ //create customized triggers
+ Trigger openGateTrigger = new SimpleTrigger("openGateTrigger",
+ Scheduler.DEFAULT_GROUP,
+ scheduleGate.getRealGateOpenTime());
+ Trigger closeGateTrigger = new SimpleTrigger("closeGateTrigger",
+ Scheduler.DEFAULT_GROUP,
+ scheduleGate.getRealGateCloseTime());
+ //start the scheduling job
+ try
+ {
+ scheduler.scheduleJob(openScheduleGateJob, openGateTrigger);
+ scheduler.scheduleJob(closeScheduleGateJob, closeGateTrigger);
+ }
+ catch (SchedulerException e)
+ {
+ throw new MonitoringServiceException("Error occurred at " +
+ "[runGateScheduler]- fail to start scheduling",e);
+ }
+ if(log.isDebugEnabled())
+ log.debug("Scheduler for Gate "+scheduleGate.getActivityId()+" started...");
+ }
+
+ /**
+ * Returns the bean that defines the open schedule gate job.
+ */
private JobDetail getOpenScheduleGateJob()
{
return (JobDetail)applicationContext.getBean("openScheduleGateJob");
}
/**
- *
+ * Returns the bean that defines the close schdule gate job.
*/
private JobDetail getCloseScheduleGateJob()
{
return (JobDetail)applicationContext.getBean("closeScheduleGateJob");
}
+
}
\ No newline at end of file
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java
===================================================================
diff -u -r06534437a29c100f06d4dda2a400b055eec2fd58 -rb6df3bbcefaf4633858d1d3161063abc3b620e7e
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java (.../MonitoringServiceProxy.java) (revision 06534437a29c100f06d4dda2a400b055eec2fd58)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java (.../MonitoringServiceProxy.java) (revision b6df3bbcefaf4633858d1d3161063abc3b620e7e)
@@ -24,6 +24,7 @@
import javax.servlet.ServletContext;
+import org.lamsfoundation.lams.learning.service.ILearnerService;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -44,18 +45,27 @@
{
/**
- * Return the learner domain service object. It will delegate to the Spring
+ * Return the monitor domain service object. It will delegate to the Spring
* helper method to retrieve the proper bean from Spring bean factory.
* @param servletContext the servletContext for current application
- * @return learner service object.
+ * @return monitoring service object.
*/
public static final IMonitoringService getMonitoringService(ServletContext servletContext)
{
return (IMonitoringService)getDomainService(servletContext,"monitoringService");
}
-
/**
+ * Return the learner domain service object. It will delegate to the Spring
+ * helper method to retrieve the proper bean from Spring bean factory.
+ * @param servletContext the servletContext for current application
+ * @return learner service object.
+ */
+ public static final ILearnerService getLearnerService(ServletContext servletContext)
+ {
+ return (ILearnerService)getDomainService(servletContext,"learnerService");
+ }
+ /**
* Retrieve the proper Spring bean from bean factory.
* @param servletContext the servletContext for current application
* @return the Spring service bean.
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/OpenScheduleGateJob.java
===================================================================
diff -u -r06534437a29c100f06d4dda2a400b055eec2fd58 -rb6df3bbcefaf4633858d1d3161063abc3b620e7e
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/OpenScheduleGateJob.java (.../OpenScheduleGateJob.java) (revision 06534437a29c100f06d4dda2a400b055eec2fd58)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/OpenScheduleGateJob.java (.../OpenScheduleGateJob.java) (revision b6df3bbcefaf4633858d1d3161063abc3b620e7e)
@@ -69,13 +69,13 @@
Map properties = context.getJobDetail().getJobDataMap();
Long gateId = (Long)properties.get("gateId");
- //if(log.isDebugEnabled())
- log.info("Openning gate......["+gateId.longValue()+"]");
+ if(log.isDebugEnabled())
+ log.debug("Openning gate......["+gateId.longValue()+"]");
monitoringService.openGate(gateId);
- //if(log.isDebugEnabled())
- log.info("Gate......["+gateId.longValue()+"] opened");
+ if(log.isDebugEnabled())
+ log.debug("Gate......["+gateId.longValue()+"] opened");
}
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java
===================================================================
diff -u
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (revision 0)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GateAction.java (revision b6df3bbcefaf4633858d1d3161063abc3b620e7e)
@@ -0,0 +1,249 @@
+/***************************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ***********************************************************************/
+
+package org.lamsfoundation.lams.monitoring.web;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.learning.service.ILearnerService;
+import org.lamsfoundation.lams.learning.web.util.LessonLearnerDataManager;
+import org.lamsfoundation.lams.learningdesign.Activity;
+import org.lamsfoundation.lams.learningdesign.PermissionGateActivity;
+import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity;
+import org.lamsfoundation.lams.learningdesign.SynchGateActivity;
+import org.lamsfoundation.lams.monitoring.service.IMonitoringService;
+import org.lamsfoundation.lams.monitoring.service.MonitoringServiceException;
+import org.lamsfoundation.lams.monitoring.service.MonitoringServiceProxy;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+
+/**
+ *
The action servlet that allows the teacher to view the status of sync
+ * gate, scheduling gate and permission gate. The teacher can also force the
+ * gate to open through this servlet.
+ *
+ *
Regarding view gate status, followings contents should be shown by
+ * calling this action servlet:
+ *
1.View the status of an sync gate, the lams should show how many
+ * learners are waiting and the size of the total class.
+ *
2.View the status of the permission gate, the lams shows the number
+ * of the learners waiting in front of the gates.
+ *
3.View the status of the schedule gate, the lams shows the gate
+ * status. If the schedule has been triggerred. The teacher should
+ * be able to change the trigger.
The dispatch method that allows the teacher to view the status of the
+ * gate. It is expecting the caller passed in lesson id and gate activity
+ * id as http parameter. Otherwise, the utility method will generate some
+ * exception.
+ *
+ *
Based on the lesson id and gate activity id, it sets up the gate form
+ * to show the waiting learners and the total waiting learners. Regarding
+ * schedule gate, it also shows the estimated gate opening time and gate
+ * closing time.
+ *
+ * Note: gate form attribute waitingLearners got setup
+ * after the view is dispatch to ensure there won't be casting exception
+ * occur if the activity id is not a gate by chance.
+ *
+ *
+ * @param mapping An ActionMapping class that will be used by the Action
+ * class to tell the ActionServlet where to send the end-user.
+ *
+ * @param form The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param response A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet
+ * indicating where the user is to go next.
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward viewGate(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ DynaActionForm gateForm = (DynaActionForm)form;
+
+ this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext());
+ this.learnerService = MonitoringServiceProxy.getLearnerService(getServlet().getServletContext());
+
+ long gateId = ((Long)gateForm.get("activityId")).longValue();
+ long lessonId = WebUtil.readLongParam(request,PARAM_LESSON_ID);
+
+ Activity gate = monitoringService.getActivityById(gateId);
+
+ //setup the total learners
+ int totalLearners = LessonLearnerDataManager.getAllLessonLearners(getServlet().getServletContext(),lessonId,learnerService)
+ .size();
+ gateForm.set("totalLearners",new Integer(totalLearners));
+
+ //dispatch the view according to the type of the gate.
+ if(gate.isSynchGate())
+ return viewSynchGate(mapping,gateForm,(SynchGateActivity)gate);
+ else if(gate.isScheduleGate())
+ return viewScheduleGate(mapping,gateForm,(ScheduleGateActivity)gate);
+ else if(gate.isPermissionGate())
+ return viewPermissionGate(mapping,gateForm,(PermissionGateActivity)gate);
+ else
+ throw new MonitoringServiceException("Invalid gate activity. " +
+ "gate id ["+gate.getActivityId()+"] - the type ["+
+ gate.getActivityTypeId()+"] is not a gate type");
+ }
+
+ /**
+ * Open the gate if is closed.
+ *
+ * @param mapping An ActionMapping class that will be used by the Action
+ * class to tell the ActionServlet where to send the end-user.
+ *
+ * @param form The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param response A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet
+ * indicating where the user is to go next.
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward openGate(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ this.monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext());
+
+ DynaActionForm gateForm = (DynaActionForm)form;
+
+ monitoringService.openGate((Long)gateForm.get("activityId"));
+
+ return mapping.findForward(OPEN_GATE);
+ }
+
+ /**
+ *
+ * @param mapping
+ * @param gateForm
+ * @param permissionGate
+ * @return
+ */
+ private ActionForward viewPermissionGate(ActionMapping mapping,
+ DynaActionForm gateForm,
+ PermissionGateActivity permissionGate)
+ {
+ gateForm.set("waitingLearners",new Integer(permissionGate.getWaitingLearners().size()));
+ return mapping.findForward(VIEW_PERMISSION_GATE);
+ }
+
+ /**
+ * @param mapping
+ * @param gateForm
+ * @param scheduleGate
+ * @return
+ */
+ private ActionForward viewScheduleGate(ActionMapping mapping,
+ DynaActionForm gateForm,
+ ScheduleGateActivity scheduleGate)
+ {
+ gateForm.set("waitingLearners",new Integer(scheduleGate.getWaitingLearners().size()));
+ //gateForm.set("startingTime",scheduleGate.get);
+
+ return mapping.findForward(VIEW_SCHEDULE_GATE);
+ }
+
+ /**
+ *
+ * @param mapping
+ * @param gateForm
+ * @param synchgate
+ * @return
+ */
+ private ActionForward viewSynchGate(ActionMapping mapping,
+ DynaActionForm gateForm,
+ SynchGateActivity synchgate)
+ {
+ gateForm.set("waitingLearners",new Integer(synchgate.getWaitingLearners().size()));
+ return mapping.findForward(VIEW_SYNCH_GATE);
+ }
+
+}
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java
===================================================================
diff -u -r06534437a29c100f06d4dda2a400b055eec2fd58 -rb6df3bbcefaf4633858d1d3161063abc3b620e7e
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 06534437a29c100f06d4dda2a400b055eec2fd58)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision b6df3bbcefaf4633858d1d3161063abc3b620e7e)
@@ -40,7 +40,6 @@
/**
- *
*
The action servlet that provide all the monitoring functionalities. It
* interact with the teacher via flash and JSP monitoring interface.