use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method move.
private void move(PortfolioStructure parentStructure, PortfolioStructure childStructure, boolean up) {
if (childStructure == null || parentStructure == null)
throw new NullPointerException();
if (parentStructure instanceof EPStructureElement) {
// save eventual changes
dbInstance.updateObject(parentStructure);
// reconnect to the session
EPStructureElement structureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) parentStructure);
List<EPStructureToStructureLink> structureLinks = structureEl.getInternalChildren();
int index = indexOf(structureLinks, childStructure);
if (up && index > 0) {
// swap the link with the previous link in the list
Collections.swap(structureLinks, index, index - 1);
dbInstance.updateObject(structureEl);
} else if (!up && (index >= 0 && index < (structureLinks.size() - 1))) {
// swap the link with the next link in the list
Collections.swap(structureLinks, index, index + 1);
dbInstance.updateObject(structureEl);
}
}
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method addCollectRestriction.
/**
* Add or update a restriction to the collection of artefacts for a given structure element
* @param structure
* @param artefactType
* @param restriction
* @param amount
*/
public void addCollectRestriction(PortfolioStructure structure, String artefactType, String restriction, int amount) {
if (structure == null)
throw new NullPointerException("Structure cannot be null");
EPStructureElement structEl = (EPStructureElement) structure;
List<CollectRestriction> restrictions = structEl.getCollectRestrictions();
CollectRestriction cr = new CollectRestriction();
cr.setArtefactType(artefactType);
cr.setRestriction(restriction);
cr.setAmount(amount);
restrictions.add(cr);
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getReflexionForArtefactToStructureLink.
protected String getReflexionForArtefactToStructureLink(AbstractArtefact artefact, PortfolioStructure structure) {
if (structure == null)
return null;
EPStructureElement structureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) structure);
List<EPStructureToArtefactLink> links = structureEl.getInternalArtefacts();
for (EPStructureToArtefactLink epStructureToArtefactLink : links) {
if (epStructureToArtefactLink.getArtefact().getKey().equals(artefact.getKey())) {
return epStructureToArtefactLink.getReflexion();
}
}
return null;
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method syncStructureRecursively.
/**
* Sync the tree structure recursively with or without artefacts
* @param sourceEl
* @param targetEl
* @param withArtefacts
*/
protected void syncStructureRecursively(PortfolioStructure source, PortfolioStructure target, boolean withArtefacts) {
// all changes are overwritten
EPStructureElement sourceEl = (EPStructureElement) source;
// update the source
dbInstance.updateObject(target);
// reconnect to the session
EPStructureElement targetEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) target);
syncEPStructureElementRecursively(sourceEl, targetEl, withArtefacts);
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
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);
}
Aggregations