use of org.olat.portfolio.model.structel.EPStructuredMap in project openolat by klemens.
the class EPStructureManagerTest method testUseStructureMapTemplate.
@Test
public void testUseStructureMapTemplate() {
// save parent and 20 children
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(ident1, "paged-parent-structure-el", "parent-structure-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, ident1, "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("3894580");
targetResource.setBusinessPath("[RepositoryEntry:23647598][CourseNode:934598]");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// test
PortfolioStructureMap retrievedMap = (PortfolioStructureMap) epFrontendManager.loadPortfolioStructureByKey(map.getKey());
assertNotNull(retrievedMap);
assertNotNull(((EPStructuredMap) retrievedMap).getReturnDate());
assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
assertNotNull(((EPStructuredMap) retrievedMap).getTargetResource());
EPTargetResource retriviedTargetResource = ((EPStructuredMap) retrievedMap).getTargetResource();
assertEquals("CourseModule", retriviedTargetResource.getResourceableTypeName());
assertEquals(new Long(234l), retriviedTargetResource.getResourceableId());
assertEquals("3894580", retriviedTargetResource.getSubPath());
assertEquals("[RepositoryEntry:23647598][CourseNode:934598]", retriviedTargetResource.getBusinessPath());
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project openolat by klemens.
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 klemens.
the class EPMapViewController method preCheckMapSubmit.
private boolean preCheckMapSubmit() {
EPStructuredMap submittedMap = (EPStructuredMap) map;
try {
EPTargetResource resource = submittedMap.getTargetResource();
OLATResourceable courseOres = resource.getOLATResourceable();
ICourse course = CourseFactory.loadCourse(courseOres);
CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
if (courseNode == null)
return false;
} catch (Exception e) {
return false;
}
return true;
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project openolat by klemens.
the class EPMapViewController method initForm.
protected void initForm(UserRequest ureq) {
Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
if (ownerIdentity != null) {
DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
}
mainVc.contextPut("map", map);
mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
mainVc.remove(mainVc.getComponent("map.editButton"));
if (secCallback.canEditStructure()) {
editButton = LinkFactory.createButton("map.editButton", mainVc, this);
editButton.setElementCssClass("o_sel_ep_edit_map");
editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
if (editMode == EditMode.view) {
editButton.setCustomDisplayText(translate("map.editButton.on"));
} else {
editButton.setCustomDisplayText(translate("map.editButton.off"));
}
}
if (back) {
backLink = LinkFactory.createLinkBack(mainVc, this);
}
mainVc.remove(mainVc.getComponent("map.submit.assess"));
if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
}
if (map instanceof EPStructuredMap) {
EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
if (repoEntry != null) {
mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
String url = Settings.getServerContextPathURI();
url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
mainVc.contextPut("courseLink", url);
}
}
mainVc.remove(mainVc.getComponent("addButton"));
if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
if (secCallback.canAddPage()) {
addButton.setShowLink(EPAddElementsController.ADD_PAGE);
}
mainVc.put("addButton", addButton.getInitialComponent());
listenTo(addButton);
}
mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
if (pageList != null && pageList.size() != 0) {
// prepare to paint pages also
removeAsListenerAndDispose(pageCtrl);
pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
listenTo(pageCtrl);
} else if (mainVc.getComponent("pagesCtrl") != null) {
mainVc.remove(mainVc.getComponent("pagesCtrl"));
}
}
use of org.olat.portfolio.model.structel.EPStructuredMap in project OpenOLAT by OpenOLAT.
the class EPStructureManager method copyStructureRecursively.
protected void copyStructureRecursively(PortfolioStructure source, PortfolioStructure target, boolean withArtefacts) {
// all changes are overwritten
EPStructureElement targetEl = (EPStructureElement) target;
if (targetEl instanceof EPStructuredMap) {
((EPStructuredMap) targetEl).setCopyDate(new Date());
}
// update the source
dbInstance.updateObject(source);
// reconnect to the session
EPStructureElement sourceEl = (EPStructureElement) source;
targetEl.setStyle(sourceEl.getStyle());
copyEPStructureElementRecursively(sourceEl, targetEl, withArtefacts, true);
}
Aggregations