Index: lams_build/lib/lams/lams-monitoring.jar
===================================================================
RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams-monitoring.jar,v
diff -u -r1.36.4.1 -r1.36.4.2
Binary files differ
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml,v
diff -u -r1.24 -r1.24.2.1
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml 16 Nov 2006 01:09:25 -0000 1.24
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml 19 Apr 2007 01:07:30 -0000 1.24.2.1
@@ -64,6 +64,7 @@
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRES_NEW
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java,v
diff -u -r1.61.2.2 -r1.61.2.3
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 26 Mar 2007 06:06:16 -0000 1.61.2.2
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 19 Apr 2007 01:07:29 -0000 1.61.2.3
@@ -32,6 +32,7 @@
import org.lamsfoundation.lams.learningdesign.Activity;
import org.lamsfoundation.lams.learningdesign.GateActivity;
import org.lamsfoundation.lams.learningdesign.GroupingActivity;
+import org.lamsfoundation.lams.learningdesign.ScheduleGateActivity;
import org.lamsfoundation.lams.learningdesign.exception.LearningDesignProcessorException;
import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.lesson.service.LessonServiceException;
@@ -132,7 +133,26 @@
* lesson.
*/
public void startLesson(long lessonId, Integer userId) throws UserAccessDeniedException;
+
/**
+ *
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.
+ * @param schedulingStartTime the time on which the gate open should be based if an offset is used. For starting
+ * a lesson, this is the lessonStartTime. For live edit, it is now.
+ * @param lessonName the name lesson incorporating this gate - used for the description of the Quartz job. Optional.
+ * @returns An updated gate, that should be saved by the calling code.
+ */
+ public ScheduleGateActivity runGateScheduler(ScheduleGateActivity scheduleGate,
+ Date schedulingStartTime, String lessonName);
+
+ /**
* Start a lesson on schedule datetime.
* @param lessonId
* @param startDate the lesson start date and time.
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v
diff -u -r1.102.2.5 -r1.102.2.6
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 10 Apr 2007 05:04:48 -0000 1.102.2.5
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 19 Apr 2007 01:07:29 -0000 1.102.2.6
@@ -742,8 +742,11 @@
//if it is schedule gate, we need to initialize the sheduler for it.
if(activity.getActivityTypeId().intValue() == Activity.SCHEDULE_GATE_ACTIVITY_TYPE) {
ScheduleGateActivity gateActivity = (ScheduleGateActivity) activityDAO.getActivityByActivityId(activity.getActivityId());
- runGateScheduler(gateActivity,lessonStartTime,requestedLesson.getLessonName());
+ activity = runGateScheduler(gateActivity,lessonStartTime,requestedLesson.getLessonName());
}
+ activity.setInitialised(Boolean.TRUE);
+ activityDAO.update(activity);
+
//update lesson status
}
requestedLesson.setLessonStateId(Lesson.STARTED_STATE);
@@ -753,7 +756,74 @@
if(log.isDebugEnabled())
log.debug("=============Lesson "+lessonId+" started===============");
}
+
/**
+ * 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.
+ * @param schedulingStartTime the time on which the gate open should be based if an offset is used. For starting
+ * a lesson, this is the lessonStartTime. For live edit, it is now.
+ * @param lessonName the name lesson incorporating this gate - used for the description of the Quartz job. Optional.
+ * @returns An updated gate, that should be saved by the calling code.
+ */
+ public ScheduleGateActivity runGateScheduler(ScheduleGateActivity scheduleGate,
+ Date schedulingStartTime, String lessonName)
+ {
+
+ 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:" + scheduleGate.getActivityId());
+ openScheduleGateJob.setDescription(scheduleGate.getTitle()+":"+lessonName);
+ openScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
+ closeScheduleGateJob.setName("closeGate:" + scheduleGate.getActivityId());
+ closeScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
+ closeScheduleGateJob.setDescription(scheduleGate.getTitle()+":"+lessonName);
+
+
+ //create customized triggers
+ Trigger openGateTrigger = new SimpleTrigger("openGateTrigger:" + scheduleGate.getActivityId(),
+ Scheduler.DEFAULT_GROUP,
+ scheduleGate.getLessonGateOpenTime(schedulingStartTime));
+
+
+ Trigger closeGateTrigger = new SimpleTrigger("closeGateTrigger:" + scheduleGate.getActivityId(),
+ Scheduler.DEFAULT_GROUP,
+ scheduleGate.getLessonGateCloseTime(schedulingStartTime));
+
+ //start the scheduling job
+ try
+ {
+ if((scheduleGate.getGateStartTimeOffset() == null && scheduleGate.getGateEndTimeOffset() == null) ||
+ (scheduleGate.getGateStartTimeOffset() != null && scheduleGate.getGateEndTimeOffset() == null))
+ scheduler.scheduleJob(openScheduleGateJob, openGateTrigger);
+ else if(openGateTrigger.getStartTime().before(closeGateTrigger.getStartTime())) {
+ 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...");
+
+ return scheduleGate;
+ }
+
+ /**
* @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#finishLesson(long)
*/
public void finishLesson(long lessonId, Integer userId) {
@@ -1584,68 +1654,7 @@
//---------------------------------------------------------------------
// 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,
- Date lessonStartTime, String lessonName)
- {
-
- 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:" + scheduleGate.getActivityId());
- openScheduleGateJob.setDescription(scheduleGate.getTitle()+":"+lessonName);
- openScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
- closeScheduleGateJob.setName("closeGate:" + scheduleGate.getActivityId());
- closeScheduleGateJob.getJobDataMap().put("gateId",scheduleGate.getActivityId());
- closeScheduleGateJob.setDescription(scheduleGate.getTitle()+":"+lessonName);
-
- //create customized triggers
- Trigger openGateTrigger = new SimpleTrigger("openGateTrigger:" + scheduleGate.getActivityId(),
- Scheduler.DEFAULT_GROUP,
- scheduleGate.getLessonGateOpenTime(lessonStartTime));
-
-
- Trigger closeGateTrigger = new SimpleTrigger("closeGateTrigger:" + scheduleGate.getActivityId(),
- Scheduler.DEFAULT_GROUP,
- scheduleGate.getLessonGateCloseTime(lessonStartTime));
-
- //start the scheduling job
- try
- {
- if((scheduleGate.getGateStartTimeOffset() == null && scheduleGate.getGateEndTimeOffset() == null) ||
- (scheduleGate.getGateStartTimeOffset() != null && scheduleGate.getGateEndTimeOffset() == null))
- scheduler.scheduleJob(openScheduleGateJob, openGateTrigger);
- else if(openGateTrigger.getStartTime().before(closeGateTrigger.getStartTime())) {
- scheduler.scheduleJob(openScheduleGateJob, openGateTrigger);
- scheduler.scheduleJob(closeScheduleGateJob, closeGateTrigger);
- }
-
- }
- catch (SchedulerException e)
- {
- throw new MonitoringServiceException("Error occurred at " +
- "[runGateScheduler]- fail to start scheduling",e);
- }
- //update the gate because the start time might be setup
- activityDAO.update(scheduleGate);
-
- if(log.isDebugEnabled())
- log.debug("Scheduler for Gate "+scheduleGate.getActivityId()+" started...");
- }
-
/**
* Returns the bean that defines the open schedule gate job.
*/