use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method getArtefactPoolForUser.
protected List<AbstractArtefact> getArtefactPoolForUser(Identity ident) {
long start = System.currentTimeMillis();
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where author=:author");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setEntity("author", ident);
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
if (artefacts.isEmpty())
return null;
long duration = System.currentTimeMillis() - start;
if (isLogDebugEnabled())
logDebug("loading the full artefact pool took " + duration + "ms");
return artefacts;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method loadArtefactByKey.
/**
* Load the artefact by its primary key
*
* @param key The primary key
* @return The artefact or null if nothing found
*/
protected AbstractArtefact loadArtefactByKey(Long key) {
if (key == null)
throw new NullPointerException();
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where artefact=:key");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("key", key);
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
// if not found, it is an empty list
if (artefacts.isEmpty())
return null;
return artefacts.get(0);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getArtefacts.
/**
* Return the list of artefacts glued to this structure element
* @param structure
* @param firstResult
* @param maxResults
* @return
*/
public List<AbstractArtefact> getArtefacts(PortfolioStructure structure, int firstResult, int maxResults) {
StringBuilder sb = new StringBuilder();
sb.append("select link.artefact from ").append(EPStructureToArtefactLink.class.getName()).append(" link").append(" where link.structureElement.key=:structureElKey order by link.order");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("structureElKey", structure.getKey());
if (firstResult > 0) {
query.setFirstResult(firstResult);
}
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
return artefacts;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPStructureManager method removeStructureRecursively.
public void removeStructureRecursively(PortfolioStructure struct) {
List<PortfolioStructure> children = loadStructureChildren(struct);
for (PortfolioStructure childstruct : children) {
removeStructureRecursively(childstruct);
}
// remove artefact-links
List<AbstractArtefact> thisStructsArtefacts = getArtefacts(struct);
for (AbstractArtefact artefact : thisStructsArtefacts) {
removeArtefactFromStructure(artefact, struct, false);
}
// remove from parent
PortfolioStructure parent = loadStructureParent(struct);
if (parent == null && struct.getRoot() != null)
parent = struct.getRoot();
removeStructure(parent, struct);
// remove collect restriction
struct.getCollectRestrictions().clear();
// remove sharings
if (struct instanceof EPAbstractMap) {
((EPAbstractMap) struct).getGroups().clear();
}
// remove comments and ratings
CommentAndRatingService commentAndRatingService = CoreSpringFactory.getImpl(CommentAndRatingService.class);
commentAndRatingService.deleteAllIgnoringSubPath(struct.getOlatResource());
// FXOLAT-431 remove subscriptions if the current struct is a map
if (struct instanceof EPAbstractMap) {
SubscriptionContext subsContext = new SubscriptionContext(EPNotificationsHandler.TYPENNAME, struct.getResourceableId(), EPNotificationsHandler.TYPENNAME);
NotificationsManager.getInstance().delete(subsContext);
}
// remove structure itself
struct = (EPStructureElement) dbInstance.loadObject((EPStructureElement) struct);
dbInstance.deleteObject(struct);
if (struct instanceof EPAbstractMap) {
removeBaseGroup((EPAbstractMap) struct);
}
// which need the resource
if (!(struct instanceof EPStructuredMapTemplate)) {
resourceManager.deleteOLATResourceable(struct);
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact 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;
}
Aggregations