Search in sources :

Example 6 with EPStructureElementToGroupRelation

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

the class EPStructureManager method createBaseGroup.

private EPStructureElementToGroupRelation createBaseGroup(EPStructureElement element, Identity author) {
    // create security group
    Group ownerGroup = groupDao.createGroup();
    EPStructureElementToGroupRelation relation = new EPStructureElementToGroupRelation();
    relation.setDefaultGroup(true);
    relation.setCreationDate(new Date());
    relation.setGroup(ownerGroup);
    relation.setStructureElement(element);
    groupDao.addMembershipTwoWay(ownerGroup, author, GroupRoles.owner.name());
    return relation;
}
Also used : Group(org.olat.basesecurity.Group) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) Date(java.util.Date)

Example 7 with EPStructureElementToGroupRelation

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

the class EPStructureManager method createAndPersistPortfolioMapTemplateFromEntry.

/**
 * Create a template map with the given repsoitory entry and olat resource (in the repository entry).
 * The repository entry must already be persisted.
 * @param identity
 * @param entry
 * @return
 */
public PortfolioStructureMap createAndPersistPortfolioMapTemplateFromEntry(Identity identity, RepositoryEntry entry) {
    EPStructuredMapTemplate el = (EPStructuredMapTemplate) loadPortfolioStructure(entry.getOlatResource());
    if (el == null) {
        el = new EPStructuredMapTemplate();
    }
    el.setTitle(entry.getDisplayname());
    el.setDescription(entry.getDescription());
    el.setOlatResource(entry.getOlatResource());
    // create security group
    Group group = repositoryEntyRelationDao.getDefaultGroup(entry);
    if (group == null) {
        group = groupDao.createGroup();
        groupDao.addMembershipTwoWay(group, identity, GroupRoles.owner.name());
    }
    EPStructureElementToGroupRelation relation = createBaseRelation(el, group);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(relation);
    el.setGroups(relations);
    dbInstance.saveObject(el);
    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 8 with EPStructureElementToGroupRelation

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

the class EPStructureManager method createPortfolioDefaultMap.

protected PortfolioStructureMap createPortfolioDefaultMap(Identity identity, String title, String description) {
    EPDefaultMap el = new EPDefaultMap();
    fillStructureElement(el, title, description);
    // create security group
    EPStructureElementToGroupRelation ownerGroup = createBaseGroup(el, identity);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(ownerGroup);
    el.setGroups(relations);
    return el;
}
Also used : EPDefaultMap(org.olat.portfolio.model.structel.EPDefaultMap) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) HashSet(java.util.HashSet)

Example 9 with EPStructureElementToGroupRelation

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

the class EPStructureManager method createPortfolioStructuredMap.

protected PortfolioStructureMap createPortfolioStructuredMap(PortfolioStructureMap template, Identity identity, String title, String description, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
    EPStructuredMap el = new EPStructuredMap();
    el.setStructuredMapSource((EPStructuredMapTemplate) template);
    el.setStructureElSource(template.getKey());
    if (template != null) {
        copyOrUpdateCollectRestriction(template, el, false);
    }
    EPTargetResource targetResource = el.getTargetResource();
    if (targetOres != null) {
        targetResource.setResourceableId(targetOres.getResourceableId());
        targetResource.setResourceableTypeName(targetOres.getResourceableTypeName());
    }
    if (StringHelper.containsNonWhitespace(targetSubPath)) {
        targetResource.setSubPath(targetSubPath);
    }
    if (StringHelper.containsNonWhitespace(targetBusinessPath)) {
        targetResource.setBusinessPath(targetBusinessPath);
    }
    fillStructureElement(el, title, description);
    // create security group
    EPStructureElementToGroupRelation ownerGroup = createBaseGroup(el, identity);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(ownerGroup);
    el.setGroups(relations);
    return el;
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) HashSet(java.util.HashSet)

Example 10 with EPStructureElementToGroupRelation

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

the class EPPolicyManager method getEquivalentWrapper.

private EPMapPolicy getEquivalentWrapper(EPStructureElementToGroupRelation relation, List<EPMapPolicy> policies) {
    Date to = relation.getValidTo();
    Date from = relation.getValidFrom();
    String role = relation.getRole();
    a_a: for (EPMapPolicy policy : policies) {
        for (EPStructureElementToGroupRelation p : policy.getRelations()) {
            if (!role.equals(p.getRole())) {
                continue a_a;
            }
            if (from == null && p.getValidFrom() == null || (from != null && p.getValidFrom() != null && from.equals(p.getValidFrom()))) {
                if (to == null && p.getValidTo() == null || (to != null && p.getValidTo() != null && to.equals(p.getValidTo()))) {
                    return policy;
                }
            }
        }
    }
    return null;
}
Also used : EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) Date(java.util.Date)

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