use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
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.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class PortfolioResultDetailsController method initMapsForm.
protected void initMapsForm(FormItemContainer formLayout) {
Formatter formatter = Formatter.getInstance(getLocale());
int count = 0;
for (PortfolioStructureMap map : maps) {
MapElements mapElements = new MapElements();
if (map instanceof EPStructuredMap) {
EPStructuredMap structuredMap = (EPStructuredMap) map;
if (maps.size() > 1 || !structuredMap.getStructuredMapSource().equals(templateMap)) {
String templateTitle = structuredMap.getStructuredMapSource().getTitle();
uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
}
String copyDate = "";
if (structuredMap.getCopyDate() != null) {
copyDate = formatter.formatDateAndTime(structuredMap.getCopyDate());
}
uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
String returnDate = "";
if (structuredMap.getReturnDate() != null) {
returnDate = formatter.formatDateAndTime(structuredMap.getReturnDate());
}
uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
String deadLine = "";
if (structuredMap.getDeadLine() != null) {
deadLine = formatter.formatDateAndTime(structuredMap.getDeadLine());
}
mapElements.deadlineEl = uifactory.addStaticTextElement("map.deadline." + count, "map.deadline", deadLine, formLayout);
}
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
if (map instanceof EPStructuredMap) {
mapElements.changeDeadlineLink = uifactory.addFormLink("map.deadline.change." + count, "map.deadline.change", null, buttonsCont, Link.BUTTON);
mapElements.changeDeadlineLink.setUserObject(map);
}
mapElements.openMapLink = uifactory.addFormLink("open.map." + count, "open.map", null, buttonsCont, Link.BUTTON);
mapElements.openMapLink.setUserObject(map);
count++;
if (count != maps.size()) {
uifactory.addSpacerElement("spacer-" + count, formLayout, false);
}
mapToElements.put(map, mapElements);
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPStructureManagerTest method testLoadPortfolioStructuredMaps.
@Test
public void testLoadPortfolioStructuredMaps() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
// a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
// clone the template
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
((EPStructuredMap) map).setReturnDate(new Date());
EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
targetResource.setResourceableTypeName("CourseModule");
targetResource.setResourceableId(234l);
targetResource.setSubPath(UUID.randomUUID().toString());
targetResource.setBusinessPath("[RepositoryEntry:23647600][CourseNode:934600]");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// load the cloned map another map
List<PortfolioStructureMap> myCloneAlt = epStructureManager.loadPortfolioStructuredMaps(user, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
Assert.assertNotNull(myCloneAlt);
Assert.assertEquals(1, myCloneAlt.size());
Assert.assertEquals(map, myCloneAlt.get(0));
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPStructureManagerTest method loadPortfolioStructure_resourceable.
@Test
public void loadPortfolioStructure_resourceable() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-res-tmp-");
// a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "resourced-el", "resource-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
OLATResource resource = template.getOlatResource();
PortfolioStructure structure = epStructureManager.loadPortfolioStructure(resource);
Assert.assertNotNull(structure);
Assert.assertEquals(template, structure);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPStructureManagerTest method testLoadPortfolioStructuredMap.
@Test
public void testLoadPortfolioStructuredMap() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
// create a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
// clone the template
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
((EPStructuredMap) map).setReturnDate(new Date());
EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
targetResource.setResourceableTypeName("CourseModule");
targetResource.setResourceableId(234l);
targetResource.setSubPath(UUID.randomUUID().toString());
targetResource.setBusinessPath("[RepositoryEntry:23647599][CourseNode:934599]");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// load the cloned map another map
PortfolioStructureMap myClonedMap = epStructureManager.loadPortfolioStructuredMap(user, template, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
Assert.assertNotNull(myClonedMap);
}
Aggregations