Search in sources :

Example 21 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPStructureManager method getStructureElementsFromOthersLimited.

protected List<PortfolioStructure> getStructureElementsFromOthersLimited(Identity ident, Identity choosenOwner, int limitFrom, int limitTo, ElementType... types) {
    TypedQuery<PortfolioStructure> query = buildStructureElementsFromOthersLimitedQuery(choosenOwner, PortfolioStructure.class, types);
    // limits
    if (limitTo > 0 && (limitFrom < limitTo)) {
        query.setFirstResult(limitFrom);
        query.setMaxResults(limitTo - limitFrom);
    }
    query.setParameter("ident", ident).setParameter("date", new Date());
    if (choosenOwner != null) {
        query.setParameter("owner", choosenOwner);
    }
    return query.getResultList();
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Date(java.util.Date)

Example 22 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure 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);
    }
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) CommentAndRatingService(org.olat.core.commons.services.commentAndRating.CommentAndRatingService) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 23 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPStructureManager method getRestrictionStatisticsOfMap.

// count recursively
protected Integer[] getRestrictionStatisticsOfMap(PortfolioStructure structureMap, int done, int todo) {
    final List<PortfolioStructure> children = loadStructureChildren(structureMap);
    for (final PortfolioStructure child : children) {
        Integer[] childStat = getRestrictionStatisticsOfMap(child, done, todo);
        done = childStat[0];
        todo = childStat[1];
    }
    // summarize
    Integer[] statsArr = getRestrictionStatistics(structureMap);
    if (statsArr != null) {
        done += statsArr[0];
        todo += statsArr[1];
    }
    return new Integer[] { done, todo };
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 24 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure 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;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList)

Example 25 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPFrontendManager method checkAllCollectRestrictionRec.

protected boolean checkAllCollectRestrictionRec(PortfolioStructure structure) {
    boolean allOk = structureManager.checkCollectRestriction(structure);
    List<PortfolioStructure> children = structureManager.loadStructureChildren(structure);
    for (PortfolioStructure child : children) {
        allOk &= checkAllCollectRestrictionRec(child);
    }
    return allOk;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Aggregations

PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)236 Test (org.junit.Test)90 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)70 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)54 ArrayList (java.util.ArrayList)40 OLATResource (org.olat.resource.OLATResource)30 Identity (org.olat.core.id.Identity)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)22 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 EPPage (org.olat.portfolio.model.structel.EPPage)16 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)12 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)12 DBQuery (org.olat.core.commons.persistence.DBQuery)10 EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)10 Date (java.util.Date)8 Document (org.apache.lucene.document.Document)8 Link (org.olat.core.gui.components.link.Link)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)8