use of org.olat.course.assessment.model.CoordinatedAssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeCoordinationServiceImpl method manageListenersOfCoordinatedMode.
private void manageListenersOfCoordinatedMode(AssessmentMode mode) {
try {
Status status = mode.getStatus();
if (status == Status.leadtime || status == Status.assessment || status == Status.followup) {
// add listeners
CoordinatedAssessmentMode coordinateMode = coordinatedModes.get(mode.getKey());
if (coordinateMode == null) {
coordinateMode = new CoordinatedAssessmentMode(mode);
coordinatedModes.put(mode.getKey(), coordinateMode);
}
coordinatorManager.getCoordinator().getEventBus().registerFor(this, null, coordinateMode.getListenerRes());
} else if (coordinatedModes.containsKey(mode.getKey())) {
CoordinatedAssessmentMode decoordinateMode = coordinatedModes.remove(mode.getKey());
if (decoordinateMode != null) {
coordinatorManager.getCoordinator().getEventBus().deregisterFor(this, decoordinateMode.getListenerRes());
}
}
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.course.assessment.model.CoordinatedAssessmentMode in project openolat by klemens.
the class AssessmentModeCoordinationServiceImpl method manageListenersOfCoordinatedMode.
private void manageListenersOfCoordinatedMode(AssessmentMode mode) {
try {
Status status = mode.getStatus();
if (status == Status.leadtime || status == Status.assessment || status == Status.followup) {
// add listeners
CoordinatedAssessmentMode coordinateMode = coordinatedModes.get(mode.getKey());
if (coordinateMode == null) {
coordinateMode = new CoordinatedAssessmentMode(mode);
coordinatedModes.put(mode.getKey(), coordinateMode);
}
coordinatorManager.getCoordinator().getEventBus().registerFor(this, null, coordinateMode.getListenerRes());
} else if (coordinatedModes.containsKey(mode.getKey())) {
CoordinatedAssessmentMode decoordinateMode = coordinatedModes.remove(mode.getKey());
if (decoordinateMode != null) {
coordinatorManager.getCoordinator().getEventBus().deregisterFor(this, decoordinateMode.getListenerRes());
}
}
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.course.assessment.model.CoordinatedAssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeCoordinationServiceImpl method beat.
protected synchronized void beat() {
if (assessmentModule.isAssessmentModeEnabled()) {
Date now = now();
List<Long> currentModeKeys = new ArrayList<>();
List<AssessmentMode> currentModes = assessmentModeManager.getAssessmentModes(now);
for (AssessmentMode currentMode : currentModes) {
try {
sendEvent(currentMode, now, false);
currentModeKeys.add(currentMode.getKey());
} catch (Exception e) {
log.error("", e);
}
}
// remove coordinated mode
List<Long> coordinatedModeKeys = new ArrayList<>(coordinatedModes.keySet());
for (Long coordinatedModeKey : coordinatedModeKeys) {
if (!currentModeKeys.contains(coordinatedModeKey)) {
CoordinatedAssessmentMode decoordinatedMode = coordinatedModes.remove(coordinatedModeKey);
if (decoordinatedMode != null) {
coordinatorManager.getCoordinator().getEventBus().deregisterFor(this, decoordinatedMode.getListenerRes());
}
}
}
if (coordinatedModes.size() > 250) {
log.error("Seem to be a leak of coordinated modes");
}
}
}
use of org.olat.course.assessment.model.CoordinatedAssessmentMode in project openolat by klemens.
the class AssessmentModeCoordinationServiceImpl method beat.
protected synchronized void beat() {
if (assessmentModule.isAssessmentModeEnabled()) {
Date now = now();
List<Long> currentModeKeys = new ArrayList<>();
List<AssessmentMode> currentModes = assessmentModeManager.getAssessmentModes(now);
for (AssessmentMode currentMode : currentModes) {
try {
sendEvent(currentMode, now, false);
currentModeKeys.add(currentMode.getKey());
} catch (Exception e) {
log.error("", e);
}
}
// remove coordinated mode
List<Long> coordinatedModeKeys = new ArrayList<>(coordinatedModes.keySet());
for (Long coordinatedModeKey : coordinatedModeKeys) {
if (!currentModeKeys.contains(coordinatedModeKey)) {
CoordinatedAssessmentMode decoordinatedMode = coordinatedModes.remove(coordinatedModeKey);
if (decoordinatedMode != null) {
coordinatorManager.getCoordinator().getEventBus().deregisterFor(this, decoordinatedMode.getListenerRes());
}
}
}
if (coordinatedModes.size() > 250) {
log.error("Seem to be a leak of coordinated modes");
}
}
}
Aggregations