Search in sources :

Example 91 with PortfolioStructure

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

the class EPStructureManager method loadPortfolioStructure.

/**
 * @param olatResourceable cannot be null
 * @return The structure element or null if not found
 */
public PortfolioStructure loadPortfolioStructure(OLATResourceable olatResourceable) {
    if (olatResourceable == null)
        throw new NullPointerException();
    OLATResource resource = resourceManager.findResourceable(olatResourceable);
    if (resource == null)
        return null;
    StringBuilder sb = new StringBuilder();
    sb.append("select element from ").append(EPStructureElement.class.getName()).append(" element").append(" where element.olatResource=:resource");
    List<PortfolioStructure> resources = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructure.class).setParameter("resource", resource).getResultList();
    // if not found, it is an empty list
    return resources.isEmpty() ? null : resources.get(0);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource)

Example 92 with PortfolioStructure

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

the class EPFrontendManager method deleteUserData.

@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
    deleteUsersArtefacts(identity);
    List<PortfolioStructure> userPersonalMaps = getStructureElementsForUser(identity, ElementType.DEFAULT_MAP, ElementType.STRUCTURED_MAP);
    for (PortfolioStructure portfolioStructure : userPersonalMaps) {
        deletePortfolioStructure(portfolioStructure);
    }
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 93 with PortfolioStructure

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

the class EPFrontendManager method deleteGroupDataFor.

@Override
public boolean deleteGroupDataFor(BusinessGroup group) {
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(group);
    final Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
    if (mapKeyProperty != null) {
        final Long mapKey = mapKeyProperty.getLongValue();
        final String version = mapKeyProperty.getStringValue();
        if (!"2".equals(version)) {
            final PortfolioStructure map = loadPortfolioStructureByKey(mapKey);
            if (map != null) {
                deletePortfolioStructure(map);
            }
        }
        return true;
    }
    return false;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 94 with PortfolioStructure

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

the class EPFrontendManager method deleteArtefact.

/**
 * delete an artefact and also its vfs-artefactContainer
 * all used tags will also be deleted.
 * @param artefact
 */
public void deleteArtefact(AbstractArtefact artefact) {
    List<PortfolioStructure> linksToArtefact = structureManager.getAllReferencesForArtefact(artefact);
    for (PortfolioStructure portfolioStructure : linksToArtefact) {
        structureManager.removeArtefactFromStructure(artefact, portfolioStructure);
    }
    // load again as session might be closed between
    artefact = artefactManager.loadArtefactByKey(artefact.getKey());
    artefactManager.deleteArtefact(artefact);
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 95 with PortfolioStructure

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

the class EPStructureManager method getStructureElementsFromOthersWithoutPublic.

protected List<PortfolioStructure> getStructureElementsFromOthersWithoutPublic(IdentityRef ident, IdentityRef choosenOwner, ElementType... types) {
    StringBuilder sb = new StringBuilder();
    sb.append("select stEl from ").append(EPStructureElement.class.getName()).append(" stEl ").append(" inner join fetch stEl.olatResource as oRes ").append(" inner join stEl.groups as relGroup on relGroup.defaultGroup=false").append(" inner join relGroup.group as baseGroup").append(" inner join baseGroup.members as members").append(" where members.identity.key=:identityKey").append(" and (relGroup.validFrom is null or relGroup.validFrom<=:date)").append(" and (relGroup.validTo is null or relGroup.validTo>=:date)");
    if (choosenOwner != null) {
        sb.append(" and exists (select sgmsi from bgroupmember as sgmsi ").append("   where sgmsi.group=baseGroup and sgmsi.identity.key=:ownerKey").append(" )");
    }
    if (types != null && types.length > 0) {
        sb.append(" and type(stEl) in (");
        boolean first = true;
        for (ElementType type : types) {
            if (first)
                first = false;
            else
                sb.append(",");
            sb.append(getImplementation(type).getName());
        }
        sb.append(")");
    }
    TypedQuery<PortfolioStructure> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructure.class).setParameter("identityKey", ident.getKey()).setParameter("date", new Date());
    if (choosenOwner != null) {
        query.setParameter("ownerKey", choosenOwner.getKey());
    }
    return query.getResultList();
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) ElementType(org.olat.portfolio.model.structel.ElementType) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Date(java.util.Date)

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