Search in sources :

Example 21 with EPStructuredMapTemplate

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

the class EPChangelogController method updateChangelogDisplay.

/**
 * update the changelog-list according to selected date. this method is
 * invoked on initForm and again when user changes date in dateChooser
 */
private void updateChangelogDisplay() {
    // init the helper;
    String path = getWindowControl().getBusinessControl().getAsString();
    EPNotificationsHelper helper = new EPNotificationsHelper(path, getLocale());
    // get the date from the dateChooser component
    Date compareDate = dateChooser.getDate();
    EPMapShort mapShort = ePFMgr.loadMapShortByResourceId(map.getOlatResource().getResourceableId());
    List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
    // get subscriptionListItems according to map type
    if (map instanceof EPDefaultMap || map instanceof EPStructuredMapTemplate) {
        allItems = helper.getAllSubscrItemsDefault(compareDate, mapShort);
    } else if (map instanceof EPStructuredMap) {
        allItems = helper.getAllSubscrItemsStructured(compareDate, mapShort);
    }
    List<SubscriptionItemBundle> bundles = getItemBundlesForSubscriptionItems(allItems);
    flc.contextPut("subscriptionItems", bundles);
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) EPNotificationsHelper(org.olat.portfolio.manager.EPNotificationsHelper) ArrayList(java.util.ArrayList) EPDefaultMap(org.olat.portfolio.model.structel.EPDefaultMap) EPMapShort(org.olat.portfolio.model.structel.EPMapShort) Date(java.util.Date)

Example 22 with EPStructuredMapTemplate

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

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 23 with EPStructuredMapTemplate

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

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 24 with EPStructuredMapTemplate

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

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 25 with EPStructuredMapTemplate

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

the class EPStructureManager method loadPortfolioStructuredMap.

public PortfolioStructureMap loadPortfolioStructuredMap(IdentityRef identity, PortfolioStructureMap template, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
    if (template == null)
        throw new NullPointerException();
    if (!(template instanceof EPStructuredMapTemplate))
        throw new AssertException("Only template are acceptable");
    StringBuilder sb = new StringBuilder();
    sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" map").append(" left join fetch map.targetResource as targetResource").append(" inner join map.groups as relGroup on relGroup.defaultGroup=true").append(" inner join relGroup.group as baseGroup").append(" where map.structuredMapSource=:template");
    if (targetOres != null) {
        sb.append(" and targetResource.resourceableId=:resourceId").append(" and targetResource.resourceableTypeName=:resourceType");
    }
    if (targetSubPath != null) {
        sb.append(" and targetResource.subPath=:subPath");
    }
    if (targetBusinessPath != null) {
        sb.append(" and targetResource.businessPath=:businessPath");
    }
    sb.append(" and exists (select membership from bgroupmember as membership ").append("    where baseGroup=membership.group and membership.identity.key=:identityKey and membership.role='").append(GroupRoles.owner.name()).append("'").append(" )");
    TypedQuery<PortfolioStructureMap> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructureMap.class).setParameter("template", template).setParameter("identityKey", identity.getKey());
    if (targetOres != null) {
        query.setParameter("resourceId", targetOres.getResourceableId());
        query.setParameter("resourceType", targetOres.getResourceableTypeName());
    }
    if (targetSubPath != null) {
        query.setParameter("subPath", targetSubPath);
    }
    if (targetBusinessPath != null) {
        query.setParameter("businessPath", targetBusinessPath);
    }
    List<PortfolioStructureMap> maps = query.getResultList();
    // if not found, it is an empty list
    return maps.isEmpty() ? null : maps.get(0);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) AssertException(org.olat.core.logging.AssertException) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate)

Aggregations

EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)28 RepositoryEntry (org.olat.repository.RepositoryEntry)10 ArrayList (java.util.ArrayList)8 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)8 HashSet (java.util.HashSet)6 Group (org.olat.basesecurity.Group)6 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)6 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)6 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)4 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)4 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 Document (org.apache.lucene.document.Document)2 Test (org.junit.Test)2 CommentAndRatingService (org.olat.core.commons.services.commentAndRating.CommentAndRatingService)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2