use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.
the class NewCachePersistingAssessmentManager method saveNodeComment.
/**
* @see org.olat.course.assessment.AssessmentManager#saveNodeComment(org.olat.course.nodes.CourseNode,
* org.olat.core.id.Identity, org.olat.core.id.Identity,
* java.lang.String)
*/
public void saveNodeComment(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final String comment) {
ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {
public void execute() {
Property commentProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, COMMENT);
if (commentProperty == null) {
commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COMMENT, null, null, null, comment);
cpm.saveProperty(commentProperty);
} else {
commentProperty.setTextValue(comment);
cpm.updateProperty(commentProperty);
}
// add to cache
putPropertyIntoCache(assessedIdentity, commentProperty);
}
});
// node log
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, COMMENT + " set to: " + comment);
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_USER_COMMENT_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_USERCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiUserComment, "", StringHelper.stripLineBreaks(comment)));
}
use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.
the class InfoMessageManager method setInfoMessage.
/**
* @param message The new info message that will show up on the login screen
* Synchronized to prevent two users creating or updating the info message property
* at the same time
*/
public void setInfoMessage(final String message) {
// o_clusterOK synchronized
OLATResourceable ores = OresHelper.createOLATResourceableInstance(INFO_MSG, KEY);
coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
public void execute() {
PropertyManager pm = PropertyManager.getInstance();
Property p = pm.findProperty(null, null, null, "_o3_", INFO_MSG);
if (p == null) {
p = pm.createPropertyInstance(null, null, null, "_o3_", INFO_MSG, null, null, null, "");
pm.saveProperty(p);
}
p.setTextValue(message);
// set Message in RAM
InfoMessageManager.infoMessage = message;
pm.updateProperty(p);
}
});
// end syncerCallback
EventBus eb = coordinatorManager.getCoordinator().getEventBus();
MultiUserEvent mue = new MultiUserEvent(message);
eb.fireEventToListenersOf(mue, INFO_MESSAGE_ORES);
}
use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.
the class ChecklistManager method updateCheckpoint.
/**
* Update checkpoint
* @param checkpoint
*/
public void updateCheckpoint(final Checkpoint cp) {
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Checkpoint.class, cp.getKey());
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
public void execute() {
cp.setLastModified(new Date());
DBFactory.getInstance().updateObject(cp);
}
});
}
use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.
the class EfficiencyStatementManager method updateEfficiencyStatements.
/**
* Create or update all efficiency statment lists for the given list of identities and this course
* This is called from only one thread, since the course is locked at editing (either CourseEdit or CourseDetails edit).
*
* @param ores The resource to load the course
* @param identities List of identities
* false: always create new one (be careful with this one!)
*/
public void updateEfficiencyStatements(final RepositoryEntry courseEntry, List<Identity> identities) {
if (identities.size() > 0) {
final ICourse course = CourseFactory.loadCourse(courseEntry);
log.audit("Updating efficiency statements for course::" + course.getResourceableId() + ", this might produce temporary heavy load on the CPU");
// preload cache to speed up things
AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
int count = 0;
for (Identity identity : identities) {
// o_clusterOK: by ld
OLATResourceable efficiencyStatementResourceable = am.createOLATResourceableForLocking(identity);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(efficiencyStatementResourceable, new SyncerExecutor() {
@Override
public void execute() {
// create temporary user course env
UserCourseEnvironment uce = AssessmentHelper.createInitAndUpdateUserCourseEnvironment(identity, course);
updateUserEfficiencyStatement(uce, courseEntry);
}
});
if (Thread.interrupted()) {
break;
}
if (++count % 10 == 0) {
DBFactory.getInstance().commitAndCloseSession();
}
}
}
}
use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.
the class CustomDBController method addCustomDb.
private void addCustomDb(final String category) {
final ICourse course = CourseFactory.loadCourse(courseKey);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(course, new SyncerExecutor() {
@Override
public void execute() {
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
if (p == null) {
p = cpm.createCourseNodePropertyInstance(rootNode, null, null, CustomDBMainController.CUSTOM_DB, null, null, null, category);
cpm.saveProperty(p);
} else {
String currentDbs = p.getTextValue();
p.setTextValue(currentDbs + ":" + category);
cpm.updateProperty(p);
}
}
});
}
Aggregations