Search in sources :

Example 6 with EPMapShort

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

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 7 with EPMapShort

use of org.olat.portfolio.model.structel.EPMapShort 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 8 with EPMapShort

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

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 9 with EPMapShort

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

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)

Example 10 with EPMapShort

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

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)

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