use of org.olat.portfolio.model.structel.EPPage in project OpenOLAT by OpenOLAT.
the class EPStructureManager method instantiateClone.
private EPStructureElement instantiateClone(PortfolioStructure source) {
EPStructureElement targetEl = null;
// don't forget the inheritence
if (source instanceof EPPage) {
targetEl = new EPPage();
targetEl.setTitle(((EPPage) source).getTitle());
targetEl.setDescription(((EPPage) source).getDescription());
} else if (source instanceof EPStructureElement) {
targetEl = new EPStructureElement();
targetEl.setTitle(((EPStructureElement) source).getTitle());
targetEl.setDescription(((EPStructureElement) source).getDescription());
}
return targetEl;
}
use of org.olat.portfolio.model.structel.EPPage in project OpenOLAT by OpenOLAT.
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.EPPage in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method processStructure.
/**
* call the needed methods to really do the magic.
*/
private void processStructure(PortfolioStructure structuredMap) {
List<PortfolioStructure> linkedChildren = ePFMgr.loadStructureChildren(structuredMap);
for (PortfolioStructure childStruct : linkedChildren) {
// reload dbchildren in each run, because of filtering
List<PortfolioStructure> dbChildren;
if (childStruct instanceof EPPage) {
dbChildren = loadMapChildrenByInternalFK(childStruct, structuredMap);
} else {
dbChildren = loadMapChildrenByInternalFK(childStruct, structuredMap.getRoot());
}
// filter the struct that is already linked by a struct->struct link
// and filter such with other struct-source
filterLinkedStructs(childStruct, dbChildren);
log.audit(" found " + dbChildren.size() + " faulty children (of " + childStruct + ") linked by internal fk to be merged and removed afterwards.");
// merge artefacts to the linked struct
mergeLinkedArtefactsToFinalStruct(childStruct, dbChildren);
// collect comments on structures and merge to target
mergeCommentsToFinalStruct(childStruct, dbChildren);
// ratings are not merged, see OLAT-6306
// remove the old elements
removeWrongElements(dbChildren);
// fix root-reference on EPStructureElements
if (!(childStruct instanceof EPPage)) {
if (childStruct.getRoot().equals(childStruct.getRootMap())) {
EPStructureElement realParentRoot = (EPStructureElement) ePFMgr.loadStructureParent(childStruct);
((EPStructureElement) childStruct).setRoot(realParentRoot);
ePFMgr.savePortfolioStructure(childStruct);
}
}
}
// loop children
DBFactory.getInstance().intermediateCommit();
}
use of org.olat.portfolio.model.structel.EPPage in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method mergeCommentsToFinalStruct.
private void mergeCommentsToFinalStruct(PortfolioStructure finalStruct, List<PortfolioStructure> wrongStructs) {
if (wrongStructs == null || wrongStructs.isEmpty())
return;
List<UserComment> collectedComments = new ArrayList<UserComment>();
// collect all comments out there
for (PortfolioStructure portfolioStructure : wrongStructs) {
// no comments on StructureElements!
if (!(portfolioStructure instanceof EPPage))
return;
List<UserComment> oldComments = commentAndRatingService.getComments(portfolioStructure.getRootMap(), portfolioStructure.getKey().toString());
collectedComments.addAll(oldComments);
commentAndRatingService.deleteAllComments(portfolioStructure.getRootMap(), portfolioStructure.getKey().toString());
}
log.audit(" found " + collectedComments.size() + " comments for this structure, will be merged to new destination.");
if (collectedComments.size() == 0)
return;
Identity ident = collectedComments.get(0).getCreator();
UserComment topComment = commentAndRatingService.createComment(ident, finalStruct.getRootMap(), finalStruct.getKey().toString(), "The following comments were restored from a migration task to rescue lost data.");
// attach all to this info-comment
for (UserComment userComment : collectedComments) {
UserComment attachedComment = commentAndRatingService.replyTo(topComment, userComment.getCreator(), userComment.getComment());
// set original date
attachedComment.setCreationDate(userComment.getCreationDate());
commentAndRatingService.updateComment(attachedComment, attachedComment.getComment());
}
}
use of org.olat.portfolio.model.structel.EPPage in project OpenOLAT by OpenOLAT.
the class EPTOCController method refreshAddElements.
/**
* refreshing the add elements link to actual structure
* @param ureq
* @param struct maybe null -> hiding the add-button
*/
private void refreshAddElements(UserRequest ureq, PortfolioStructure struct) {
tocV.remove(tocV.getComponent("addElement"));
removeAsListenerAndDispose(addElCtrl);
if (struct != null) {
addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
if (struct instanceof EPPage) {
if (secCallback.canAddStructure()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
}
if (secCallback.canAddArtefact()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
}
} else if (struct instanceof EPAbstractMap) {
if (secCallback.canAddPage()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
}
} else {
// its a structure element
if (secCallback.canAddArtefact()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
}
}
listenTo(addElCtrl);
tocV.put("addElement", addElCtrl.getInitialComponent());
}
}
Aggregations