Search in sources :

Example 21 with EPStructuredMap

use of org.olat.portfolio.model.structel.EPStructuredMap 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);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 22 with EPStructuredMap

use of org.olat.portfolio.model.structel.EPStructuredMap 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);
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 23 with EPStructuredMap

use of org.olat.portfolio.model.structel.EPStructuredMap 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));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 24 with EPStructuredMap

use of org.olat.portfolio.model.structel.EPStructuredMap 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);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 25 with EPStructuredMap

use of org.olat.portfolio.model.structel.EPStructuredMap in project openolat by klemens.

the class EPStructureManager method createPortfolioStructuredMap.

protected PortfolioStructureMap createPortfolioStructuredMap(PortfolioStructureMap template, Identity identity, String title, String description, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
    EPStructuredMap el = new EPStructuredMap();
    el.setStructuredMapSource((EPStructuredMapTemplate) template);
    el.setStructureElSource(template.getKey());
    if (template != null) {
        copyOrUpdateCollectRestriction(template, el, false);
    }
    EPTargetResource targetResource = el.getTargetResource();
    if (targetOres != null) {
        targetResource.setResourceableId(targetOres.getResourceableId());
        targetResource.setResourceableTypeName(targetOres.getResourceableTypeName());
    }
    if (StringHelper.containsNonWhitespace(targetSubPath)) {
        targetResource.setSubPath(targetSubPath);
    }
    if (StringHelper.containsNonWhitespace(targetBusinessPath)) {
        targetResource.setBusinessPath(targetBusinessPath);
    }
    fillStructureElement(el, title, description);
    // create security group
    EPStructureElementToGroupRelation ownerGroup = createBaseGroup(el, identity);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(ownerGroup);
    el.setGroups(relations);
    return el;
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) HashSet(java.util.HashSet)

Aggregations

EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)34 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)18 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)16 Date (java.util.Date)14 RepositoryEntry (org.olat.repository.RepositoryEntry)12 Test (org.junit.Test)10 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)10 Identity (org.olat.core.id.Identity)8 ArrayList (java.util.ArrayList)6 OLATResource (org.olat.resource.OLATResource)6 OLATResourceable (org.olat.core.id.OLATResourceable)4 ICourse (org.olat.course.ICourse)4 CourseNode (org.olat.course.nodes.CourseNode)4 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4 HashSet (java.util.HashSet)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 Component (org.olat.core.gui.components.Component)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2