use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.
the class EPFrontendManager method createAndPersistPortfolioStructureElement.
/**
* create a structure-element
* @param root
* @param title
* @param description
* @return
*/
public PortfolioStructure createAndPersistPortfolioStructureElement(PortfolioStructure root, String title, String description) {
EPStructureElement newStruct = (EPStructureElement) structureManager.createPortfolioStructure(root, title, description);
if (root != null)
structureManager.addStructureToStructure(root, newStruct, -1);
structureManager.savePortfolioStructure(newStruct);
return newStruct;
}
use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.
the class EPFrontendManager method getValidStyleName.
/**
* get a valid name of style for a given PortfolioStructure
* if style is not enabled anymore, the default will be used.
* @param struct
* @return the set style or the default from config if nothing is set.
*/
public String getValidStyleName(PortfolioStructure struct) {
// first style in list is the default, can be named default.
List<String> allStyles = portfolioModule.getAvailableMapStyles();
if (allStyles == null || allStyles.size() == 0)
throw new AssertException("at least one style (that also exists in brasato.css must be configured for maps.");
String styleName = ((EPStructureElement) struct).getStyle();
if (StringHelper.containsNonWhitespace(styleName) && allStyles.contains(styleName)) {
return styleName;
}
return allStyles.get(0);
}
use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.
the class EPStructureManager method removeStructure.
/**
* Remove a child structure from its parent structure.
* @param parentStructure
* @param childStructure
*/
// this has to be done recursively for pages, structs also!
// also remove the artefacts from each!
public void removeStructure(PortfolioStructure parentStructure, PortfolioStructure childStructure) {
if (childStructure == null)
throw new NullPointerException();
// child not persisted
if (childStructure.getKey() == null)
return;
// cannot remove with no parent!
if (parentStructure == null)
return;
if (childStructure instanceof EPStructureElement) {
// save eventual changes
dbInstance.updateObject(parentStructure);
// reconnect to the session
EPStructureToStructureLink linkToDelete = null;
EPStructureElement parentStructureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) parentStructure);
for (Iterator<EPStructureToStructureLink> linkIt = parentStructureEl.getInternalChildren().iterator(); linkIt.hasNext(); ) {
EPStructureToStructureLink link = linkIt.next();
if (link.getChild().getKey().equals(childStructure.getKey())) {
linkIt.remove();
linkToDelete = link;
break;
}
}
// I have not set the cascade all delete
if (linkToDelete != null) {
dbInstance.updateObject(parentStructureEl);
dbInstance.deleteObject(linkToDelete);
}
}
if (parentStructure == childStructure) {
deleteRootStructure(childStructure);
return;
}
}
use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.
the class OLATUpgrade_7_1_1 method fixTemplateEntry.
private void fixTemplateEntry(PortfolioStructure template) {
List<PortfolioStructure> temps = new ArrayList<PortfolioStructure>();
recurseIntoTemplateAndCheck(new ArrayList<PortfolioStructure>(), temps, template);
for (PortfolioStructure portfolioStructure : temps) {
((EPStructureElement) portfolioStructure).setStructureElSource(null);
ePFMgr.savePortfolioStructure(portfolioStructure);
}
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method createPortfolioStructure.
/**
* Create a basic structure element
* @param title
* @param description
* @return The structure element
*/
protected PortfolioStructure createPortfolioStructure(PortfolioStructure root, String title, String description) {
EPStructureElement el = new EPStructureElement();
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);
}
Aggregations