use of org.olat.modules.portfolio.Binder in project OpenOLAT by OpenOLAT.
the class MediaDAOTest method usedInBinders.
@Test
public void usedInBinders() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-2");
Binder binder = portfolioService.createNewBinder("Binder p2", "A binder with 2 page", null, author);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
Media media = mediaDao.createMedia("Media", "Binder", "Une citation sur les classeurs", TextHandler.TEXT_MEDIA, "[Media:0]", null, 10, author);
dbInstance.commitAndCloseSession();
MediaPart mediaPart = new MediaPart();
mediaPart.setMedia(media);
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.persistPart(reloadedBody, mediaPart);
dbInstance.commitAndCloseSession();
// reload
List<BinderPageUsage> binders = mediaDao.usedInBinders(media);
Assert.assertNotNull(binders);
Assert.assertEquals(1, binders.size());
Assert.assertTrue(binders.get(0).getBinderKey().equals(binder.getKey()));
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioResultDetailsController method initBindersForm.
protected void initBindersForm(FormItemContainer formLayout) {
Formatter formatter = Formatter.getInstance(getLocale());
int count = 0;
for (Binder binder : binders) {
MapElements mapElements = new MapElements();
if (binders.size() > 1 || !binder.getTemplate().equals(templateBinder)) {
String templateTitle = binder.getTemplate().getTitle();
uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
}
String copyDate = "";
if (binder.getCopyDate() != null) {
copyDate = formatter.formatDateAndTime(binder.getCopyDate());
}
uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
String returnDate = "";
if (binder.getReturnDate() != null) {
returnDate = formatter.formatDateAndTime(binder.getReturnDate());
}
uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
mapElements.openMapLink = uifactory.addFormLink("open.binder." + count, "open.binder", "open.map", null, buttonsCont, Link.BUTTON);
mapElements.openMapLink.setUserObject(binder);
count++;
if (count != binders.size()) {
uifactory.addSpacerElement("spacer-" + count, formLayout, false);
}
binderToElements.put(binder, mapElements);
}
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioResultDetailsController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if (cmd != null && cmd.startsWith("map.deadline.change")) {
if (deadlineCalloutCtr == null) {
EPStructuredMap map = (EPStructuredMap) link.getUserObject();
popupDeadlineBox(ureq, map);
} else {
// close on second click
closeDeadlineBox();
}
} else if (link.getName().startsWith("open.map")) {
PortfolioStructureMap map = (PortfolioStructureMap) link.getUserObject();
doOpenMap(ureq, map);
} else if (link.getName().startsWith("open.binder")) {
Binder map = (Binder) link.getUserObject();
doOpenMap(ureq, map);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioTextForm method loadMapOrBinder.
protected void loadMapOrBinder() {
RepositoryEntry mapEntry = courseNode.getReferencedRepositoryEntry();
if (mapEntry != null) {
if (BinderTemplateResource.TYPE_NAME.equals(mapEntry.getOlatResource().getResourceableTypeName())) {
Binder binder = portfolioService.getBinderByResource(mapEntry.getOlatResource());
if (binder != null) {
inUse = portfolioService.isTemplateInUse(binder, courseEntry, courseNode.getIdent());
}
withDeadline = false;
} else {
PortfolioStructureMap template = (PortfolioStructureMap) ePFMgr.loadPortfolioStructure(mapEntry.getOlatResource());
Long courseResId = courseEntry.getOlatResource().getResourceableId();
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseResId);
if (template != null) {
inUse = ePFMgr.isTemplateInUse(template, courseOres, courseNode.getIdent(), null);
}
withDeadline = true;
}
} else {
withDeadline = true;
}
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class BinderListController method doCreateBinderFromTemplate.
private void doCreateBinderFromTemplate(UserRequest ureq, RepositoryEntry entry) {
Binder templateBinder = portfolioService.getBinderByResource(entry.getOlatResource());
Binder newBinder = portfolioService.assignBinder(getIdentity(), templateBinder, null, null, null);
DBFactory.getInstance().commit();
SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(newBinder);
newBinder = synchedBinder.getBinder();
doOpenBinder(ureq, newBinder).activate(ureq, null, null);
}
Aggregations