use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class CategoryDAOTest method createRelationToCategory.
@Test
public void createRelationToCategory() {
Category category = categoryDao.createAndPersistCategory("Cool");
dbInstance.commitAndCloseSession();
// create relation
String rndType = UUID.randomUUID().toString();
OLATResourceable ores = OresHelper.createOLATResourceableInstance(rndType, 234l);
categoryDao.appendRelation(ores, category);
dbInstance.commitAndCloseSession();
// load relation
List<Category> categories = categoryDao.getCategories(ores);
Assert.assertNotNull(categories);
Assert.assertEquals(1, categories.size());
Assert.assertEquals(category, categories.get(0));
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class ReferenceManagerTest method testAddReference.
@Test
public void testAddReference() {
OLATResource oressource = JunitTestHelper.createRandomResource();
OLATResource orestarget = JunitTestHelper.createRandomResource();
String udata = "üserdätä";
// add a reference
referenceManager.addReference(oressource, orestarget, udata);
dbInstance.commitAndCloseSession();
OLATResourceable targetOres = OresHelper.createOLATResourceableInstance(orestarget.getResourceableTypeName(), orestarget.getResourceableId());
OLATResource orestarget2 = resourceManager.findOrPersistResourceable(targetOres);
List<Reference> refs = referenceManager.getReferencesTo(orestarget2);
Assert.assertNotNull(refs);
Assert.assertEquals("only one reference may exist", 1, refs.size());
Assert.assertEquals(oressource, refs.get(0).getSource());
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class OpenMeetingsCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Roles roles = ureq.getUserSession().getRoles();
// check if user is moderator of the virtual classroom
boolean admin = roles.isOLATAdmin();
boolean moderator = admin;
RepositoryEntry re = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (!admin) {
RepositoryManager rm = RepositoryManager.getInstance();
if (re != null) {
admin = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re) || rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), roles, re);
moderator = admin || rm.isIdentityInTutorSecurityGroup(ureq.getIdentity(), re) || isCoach(re, ureq.getIdentity());
}
}
// create run controller
OLATResourceable ores = OresHelper.clone(userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseResource());
Controller runCtr = new OpenMeetingsRunController(ureq, wControl, null, ores, getIdent(), admin, moderator, userCourseEnv.isCourseReadOnly());
Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_openmeetings_icon");
return new NodeRunConstructionResult(controller);
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class SPRunController method doInlineIntegration.
private void doInlineIntegration(UserRequest ureq, boolean hasEditRightsTo) {
boolean allowRelativeLinks = config.getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
// create the possibility to float
OLATResourceable ores = OresHelper.createOLATResourceableInstance(ICourse.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
spCtr = new SinglePageController(ureq, getWindowControl(), courseFolderContainer, fileName, allowRelativeLinks, null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
spCtr.setAllowDownload(true);
// only for inline integration: register for controller event to forward a olatcmd to the course,
// and also to remember latest position in the script
listenTo(spCtr);
// enable edit mode if user has the according rights
if (hasEditRightsTo) {
spCtr.allowPageEditing();
// set the link tree model to internal for the HTML editor
if (linkTreeModel != null) {
spCtr.setInternalLinkTreeModel(linkTreeModel);
}
}
// create clone wrapper layout
CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {
public ControllerCreator createLayoutControllerCreator(UserRequest uureq, final ControllerCreator contentControllerCreator) {
return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
// Wrap in column layout, popup window needs a layout controller
Controller ctr = contentControllerCreator.createController(lureq, lwControl);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), userCourseEnv.getCourseEnvironment()));
// Controller titledCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, courseNode, "o_sp_icon");
layoutCtr.addDisposableChildController(ctr);
return layoutCtr;
}
});
}
};
Controller ctrl = TitledWrapperHelper.getWrapper(ureq, getWindowControl(), spCtr, courseNode, "o_sp_icon");
if (ctrl instanceof CloneableController) {
cloneC = new CloneController(ureq, getWindowControl(), (CloneableController) ctrl, clccc);
listenTo(cloneC);
main.setContent(cloneC.getInitialComponent());
} else {
throw new AssertException("Controller must be cloneable");
}
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class IQRunController method stopAssessment.
private void stopAssessment(UserRequest ureq, Event event) {
if (displayContainerController != null) {
displayContainerController.deactivate(ureq);
} else {
getWindowControl().pop();
}
removeHistory(ureq);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("test", -1l);
addToHistory(ureq, ores, null);
if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS) && !assessmentStopped) {
assessmentStopped = true;
AssessmentEvent assessmentStoppedEvent = new AssessmentEvent(AssessmentEvent.TYPE.STOPPED, userSession);
singleUserEventCenter.deregisterFor(this, assessmentInstanceOres);
singleUserEventCenter.fireEventToListenersOf(assessmentStoppedEvent, assessmentEventOres);
}
fireEvent(ureq, event);
}
Aggregations