use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPStructureManager method copy.
/**
* Copy/Import structure elements recursively
* @param refLink
* @param targetEl
* @param withArtefacts Copy the artefacts
* @param importEl Don't load elements from the DB
* @param cloneRestrictions should the collect-restrictions be applied? you could also do this manually by copyCollectRestriction()
*/
private void copy(EPStructureToStructureLink refLink, EPStructureElement targetEl, boolean withArtefacts, boolean importEl, boolean cloneRestrictions) {
EPStructureElement childSourceEl = (EPStructureElement) refLink.getChild();
EPStructureElement clonedChildEl = instantiateClone(refLink.getChild());
if (clonedChildEl == null) {
log.warn("Attempt to clone an unsupported structure type: " + refLink.getChild(), null);
} else {
OLATResource resource = resourceManager.createOLATResourceInstance(clonedChildEl.getClass());
clonedChildEl.setOlatResource(resource);
// set root
if (targetEl.getRoot() == null) {
// it's the root element
clonedChildEl.setRoot(targetEl);
} else {
clonedChildEl.setRoot(targetEl.getRoot());
}
if (targetEl.getRootMap() == null && targetEl instanceof PortfolioStructureMap) {
clonedChildEl.setRootMap((PortfolioStructureMap) targetEl);
} else {
clonedChildEl.setRootMap(targetEl.getRootMap());
}
if (!importEl)
clonedChildEl.setStructureElSource(childSourceEl.getKey());
if (cloneRestrictions)
copyOrUpdateCollectRestriction(childSourceEl, clonedChildEl, true);
if (importEl) {
importEPStructureElementRecursively(childSourceEl, clonedChildEl);
} else {
copyEPStructureElementRecursively(childSourceEl, clonedChildEl, withArtefacts, cloneRestrictions);
}
EPStructureToStructureLink link = new EPStructureToStructureLink();
link.setParent(targetEl);
link.setChild(clonedChildEl);
targetEl.getInternalChildren().add(link);
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPStructureManager method createPortfolioPage.
/**
* Create a page element
* @param title
* @param description
* @return The structure element
*/
protected PortfolioStructure createPortfolioPage(PortfolioStructure root, String title, String description) {
EPPage el = new EPPage();
el.setRoot((EPStructureElement) root);
if (root != null && root.getRootMap() == null && root instanceof PortfolioStructureMap) {
el.setRootMap((PortfolioStructureMap) root);
} else if (root != null) {
el.setRootMap(root.getRootMap());
}
return fillStructureElement(el, title, description);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap 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.PortfolioStructureMap in project openolat by klemens.
the class EPFrontendManager method closeMapAfterDeadline.
/**
* Close all maps after the deadline if there is a deadline. It can be a long running
* process if a lot of maps are involved.
*/
public void closeMapAfterDeadline() {
List<PortfolioStructureMap> mapsToClose = structureManager.getOpenStructuredMapAfterDeadline();
int count = 0;
for (PortfolioStructureMap mapToClose : mapsToClose) {
submitMap(mapToClose, false, Role.auto);
if (count % 5 == 0) {
// this possibly takes longer than connection timeout, so do intermediatecommits.
dbInstance.intermediateCommit();
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPFrontendManager method createAndPersistPortfolioDefaultMap.
/**
* Create a map for a group
* @param root
* @param group
* @param title
* @param description
* @return
*/
public PortfolioStructureMap createAndPersistPortfolioDefaultMap(String title, String description) {
PortfolioStructureMap map = structureManager.createPortfolioDefaultMap(title, description);
structureManager.savePortfolioStructure(map);
return map;
}
Aggregations