Search in sources :

Example 61 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method countChecked_withIdentity.

@Test
public void countChecked_withIdentity() {
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-7");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-8");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-12");
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-10", 2354l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId1 = UUID.randomUUID().toString();
    DBCheckbox checkbox1 = checkboxManager.createDBCheckbox(checkboxId1, ores, resSubPath);
    String checkboxId2 = UUID.randomUUID().toString();
    DBCheckbox checkbox2 = checkboxManager.createDBCheckbox(checkboxId2, ores, resSubPath);
    String checkboxId3 = UUID.randomUUID().toString();
    DBCheckbox checkbox3 = checkboxManager.createDBCheckbox(checkboxId3, ores, resSubPath);
    String checkboxId4 = UUID.randomUUID().toString();
    DBCheckbox checkbox4 = checkboxManager.createDBCheckbox(checkboxId4, ores, resSubPath);
    // create a check
    checkboxManager.createCheck(checkbox1, id1, null, Boolean.TRUE);
    checkboxManager.createCheck(checkbox2, id1, null, Boolean.TRUE);
    checkboxManager.createCheck(checkbox1, id2, null, Boolean.TRUE);
    checkboxManager.createCheck(checkbox3, id2, null, Boolean.FALSE);
    checkboxManager.createCheck(checkbox4, id2, null, Boolean.TRUE);
    dbInstance.commitAndCloseSession();
    // count the checks
    int id1Checked = checkboxManager.countChecked(id1, ores, resSubPath);
    Assert.assertEquals(2, id1Checked);
    int id2Checked = checkboxManager.countChecked(id2, ores, resSubPath);
    Assert.assertEquals(2, id2Checked);
    int id3Checked = checkboxManager.countChecked(id3, ores, resSubPath);
    Assert.assertEquals(0, id3Checked);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 62 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class DBPersistentLockManagerTest method deleteUserData.

@Test
public void deleteUserData() {
    String type = UUID.randomUUID().toString();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(type, 25l);
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("lock-1");
    Identity nextIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("lock-2");
    String locksubkey = UUID.randomUUID().toString();
    // acquire lock
    LockResult lock = lockManager.aquirePersistentLock(ores, owner, locksubkey);
    dbInstance.commit();
    Assert.assertTrue(lock.isSuccess());
    // delete the owner
    lockManager.deleteUserData(owner, "", null);
    dbInstance.commit();
    // next can acquire the lock
    LockResult nextLock = lockManager.aquirePersistentLock(ores, nextIdentity, locksubkey);
    dbInstance.commit();
    Assert.assertTrue(nextLock.isSuccess());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 63 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class DBPersistentLockManagerTest method releasePersistentLock.

@Test
public void releasePersistentLock() {
    String type = UUID.randomUUID().toString();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(type, 25l);
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("lock-1");
    String locksubkey = UUID.randomUUID().toString();
    // acquire lock
    LockResult lock = lockManager.aquirePersistentLock(ores, owner, locksubkey);
    dbInstance.commit();
    Assert.assertTrue(lock.isSuccess());
    // release
    lockManager.releasePersistentLock(lock);
    dbInstance.commit();
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 64 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class EditorMainController method jumpToNodeEditor.

/**
 * Initializes the node edit tabbed pane and its controller for this
 * particular node
 *
 * @param ureq
 * @param chosenNode
 * @param groupMgr
 */
private void jumpToNodeEditor(String activatorIdent, UserRequest ureq, CourseNode chosenNode) {
    initNodeEditor(ureq, chosenNode);
    if (nodeEditCntrllr instanceof ActivateableTabbableDefaultController) {
        OLATResourceable activeOres = OresHelper.createOLATResourceableInstanceWithoutCheck(activatorIdent, 0l);
        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromString(activeOres);
        ((ActivateableTabbableDefaultController) nodeEditCntrllr).activate(ureq, entries, null);
    }
}
Also used : ActivateableTabbableDefaultController(org.olat.core.gui.control.generic.tabbable.ActivateableTabbableDefaultController) OLATResourceable(org.olat.core.id.OLATResourceable) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 65 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class MembersManagementMainController method selectMenuItem.

private Controller selectMenuItem(UserRequest ureq, String cmd) {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(cmd, 0l);
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
    addToHistory(ureq, bwControl);
    Controller selectedCtrl = null;
    if (CMD_MEMBERS.equals(cmd)) {
        if (entryAdmin || memberManagementRight) {
            if (membersOverviewCtrl == null) {
                membersOverviewCtrl = new MembersOverviewController(ureq, bwControl, toolbarPanel, repoEntry, coachCourseEnv);
                listenTo(membersOverviewCtrl);
            } else if (membersDirty) {
                membersOverviewCtrl.reloadMembers();
            }
            mainVC.put("content", membersOverviewCtrl.getInitialComponent());
            selectedCtrl = membersOverviewCtrl;
        }
    } else if (CMD_GROUPS.equals(cmd)) {
        if (entryAdmin || memberManagementRight || groupManagementRight) {
            if (groupsCtrl == null) {
                groupsCtrl = new CourseBusinessGroupListController(ureq, bwControl, repoEntry, entryAdmin || groupManagementRight, coachCourseEnv.isCourseReadOnly());
                listenTo(groupsCtrl);
            }
            groupsCtrl.reloadModel();
            mainVC.put("content", groupsCtrl.getInitialComponent());
            selectedCtrl = groupsCtrl;
        }
    } else if (CMD_BOOKING.equals(cmd)) {
        if (acModule.isEnabled() && (entryAdmin || memberManagementRight)) {
            if (ordersController == null) {
                ordersController = new OrdersAdminController(ureq, bwControl, toolbarPanel, repoEntry.getOlatResource());
                listenTo(ordersController);
            }
            mainVC.put("content", ordersController.getInitialComponent());
            selectedCtrl = ordersController;
        }
    } else if (CMD_RIGHTS.equals(cmd)) {
        if (entryAdmin) {
            if (rightsController == null) {
                rightsController = new GroupsAndRightsController(ureq, bwControl, repoEntry, coachCourseEnv.isCourseReadOnly());
                listenTo(rightsController);
            }
            mainVC.put("content", rightsController.getInitialComponent());
            selectedCtrl = rightsController;
        }
    }
    TreeNode selTreeNode = TreeHelper.findNodeByUserObject(cmd, menuTree.getTreeModel().getRootNode());
    if (selTreeNode != null && !selTreeNode.getIdent().equals(menuTree.getSelectedNodeId())) {
        menuTree.setSelectedNodeId(selTreeNode.getIdent());
    }
    return selectedCtrl;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) OrdersAdminController(org.olat.resource.accesscontrol.ui.OrdersAdminController) GroupsAndRightsController(org.olat.course.groupsandrights.GroupsAndRightsController) WindowControl(org.olat.core.gui.control.WindowControl) GroupsAndRightsController(org.olat.course.groupsandrights.GroupsAndRightsController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController) OrdersAdminController(org.olat.resource.accesscontrol.ui.OrdersAdminController)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22