use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getReferencedMapsForArtefact.
protected List<PortfolioStructure> getReferencedMapsForArtefact(AbstractArtefact artefact) {
List<PortfolioStructure> pfList = getAllReferencesForArtefact(artefact);
List<PortfolioStructure> mapList = new ArrayList<PortfolioStructure>();
for (Iterator<?> iterator = pfList.iterator(); iterator.hasNext(); ) {
EPStructureElement portfolioStructure = (EPStructureElement) iterator.next();
EPStructureElement actStruct = portfolioStructure;
while (actStruct.getRoot() != null) {
EPStructureElement actRoot = actStruct.getRoot();
if (actRoot != null) {
actStruct = actRoot;
}
}
if (!mapList.contains(actStruct))
mapList.add(actStruct);
}
return mapList;
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method moveArtefactFromStructToStruct.
protected boolean moveArtefactFromStructToStruct(AbstractArtefact artefact, PortfolioStructure oldParStruct, PortfolioStructure newParStruct) {
EPStructureElement oldEPSt = (EPStructureElement) dbInstance.loadObject((EPStructureElement) oldParStruct);
Identity author = oldEPSt.getInternalArtefacts().get(0).getAuthor();
// old model without author, doesn't work!
if (author == null)
return false;
String reflexion = getReflexionForArtefactToStructureLink(artefact, oldParStruct);
removeArtefactFromStructure(artefact, oldParStruct);
boolean allOk = false;
allOk = addArtefactToStructure(author, artefact, newParStruct);
if (allOk)
return setReflexionForArtefactToStructureLink(artefact, newParStruct, reflexion);
return allOk;
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getRestrictionStatistics.
protected Integer[] getRestrictionStatistics(PortfolioStructure structure) {
if (structure instanceof EPStructureElement) {
EPStructureElement structEl = (EPStructureElement) structure;
structEl = (EPStructureElement) reloadPortfolioStructure(structEl);
final List<CollectRestriction> restrictions = structEl.getCollectRestrictions();
if (restrictions != null && !restrictions.isEmpty()) {
int todo = 0;
int done = 0;
List<AbstractArtefact> artefacts = getArtefacts(structEl);
for (CollectRestriction cR : restrictions) {
if (RestrictionsConstants.MIN.equals(cR.getRestriction()) || RestrictionsConstants.EQUAL.equals(cR.getRestriction())) {
todo += cR.getAmount();
int actualCRCount = countRestrictionType(artefacts, cR);
done += actualCRCount;
}
}
return new Integer[] { done, todo };
}
}
return null;
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method addArtefactToStructure.
/**
* Add a link between a structure element and an artefact
* @param author
* @param artefact
* @param structure
* @return
*/
protected boolean addArtefactToStructure(Identity author, AbstractArtefact artefact, PortfolioStructure structure) {
if (author == null || artefact == null || structure == null)
throw new NullPointerException();
if (structure instanceof EPStructureElement) {
EPStructureElement structureEl = (EPStructureElement) structure;
boolean canAdd = canAddArtefact(structureEl, artefact);
if (!canAdd) {
return false;
}
// save eventual changes
// TODO update the changes before dbInstance.updateObject(structureEl);
// reconnect to the session
structureEl = (EPStructureElement) dbInstance.loadObject(structureEl);
EPStructureToArtefactLink link = new EPStructureToArtefactLink();
link.setArtefact(artefact);
link.setStructureElement(structureEl);
link.setAuthor(author);
structureEl.getInternalArtefacts().add(link);
dbInstance.updateObject(structureEl);
return true;
}
return false;
}
use of org.olat.portfolio.model.structel.EPStructureElement in project OpenOLAT by OpenOLAT.
the class EPStructureManager method reOrderStructures.
protected boolean reOrderStructures(PortfolioStructure parent, PortfolioStructure orderSubject, int orderDest) {
EPStructureElement structureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) parent);
List<EPStructureToStructureLink> structureLinks = structureEl.getInternalChildren();
int oldPos = indexOf(structureLinks, orderSubject);
if (oldPos != orderDest && oldPos != -1) {
EPStructureToStructureLink link = structureLinks.remove(oldPos);
if (oldPos < orderDest) {
orderDest--;
}
if (orderDest < 0) {
orderDest = 0;
} else if (orderDest > structureLinks.size()) {
// place at end
orderDest = structureLinks.size() - 1;
}
structureLinks.add(orderDest, link);
dbInstance.updateObject(structureEl);
return true;
}
return false;
}
Aggregations