Search in sources :

Example 16 with EPStructureElementToGroupRelation

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

the class EPStructureManager method removeBaseGroup.

private void removeBaseGroup(EPAbstractMap map) {
    Set<EPStructureElementToGroupRelation> relations = map.getGroups();
    if (relations != null) {
        for (EPStructureElementToGroupRelation relation : relations) {
            Group group = relation.getGroup();
            if (relation.isDefaultGroup()) {
                groupDao.removeMemberships(group);
                groupDao.removeGroup(group);
            }
        }
    }
}
Also used : Group(org.olat.basesecurity.Group) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)

Example 17 with EPStructureElementToGroupRelation

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

the class EPStructureManager method createPortfolioMapTemplate.

/**
 * Create a map template, create an OLAT resource and a repository entry with a security group
 * of type owner to the repository and add the identity has an owner.
 * @param identity
 * @param title
 * @param description
 * @return The structure element
 */
public PortfolioStructureMap createPortfolioMapTemplate(Identity identity, String title, String description) {
    EPStructuredMapTemplate el = new EPStructuredMapTemplate();
    fillStructureElement(el, title, description);
    // create a repository entry with default security settings
    RepositoryEntry re = createRepositoryEntry(identity, el.getOlatResource(), title);
    dbInstance.commit();
    Group ownerGroup = repositoryService.getDefaultGroup(re);
    EPStructureElementToGroupRelation relation = createBaseRelation(el, ownerGroup);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(relation);
    el.setGroups(relations);
    return el;
}
Also used : Group(org.olat.basesecurity.Group) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) RepositoryEntry(org.olat.repository.RepositoryEntry) HashSet(java.util.HashSet)

Example 18 with EPStructureElementToGroupRelation

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

the class EPStructureManager method createBaseRelation.

private EPStructureElementToGroupRelation createBaseRelation(EPStructureElement element, Group ownerGroup) {
    // create security group
    EPStructureElementToGroupRelation relation = new EPStructureElementToGroupRelation();
    relation.setDefaultGroup(true);
    relation.setCreationDate(new Date());
    relation.setGroup(ownerGroup);
    relation.setStructureElement(element);
    return relation;
}
Also used : EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) Date(java.util.Date)

Example 19 with EPStructureElementToGroupRelation

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

the class EPStructureManager method importPortfolioMapTemplate.

/**
 * Import the structure.
 * @param root
 * @param identity
 * @return
 */
public PortfolioStructureMap importPortfolioMapTemplate(PortfolioStructure root, OLATResource resource) {
    EPStructuredMapTemplate el = new EPStructuredMapTemplate();
    fillStructureElement(el, root.getTitle(), root.getDescription(), resource);
    EPStructuredMapTemplate rootTemp = (EPStructuredMapTemplate) root;
    rootTemp.setStructureElSource(null);
    el.setStyle(((EPStructureElement) root).getStyle());
    importEPStructureElementRecursively((EPStructureElement) root, el);
    // create an empty group
    Group ownerGroup = groupDao.createGroup();
    EPStructureElementToGroupRelation relation = createBaseRelation(el, ownerGroup);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(relation);
    el.setGroups(relations);
    return el;
}
Also used : Group(org.olat.basesecurity.Group) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) HashSet(java.util.HashSet)

Example 20 with EPStructureElementToGroupRelation

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

the class EPPolicyManager method applyPolicyToAllUsers.

private EPStructureElementToGroupRelation applyPolicyToAllUsers(EPMapPolicy wrapper, PortfolioStructureMap map) {
    List<EPStructureElementToGroupRelation> currentRelations = wrapper.getRelations();
    if (!currentRelations.isEmpty()) {
        EPStructureElementToGroupRelation currentRelation = currentRelations.get(0);
        updatePolicy(currentRelation, wrapper.getFrom(), wrapper.getTo());
        return currentRelation;
    }
    return createBaseRelation(map, null, EPMapPolicy.Type.allusers.name(), wrapper.getFrom(), wrapper.getTo());
}
Also used : EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)

Aggregations

EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)32 Group (org.olat.basesecurity.Group)14 HashSet (java.util.HashSet)10 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 BusinessGroup (org.olat.group.BusinessGroup)8 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)6 Invitation (org.olat.basesecurity.Invitation)4 Identity (org.olat.core.id.Identity)4 EPDefaultMap (org.olat.portfolio.model.structel.EPDefaultMap)2 EPMapShort (org.olat.portfolio.model.structel.EPMapShort)2 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)2 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2