use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class CollaborationTools method createPortfolioController.
/**
* @param ureq
* @param wControl
* @param mapProperty The property is mandatory!
* @return
*/
private Controller createPortfolioController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, Property mapProperty) {
Long key = mapProperty.getLongValue();
String version = mapProperty.getStringValue();
Controller ctrl;
if ("2".equals(version)) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
Binder binder = portfolioService.getBinderByKey(key);
portfolioService.updateBinderUserInformations(binder, ureq.getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForBusinessGroup();
BinderController binderCtrl = new BinderController(ureq, wControl, stackPanel, secCallback, binder, BinderConfiguration.createBusinessGroupConfig());
ctrl = binderCtrl;
} else {
PortfolioStructureMap map = (PortfolioStructureMap) CoreSpringFactory.getImpl(EPFrontendManager.class).loadPortfolioStructureByKey(key);
EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
ctrl = EPUIFactory.createMapViewController(ureq, wControl, map, secCallback);
}
return ctrl;
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class CollaborationTools method createPortfolioController.
/**
* return an controller for the wiki tool
* @param ureq
* @param wControl
* @return
*/
public Controller createPortfolioController(final UserRequest ureq, final WindowControl wControl, final TooledStackedPanel stackPanel, final BusinessGroup group) {
final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
Property mapProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
if (mapProperty != null) {
return createPortfolioController(ureq, wControl, stackPanel, mapProperty);
} else {
return coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Controller>() {
@Override
public Controller execute() {
Controller ctrl;
Property mapKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
if (mapKeyProperty == null) {
PortfolioV2Module moduleV2 = CoreSpringFactory.getImpl(PortfolioV2Module.class);
if (moduleV2.isEnabled()) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
Binder binder = portfolioService.createNewBinder(group.getName(), group.getDescription(), null, null);
CoreSpringFactory.getImpl(BinderUserInformationsDAO.class).updateBinderUserInformationsInSync(binder, ureq.getIdentity());
mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, binder.getKey(), "2", null);
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForBusinessGroup();
BinderController binderCtrl = new BinderController(ureq, wControl, stackPanel, secCallback, binder, BinderConfiguration.createBusinessGroupConfig());
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType("Toc");
binderCtrl.activate(ureq, entries, null);
ctrl = binderCtrl;
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(binder));
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_BINDER_CREATED, getClass());
} else {
EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
PortfolioStructureMap map = ePFMgr.createAndPersistPortfolioDefaultMap(group.getName(), group.getDescription());
Translator pT = Util.createPackageTranslator(EPCreateMapController.class, ureq.getLocale());
// add a page, as each map should have at least one per default!
ePFMgr.createAndPersistPortfolioPage(map, pT.translate("new.page.title"), pT.translate("new.page.desc"));
mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, map.getKey(), null, null);
EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
ctrl = EPUIFactory.createMapViewController(ureq, wControl, map, secCallback);
}
npm.saveProperty(mapKeyProperty);
} else {
ctrl = createPortfolioController(ureq, wControl, stackPanel, mapProperty);
}
return ctrl;
}
});
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method testCopyMap.
@Test
public void testCopyMap() {
// create two artefacts
AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
assertNotNull(artefact1);
AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact2);
dbInstance.commitAndCloseSession();
// create a map with a page and the page has two artefacts
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
assertTrue(successfullLink1);
boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
assertTrue(successfullLink2);
dbInstance.commitAndCloseSession();
// 1 test: copy the map one shoot
PortfolioStructureMap copyMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy", "Description copy");
epFrontendManager.copyStructureRecursively(originalMap, copyMap, true);
assertNotNull(copyMap.getKey());
dbInstance.commitAndCloseSession();
// 2 test: copy the map two shoota
PortfolioStructureMap copyMap2 = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy 2", "Description copy 2");
dbInstance.commitAndCloseSession();
assertNotNull(copyMap2.getKey());
epFrontendManager.copyStructureRecursively(originalMap, copyMap2, true);
dbInstance.commitAndCloseSession();
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method closedArtefacts.
@Test
public void closedArtefacts() {
// create two artefacts
AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
assertNotNull(artefact1);
AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact2);
dbInstance.commitAndCloseSession();
// create a map with a page and the page has two artefacts
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
assertTrue(successfullLink1);
boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
assertTrue(successfullLink2);
dbInstance.commitAndCloseSession();
// check if the artefact is in a closed map
assertFalse(epFrontendManager.isArtefactClosed(artefact1));
assertFalse(epFrontendManager.isArtefactClosed(artefact2));
// closed the map artificially
((EPDefaultMap) originalMap).setStatus(StructureStatusEnum.CLOSED);
dbInstance.updateObject(originalMap);
dbInstance.commitAndCloseSession();
// check if the artefact is in a closed map
assertTrue(epFrontendManager.isArtefactClosed(artefact1));
assertTrue(epFrontendManager.isArtefactClosed(artefact2));
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method saveMapPolicy.
@Test
public void saveMapPolicy() {
// create a map
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Policies", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
// policies are empty
List<EPMapPolicy> policies = epFrontendManager.getMapPolicies(map);
// owner policy
assertEquals(0, policies.size());
// save a user policy
EPMapPolicy userPolicy = new EPMapPolicy();
userPolicy.setType(Type.user);
userPolicy.getIdentities().add(ident2);
epFrontendManager.updateMapPolicies(map, Collections.singletonList(userPolicy));
dbInstance.commitAndCloseSession();
// one policy
List<EPMapPolicy> policies1 = epFrontendManager.getMapPolicies(map);
assertEquals(1, policies1.size());
// check visiblity (is owner)
assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
// check visibility (is in policy)
assertTrue(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
// check not visible (not in policy)
assertFalse(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
}
Aggregations