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);
}
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());
}
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();
}
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);
}
}
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;
}
Aggregations