use of org.olat.portfolio.model.structel.EPTargetResource in project OpenOLAT by OpenOLAT.
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.EPTargetResource 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.EPTargetResource 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.EPTargetResource 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.EPTargetResource 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));
}
Aggregations