use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class PortfolioHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
EPStructureManager eSTMgr = CoreSpringFactory.getImpl(EPStructureManager.class);
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
OLATResource resource = eSTMgr.createPortfolioMapTemplateResource();
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
PortfolioStructureMap mapTemp = eSTMgr.createAndPersistPortfolioMapTemplateFromEntry(initialAuthor, re);
// add a page, as each map should have at least one per default!
Translator pt = Util.createPackageTranslator(EPCreateMapController.class, locale);
String pageTitle = pt.translate("new.page.title");
String pageDescription = pt.translate("new.page.desc");
ePFMgr.createAndPersistPortfolioPage(mapTemp, pageTitle, pageDescription);
DBFactory.getInstance().commit();
return re;
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class AbstractPortfolioMapIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext resourceContext = new SearchResourceContext();
int firstResult = 0;
List<PortfolioStructure> structures = null;
do {
structures = frontendManager.getStructureElements(firstResult, 500, getElementType());
for (PortfolioStructure structure : structures) {
if (structure instanceof PortfolioStructureMap) {
PortfolioStructureMap map = (PortfolioStructureMap) structure;
if (accept(map)) {
resourceContext.setDocumentType(getDocumentType());
resourceContext.setBusinessControlFor(map.getOlatResource());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
firstResult += structures.size();
} while (structures != null && structures.size() == BATCH_SIZE);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPMultipleMapController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
super.event(ureq, source, event);
if (source == delMapCtrl) {
if (DialogBoxUIFactory.isYesEvent(event)) {
PortfolioStructure mapToDel = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
String title = mapToDel.getTitle();
ePFMgr.deletePortfolioStructure(mapToDel);
showInfo("delete.map.success", title);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(mapToDel));
ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_MAP_REMOVED, getClass());
initOrUpdateMaps(ureq);
}
} else if (source == copyMapCtrl) {
if (event.equals(Event.CANCELLED_EVENT)) {
fireEvent(ureq, Event.CANCELLED_EVENT);
return;
}
int pos = DialogBoxUIFactory.getButtonPos(event);
boolean withArtefacts = false;
PortfolioStructure mapToCopy = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
// shift clicked pos, when "with artefacts" was hidden before
if (!ePFMgr.isMapOwner(getIdentity(), mapToCopy))
pos++;
if (pos == 2) {
// clicked cancel button
fireEvent(ureq, Event.CANCELLED_EVENT);
return;
} else if (pos == 0)
withArtefacts = true;
PortfolioStructureMap targetMap = ePFMgr.createAndPersistPortfolioDefaultMap(getIdentity(), translate("map.copy.of", mapToCopy.getTitle()), mapToCopy.getDescription());
ePFMgr.copyStructureRecursively(mapToCopy, targetMap, withArtefacts);
// open the map
String title = targetMap.getTitle();
showInfo("copy.map.success", title);
initOrUpdateMaps(ureq);
String businessPath = "[" + targetMap.getClass().getSimpleName() + ":" + targetMap.getResourceableId() + "]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
} else if (source == mapViewCtrl) {
if (EPStructureEvent.CLOSE.equals(event.getCommand())) {
myPanel.popContent();
fireEvent(ureq, event);
removeAsListenerAndDispose(mapViewCtrl);
mapViewCtrl = null;
// refresh on close (back-link) to prevent stale object errors, when map got changed meanwhile
initOrUpdateMaps(ureq);
addToHistory(ureq);
} else if (EPStructureEvent.SUBMIT.equals(event.getCommand()) || event.equals(Event.CHANGED_EVENT)) {
// refresh on submission of a map or on any other changes which needs an ui-update
initOrUpdateMaps(ureq);
}
} else if (source == shareListController) {
shareBox.deactivate();
removeAsListenerAndDispose(shareListController);
initOrUpdateMaps(ureq);
}
if (event instanceof EPStructureChangeEvent) {
// event from child
String evCmd = event.getCommand();
if (evCmd.equals(EPStructureChangeEvent.ADDED) || evCmd.equals(EPStructureChangeEvent.CHANGED)) {
initOrUpdateMaps(ureq);
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPMultipleMapController method activateMap.
private void activateMap(UserRequest ureq, Long mapKey) {
if (mapKey == null)
return;
boolean foundTheMap = false;
// we have a key, find the corresponding map with the current option (restrcited view or not)
for (PortfolioStructureMap map : userMaps) {
if (map.getKey().equals(mapKey) || (map.getResourceableId().equals(mapKey))) {
activateMap(ureq, map);
fireEvent(ureq, new EPMapEvent(EPStructureEvent.SELECT, map));
foundTheMap = true;
break;
}
}
if (!foundTheMap) {
// map not found, switch the option and retry to found the map
restrictShareView = !restrictShareView;
initOrUpdateMaps(ureq);
for (PortfolioStructureMap map : userMaps) {
if (map.getKey().equals(mapKey) || (map.getResourceableId().equals(mapKey))) {
activateMap(ureq, map);
fireEvent(ureq, new EPMapEvent(EPStructureEvent.SELECT, map));
break;
}
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPCreateMapController method formOK.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(UserRequest ureq) {
String mapTitle = titleEl.getValue();
String mapDesc = descEl.getValue();
PortfolioStructureMap resMap = ePFMgr.createAndPersistPortfolioDefaultMap(getIdentity(), mapTitle, mapDesc);
// add a page, as each map should have at least one per default!
String title = translate("new.page.title");
String description = translate("new.page.desc");
ePFMgr.createAndPersistPortfolioPage(resMap, title, description);
// refresh to get all elements with db-keys
resMap = (PortfolioStructureMap) ePFMgr.loadPortfolioStructureByKey(resMap.getKey());
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(resMap));
ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_MAP_CREATED, getClass());
fireEvent(ureq, new EPMapCreatedEvent(resMap));
}
Aggregations