use of org.olat.portfolio.model.structel.EPStructuredMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManager method assignStructuredMapToUser.
/**
* Assign a structure map to user. In other words, make a copy of the template
* and set the user as an author.
*
* @param identity
* @param portfolioStructureStructuredMapTemplate
*/
public PortfolioStructureMap assignStructuredMapToUser(final Identity identity, final PortfolioStructureMap mapTemplate, final RepositoryEntry courseEntry, String targetSubPath, final String targetBusinessPath, final Date deadline) {
// doInSync is here to check for nested doInSync exception in first place
final OLATResource ores = courseEntry.getOlatResource();
final String subPath = targetSubPath;
PortfolioStructureMap map = coordinator.getSyncer().doInSync(mapTemplate.getOlatResource(), new SyncerCallback<PortfolioStructureMap>() {
@Override
public PortfolioStructureMap execute() {
PortfolioStructureMap template = (PortfolioStructureMap) structureManager.loadPortfolioStructureByKey(mapTemplate.getKey());
String title = template.getTitle();
String description = template.getDescription();
PortfolioStructureMap copy = structureManager.createPortfolioStructuredMap(template, identity, title, description, ores, subPath, targetBusinessPath);
if (copy instanceof EPStructuredMap) {
((EPStructuredMap) copy).setDeadLine(deadline);
}
structureManager.copyStructureRecursively(template, copy, true);
RepositoryEntry referenceEntry = repositoryEntryDao.loadByResourceKey(template.getOlatResource().getKey());
assessmentService.updateAssessmentEntry(identity, courseEntry, targetSubPath, referenceEntry, AssessmentEntryStatus.inProgress);
return copy;
}
});
return map;
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManager method synchronizeStructuredMapToUserCopy.
/**
* sync map with its former source (template)
*/
public boolean synchronizeStructuredMapToUserCopy(PortfolioStructureMap map) {
if (map == null)
return false;
final EPStructuredMap userMap = (EPStructuredMap) map;
Boolean synched = coordinator.getSyncer().doInSync(map.getOlatResource(), new SyncerCallback<Boolean>() {
public Boolean execute() {
if (userMap.getStructuredMapSource() == null) {
return Boolean.FALSE;
}
// need to reload it, I don't know why
Long templateKey = userMap.getStructuredMapSource().getKey();
userMap.setLastSynchedDate(new Date());
PortfolioStructure template = structureManager.loadPortfolioStructureByKey(templateKey);
structureManager.syncStructureRecursively(template, userMap, true);
return Boolean.TRUE;
}
});
return synched.booleanValue();
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method testAssignMapTemplateToUser.
@Test
public void testAssignMapTemplateToUser() {
// create a template
OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
// create a repository entry
RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "template-1", "map-template-1", resource, RepositoryEntry.ACC_OWNERS);
dbInstance.commitAndCloseSession();
// create the template owned by ident1
PortfolioStructureMap templateEl = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
// first page
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(templateEl, "template-page-1", "template-page-1");
// structure element 1 from page 1
PortfolioStructure struct11 = epFrontendManager.createAndPersistPortfolioStructureElement(page1, "template-structure-1.1", "template-structure-1.1");
epStructureManager.addCollectRestriction(struct11, "Forum", "minimum", 2);
epStructureManager.savePortfolioStructure(struct11);
// structure element 2 from page 1
PortfolioStructure struct12 = epFrontendManager.createAndPersistPortfolioStructureElement(page1, "template-structure-1.2", "template-structure-1.2");
assertNotNull(struct12);
// first page
PortfolioStructure page2 = epFrontendManager.createAndPersistPortfolioPage(templateEl, "template-page-2", "template-page-2");
// structure element 1 from page 2
PortfolioStructure struct21 = epFrontendManager.createAndPersistPortfolioStructureElement(page2, "template-structure-2.1", "template-structure-2.1");
epStructureManager.addCollectRestriction(struct21, "bc", "maximum", 4);
epStructureManager.savePortfolioStructure(struct21);
// save the template
dbInstance.commitAndCloseSession();
// make the copy
PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, templateEl, addedEntry, null, null, null);
dbInstance.commitAndCloseSession();
assertNotNull(map);
// check the copy
PortfolioStructure retrievedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
assertNotNull(retrievedMap);
assertTrue(retrievedMap instanceof EPStructuredMap);
assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
assertEquals(templateEl.getKey(), ((EPStructuredMap) retrievedMap).getStructuredMapSource().getKey());
// check pages of the copied map
List<PortfolioStructure> pages = epFrontendManager.loadStructureChildren(retrievedMap);
assertNotNull(pages);
assertEquals(2, pages.size());
assertTrue(pages.get(0) instanceof EPPage);
assertTrue(pages.get(1) instanceof EPPage);
assertEquals("template-page-1", ((EPStructureElement) pages.get(0)).getTitle());
assertEquals("template-page-2", ((EPStructureElement) pages.get(1)).getTitle());
// check root
assertNotNull(((EPStructureElement) pages.get(0)).getRoot());
assertEquals(retrievedMap.getKey(), ((EPStructureElement) pages.get(0)).getRoot().getKey());
// check children of the pages
List<PortfolioStructure> structs1 = epFrontendManager.loadStructureChildren(pages.get(0));
assertNotNull(structs1);
assertEquals(2, structs1.size());
assertTrue(structs1.get(0) instanceof EPStructureElement);
assertTrue(structs1.get(1) instanceof EPStructureElement);
EPStructureElement struct11El = (EPStructureElement) structs1.get(0);
assertEquals("template-structure-1.1", struct11El.getTitle());
assertEquals("template-structure-1.2", ((EPStructureElement) structs1.get(1)).getTitle());
// check root
assertNotNull(((EPStructureElement) structs1.get(0)).getRoot());
assertEquals(retrievedMap.getKey(), ((EPStructureElement) structs1.get(0)).getRoot().getKey());
assertNotNull(((EPStructureElement) structs1.get(1)).getRoot());
assertEquals(retrievedMap.getKey(), ((EPStructureElement) structs1.get(1)).getRoot().getKey());
// check collect restriction
assertNotNull(struct11El.getCollectRestrictions());
assertEquals("Forum", struct11El.getCollectRestrictions().get(0).getArtefactType());
assertEquals("minimum", struct11El.getCollectRestrictions().get(0).getRestriction());
assertEquals(2, struct11El.getCollectRestrictions().get(0).getAmount());
List<PortfolioStructure> structs2 = epFrontendManager.loadStructureChildren(pages.get(1));
assertNotNull(structs2);
assertEquals(1, structs2.size());
assertTrue(structs2.get(0) instanceof EPStructureElement);
EPStructureElement struct21El = (EPStructureElement) structs2.get(0);
assertEquals("template-structure-2.1", struct21El.getTitle());
// check root
assertNotNull(struct21El.getRoot());
assertEquals(retrievedMap.getKey(), struct21El.getRoot().getKey());
// check collect restriction
assertNotNull(struct21El.getCollectRestrictions());
assertEquals("bc", struct21El.getCollectRestrictions().get(0).getArtefactType());
assertEquals("maximum", struct21El.getCollectRestrictions().get(0).getRestriction());
assertEquals(4, struct21El.getCollectRestrictions().get(0).getAmount());
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project OpenOLAT by OpenOLAT.
the class EPChangelogController method updateChangelogDisplay.
/**
* update the changelog-list according to selected date. this method is
* invoked on initForm and again when user changes date in dateChooser
*/
private void updateChangelogDisplay() {
// init the helper;
String path = getWindowControl().getBusinessControl().getAsString();
EPNotificationsHelper helper = new EPNotificationsHelper(path, getLocale());
// get the date from the dateChooser component
Date compareDate = dateChooser.getDate();
EPMapShort mapShort = ePFMgr.loadMapShortByResourceId(map.getOlatResource().getResourceableId());
List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
// get subscriptionListItems according to map type
if (map instanceof EPDefaultMap || map instanceof EPStructuredMapTemplate) {
allItems = helper.getAllSubscrItemsDefault(compareDate, mapShort);
} else if (map instanceof EPStructuredMap) {
allItems = helper.getAllSubscrItemsStructured(compareDate, mapShort);
}
List<SubscriptionItemBundle> bundles = getItemBundlesForSubscriptionItems(allItems);
flc.contextPut("subscriptionItems", bundles);
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project OpenOLAT by OpenOLAT.
the class PortfolioCourseNodeRunController method updateSelectedMapUI.
private void updateSelectedMapUI(UserRequest ureq) {
String copyTitle = StringHelper.escapeHtml(copyMap.getTitle());
selectMapLink.getComponent().setCustomDisplayText(copyTitle);
// show results, when already handed in
EPStructuredMap structuredMap = (EPStructuredMap) copyMap;
updateCopyDate(structuredMap.getCopyDate());
updateAssessmentInfos(ureq, structuredMap.getReturnDate());
updateDeadlineText(structuredMap.getDeadLine());
}
Aggregations