Search in sources :

Example 6 with PortletEntry

use of org.olat.core.gui.control.generic.portal.PortletEntry in project openolat by klemens.

the class GroupsPortletRunController method reloadModel.

@Override
protected void reloadModel(SortingCriteria sortCriteria) {
    if (sortCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) {
        BusinessGroupOrder order = null;
        if (sortCriteria.getSortingTerm() == SortingCriteria.ALPHABETICAL_SORTING) {
            order = sortCriteria.isAscending() ? BusinessGroupOrder.nameAsc : BusinessGroupOrder.nameDesc;
        } else if (sortCriteria.getSortingTerm() == SortingCriteria.DATE_SORTING) {
            order = sortCriteria.isAscending() ? BusinessGroupOrder.creationDateAsc : BusinessGroupOrder.creationDateDesc;
        }
        int maxEntries = sortCriteria.getMaxEntries();
        List<BusinessGroup> groupList = businessGroupService.findBusinessGroups(getIdentity(), maxEntries * 2, order);
        Set<BusinessGroup> removeDuplicates = new HashSet<BusinessGroup>(maxEntries);
        for (Iterator<BusinessGroup> it = groupList.iterator(); it.hasNext(); ) {
            BusinessGroup group = it.next();
            if (removeDuplicates.contains(group)) {
                it.remove();
            } else {
                removeDuplicates.add(group);
            }
        }
        List<BusinessGroup> uniqueList = groupList.subList(0, Math.min(maxEntries, groupList.size()));
        List<PortletEntry<BusinessGroupEntry>> entries = convertShortBusinessGroupToPortletEntryList(uniqueList, false);
        groupListModel.setObjects(entries);
        tableCtr.modelChanged();
    } else {
        reloadModel(getPersistentManuallySortedItems());
    }
}
Also used : PortletEntry(org.olat.core.gui.control.generic.portal.PortletEntry) BusinessGroupOrder(org.olat.group.BusinessGroupOrder) BusinessGroup(org.olat.group.BusinessGroup) HashSet(java.util.HashSet)

Example 7 with PortletEntry

use of org.olat.core.gui.control.generic.portal.PortletEntry in project OpenOLAT by OpenOLAT.

the class GroupsPortletRunController method convertBusinessGroupToPortletEntryList.

private List<PortletEntry<BusinessGroupEntry>> convertBusinessGroupToPortletEntryList(List<BusinessGroup> groups, boolean withDescription) {
    List<PortletEntry<BusinessGroupEntry>> convertedList = new ArrayList<PortletEntry<BusinessGroupEntry>>();
    for (BusinessGroup group : groups) {
        GroupPortletEntry entry = new GroupPortletEntry(group);
        if (withDescription) {
            entry.getValue().setDescription(group.getDescription());
        }
        convertedList.add(entry);
    }
    return convertedList;
}
Also used : PortletEntry(org.olat.core.gui.control.generic.portal.PortletEntry) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList)

Example 8 with PortletEntry

use of org.olat.core.gui.control.generic.portal.PortletEntry in project OpenOLAT by OpenOLAT.

the class GroupsPortletRunController method getPersistentManuallySortedItems.

/**
 * Retrieves the persistent manually sorted items for the current portlet.
 * @param ureq
 * @return
 */
private List<PortletEntry<BusinessGroupEntry>> getPersistentManuallySortedItems() {
    @SuppressWarnings("unchecked") Map<Long, Integer> storedPrefs = (Map<Long, Integer>) guiPreferences.get(Map.class, getPreferenceKey(SORTED_ITEMS_PREF));
    List<PortletEntry<BusinessGroupEntry>> portletEntryList;
    if (storedPrefs != null) {
        SearchBusinessGroupParams params = new SearchBusinessGroupParams(getIdentity(), true, true);
        params.setGroupKeys(storedPrefs.keySet());
        List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, null, 0, -1);
        portletEntryList = convertBusinessGroupToPortletEntryList(groups, false);
    } else {
        List<BusinessGroup> groups = new ArrayList<BusinessGroup>();
        portletEntryList = convertShortBusinessGroupToPortletEntryList(groups, false);
    }
    return getPersistentManuallySortedItems(portletEntryList);
}
Also used : PortletEntry(org.olat.core.gui.control.generic.portal.PortletEntry) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) Map(java.util.Map) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 9 with PortletEntry

use of org.olat.core.gui.control.generic.portal.PortletEntry in project OpenOLAT by OpenOLAT.

the class GroupsPortletRunController method reloadModel.

@Override
protected void reloadModel(SortingCriteria sortCriteria) {
    if (sortCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) {
        BusinessGroupOrder order = null;
        if (sortCriteria.getSortingTerm() == SortingCriteria.ALPHABETICAL_SORTING) {
            order = sortCriteria.isAscending() ? BusinessGroupOrder.nameAsc : BusinessGroupOrder.nameDesc;
        } else if (sortCriteria.getSortingTerm() == SortingCriteria.DATE_SORTING) {
            order = sortCriteria.isAscending() ? BusinessGroupOrder.creationDateAsc : BusinessGroupOrder.creationDateDesc;
        }
        int maxEntries = sortCriteria.getMaxEntries();
        List<BusinessGroup> groupList = businessGroupService.findBusinessGroups(getIdentity(), maxEntries * 2, order);
        Set<BusinessGroup> removeDuplicates = new HashSet<BusinessGroup>(maxEntries);
        for (Iterator<BusinessGroup> it = groupList.iterator(); it.hasNext(); ) {
            BusinessGroup group = it.next();
            if (removeDuplicates.contains(group)) {
                it.remove();
            } else {
                removeDuplicates.add(group);
            }
        }
        List<BusinessGroup> uniqueList = groupList.subList(0, Math.min(maxEntries, groupList.size()));
        List<PortletEntry<BusinessGroupEntry>> entries = convertShortBusinessGroupToPortletEntryList(uniqueList, false);
        groupListModel.setObjects(entries);
        tableCtr.modelChanged();
    } else {
        reloadModel(getPersistentManuallySortedItems());
    }
}
Also used : PortletEntry(org.olat.core.gui.control.generic.portal.PortletEntry) BusinessGroupOrder(org.olat.group.BusinessGroupOrder) BusinessGroup(org.olat.group.BusinessGroup) HashSet(java.util.HashSet)

Example 10 with PortletEntry

use of org.olat.core.gui.control.generic.portal.PortletEntry in project OpenOLAT by OpenOLAT.

the class InfoMessagePortletRunController method reloadModel.

@Override
protected void reloadModel(SortingCriteria criteria) {
    List<SubscriptionInfo> infos = NotificationsManager.getInstance().getSubscriptionInfos(getIdentity(), "InfoMessage");
    List<InfoSubscriptionItem> items = new ArrayList<InfoSubscriptionItem>();
    for (SubscriptionInfo info : infos) {
        for (SubscriptionListItem item : info.getSubscriptionListItems()) {
            items.add(new InfoSubscriptionItem(info, item));
        }
    }
    items = getSortedList(items, criteria);
    List<PortletEntry<InfoSubscriptionItem>> entries = convertToPortletEntryList(items);
    InfosTableModel model = new InfosTableModel(entries);
    tableController.setTableDataModel(model);
}
Also used : PortletEntry(org.olat.core.gui.control.generic.portal.PortletEntry) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo)

Aggregations

PortletEntry (org.olat.core.gui.control.generic.portal.PortletEntry)16 ArrayList (java.util.ArrayList)12 BusinessGroup (org.olat.group.BusinessGroup)8 Map (java.util.Map)4 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)4 RepositoryEntryLight (org.olat.repository.RepositoryEntryLight)4 HashSet (java.util.HashSet)2 Subscriber (org.olat.core.commons.services.notifications.Subscriber)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 BusinessGroupOrder (org.olat.group.BusinessGroupOrder)2 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2