Search in sources :

Example 11 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project OpenOLAT by OpenOLAT.

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);
            }
        }
    });
}
Also used : ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) CourseNode(org.olat.course.nodes.CourseNode) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 12 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class ProjectBrokerManagerImpl method updateProject.

@Override
public void updateProject(final Project project) {
    final Long projectBrokerId = project.getProjectBroker().getKey();
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        @Override
        public void execute() {
            updateProjectAndInvalidateCache(project);
        }
    });
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 13 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class ProjectBrokerManagerImpl method createAndSaveProjectFor.

public Project createAndSaveProjectFor(String title, String description, final Long projectBrokerId, BusinessGroup projectGroup) {
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    final Project project = new ProjectImpl(title, description, projectGroup, getProjectBroker(projectBrokerId));
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        public void execute() {
            dbInstance.saveObject(project);
            ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
            if (!projectBroker.getProjects().contains(project)) {
                projectBroker.getProjects().add(project);
            }
            projectCache.update(projectBrokerId.toString(), projectBroker);
        }
    });
    return project;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) OLATResourceable(org.olat.core.id.OLATResourceable) ProjectImpl(org.olat.course.nodes.projectbroker.datamodel.ProjectImpl) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 14 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class BinderUserInformationsDAO method updateBinderUserInformations.

/**
 * Update (or create if not exists) the course informations for a user. To creation
 * of the user infos is made with doInSync.
 *
 * @param binder The binder
 * @param identity The identity
 */
public void updateBinderUserInformations(final Binder binder, final Identity identity) {
    int updatedRows = lowLevelUpdate(binder, identity);
    // to make it quick
    dbInstance.commit();
    if (updatedRows == 0) {
        OLATResourceable lockRes = OresHelper.createOLATResourceableInstance("BinderLaunchDate::Identity", identity.getKey());
        CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(lockRes, new SyncerExecutor() {

            @Override
            public void execute() {
                try {
                    int retryUpdatedRows = lowLevelUpdate(binder, identity);
                    if (retryUpdatedRows == 0) {
                        createAndPersistUserInfos(binder, identity);
                    }
                } catch (Exception e) {
                    log.error("Cannot update binder informations for: " + identity + " from " + identity, e);
                }
            }
        });
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 15 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class Path method cache.

/**
 * A feed contains many URLs and links etc. The validation of the URL and
 * verification of access should only be done once for performance reasons.
 * That's where caching comes in. We'll store the URL as the key and give it a
 * boolean value whether access has been successfully granted or not.
 */
public void cache(OLATResourceable ores, final boolean accessible) {
    final String key = getKey();
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {

        public void execute() {
            if (validatedUriCache.get(key) == null) {
                validatedUriCache.put(key, accessible);
            } else {
                validatedUriCache.update(key, accessible);
            }
        }
    });
}
Also used : SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Aggregations

SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)48 OLATResourceable (org.olat.core.id.OLATResourceable)30 ICourse (org.olat.course.ICourse)12 Property (org.olat.properties.Property)12 Project (org.olat.course.nodes.projectbroker.datamodel.Project)8 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)8 Identity (org.olat.core.id.Identity)6 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)6 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)6 Date (java.util.Date)4 Iterator (java.util.Iterator)4 Test (org.junit.Test)4 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)4 ProjectBroker (org.olat.course.nodes.projectbroker.datamodel.ProjectBroker)4 PropertyManager (org.olat.properties.PropertyManager)4 OLATResource (org.olat.resource.OLATResource)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 CountDownLatch (java.util.concurrent.CountDownLatch)2