Search in sources :

Example 1 with EPMapShort

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

the class EPNotificationsHandler method getTitleItemForPublisher.

/**
 * returns a TitleItem instance for the given Publisher p If you already
 * have a reference to the map, use
 * <code>getTitleItemForMap(EPAbstractMap amap)</code>
 *
 * @param p
 * @return
 */
private TitleItem getTitleItemForPublisher(Publisher p) {
    Long resId = p.getResId();
    if (logger.isDebug())
        logger.debug("loading map with resourceableid: " + resId);
    EPFrontendManager epMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    EPMapShort map = epMgr.loadMapShortByResourceId(resId);
    return getTitleItemForMap(map);
}
Also used : EPMapShort(org.olat.portfolio.model.structel.EPMapShort)

Example 2 with EPMapShort

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

the class EPPolicyManager method getMapPolicies.

/**
 * Return a list of wrapper containing the read policies of the map
 * @param map
 */
public List<EPMapPolicy> getMapPolicies(PortfolioStructureMapRef mapRef) {
    EPMapShort map = dbInstance.getCurrentEntityManager().find(EPMapShort.class, mapRef.getKey());
    List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
    Set<EPStructureElementToGroupRelation> relations = map.getGroups();
    for (EPStructureElementToGroupRelation relation : relations) {
        if (relation.isDefaultGroup()) {
            continue;
        }
        EPMapPolicy policy = getEquivalentWrapper(relation, policies);
        if (policy == null) {
            policy = new EPMapPolicy();
            policy.setTo(relation.getValidTo());
            policy.setFrom(relation.getValidFrom());
            policies.add(policy);
        }
        String role = relation.getRole();
        if (role.startsWith(EPMapPolicy.Type.user.name())) {
            List<Identity> identities = groupDao.getMembers(relation.getGroup(), GroupRoles.participant.name());
            policy.addRelation(relation);
            policy.setType(EPMapPolicy.Type.user);
            policy.addIdentities(identities);
        } else if (role.startsWith(EPMapPolicy.Type.group.name())) {
            policy.addRelation(relation);
            BusinessGroup group = businessGroupDao.findBusinessGroup(relation.getGroup());
            policy.addGroup(group);
            policy.setType(EPMapPolicy.Type.group);
        } else if (role.startsWith(EPMapPolicy.Type.invitation.name())) {
            policy.addRelation(relation);
            Invitation invitation = invitationDao.findInvitation(relation.getGroup());
            policy.setInvitation(invitation);
            policy.setType(EPMapPolicy.Type.invitation);
        } else if (role.startsWith(EPMapPolicy.Type.allusers.name())) {
            policy.addRelation(relation);
            policy.setType(EPMapPolicy.Type.allusers);
        }
    }
    return policies;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) Identity(org.olat.core.id.Identity) EPMapShort(org.olat.portfolio.model.structel.EPMapShort)

Example 3 with EPMapShort

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

the class EPStructureManager method loadMapShortByResourceId.

/**
 * @param olatResourceable cannot be null
 * @return The structure element or null if not found
 */
public EPMapShort loadMapShortByResourceId(Long resourceableId) {
    StringBuilder sb = new StringBuilder();
    sb.append("select element from ").append(EPMapShort.class.getName()).append(" element").append(" inner join fetch element.olatResource resource").append(" where resource.resId=:resourceId and resource.resName in ('EPDefaultMap','EPStructuredMap','EPStructuredMapTemplate')");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setLong("resourceId", resourceableId);
    @SuppressWarnings("unchecked") List<EPMapShort> resources = query.list();
    // if not found, it is an empty list
    if (resources.isEmpty())
        return null;
    return resources.get(0);
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery) EPMapShort(org.olat.portfolio.model.structel.EPMapShort)

Example 4 with EPMapShort

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

the class EPNotificationsHandler method getTitleItemForPublisher.

/**
 * returns a TitleItem instance for the given Publisher p If you already
 * have a reference to the map, use
 * <code>getTitleItemForMap(EPAbstractMap amap)</code>
 *
 * @param p
 * @return
 */
private TitleItem getTitleItemForPublisher(Publisher p) {
    Long resId = p.getResId();
    if (logger.isDebug())
        logger.debug("loading map with resourceableid: " + resId);
    EPFrontendManager epMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    EPMapShort map = epMgr.loadMapShortByResourceId(resId);
    return getTitleItemForMap(map);
}
Also used : EPMapShort(org.olat.portfolio.model.structel.EPMapShort)

Example 5 with EPMapShort

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

the class EPNotificationsHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher publisher = subscriber.getPublisher();
    EPFrontendManager epMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    EPMapShort amap = epMgr.loadMapShortByResourceId(publisher.getResId());
    if (isInkoveValid(amap, compareDate, publisher)) {
        // init the helper;
        String rootBusinessPath = "[EPDefaultMap:" + amap.getKey() + "]";
        EPNotificationsHelper helper = new EPNotificationsHelper(rootBusinessPath, locale);
        String resName = amap.getOlatResource().getResourceableTypeName();
        si = new SubscriptionInfo(subscriber.getKey(), publisher.getType(), getTitleItemForMap(amap), null);
        List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
        // get subscriptionListItems according to map type
        if ("EPDefaultMap".equals(resName) || "EPStructuredMapTemplate".equals(resName)) {
            allItems = helper.getAllSubscrItemsDefault(compareDate, amap);
        } else if ("EPStructuredMap".equals(resName)) {
            allItems = helper.getAllSubscrItemsStructured(compareDate, amap);
        }
        for (SubscriptionListItem item : allItems) {
            si.addSubscriptionListItem(item);
        }
    }
    if (si == null) {
        // no info, return empty
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    return si;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) EPMapShort(org.olat.portfolio.model.structel.EPMapShort)

Aggregations

EPMapShort (org.olat.portfolio.model.structel.EPMapShort)10 ArrayList (java.util.ArrayList)6 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)4 Date (java.util.Date)2 Invitation (org.olat.basesecurity.Invitation)2 DBQuery (org.olat.core.commons.persistence.DBQuery)2 Publisher (org.olat.core.commons.services.notifications.Publisher)2 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)2 Identity (org.olat.core.id.Identity)2 BusinessGroup (org.olat.group.BusinessGroup)2 EPNotificationsHelper (org.olat.portfolio.manager.EPNotificationsHelper)2 EPDefaultMap (org.olat.portfolio.model.structel.EPDefaultMap)2 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)2 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)2 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)2