diff --git a/src/main/java/org/olat/bookmark/BookmarksPortletRunController.java b/src/main/java/org/olat/bookmark/BookmarksPortletRunController.java index 0d8c8140360a7e1f9ada01000922070321412be3..7eb5ccd553033a104d61753086e354d5e4ac866c 100644 --- a/src/main/java/org/olat/bookmark/BookmarksPortletRunController.java +++ b/src/main/java/org/olat/bookmark/BookmarksPortletRunController.java @@ -128,13 +128,13 @@ public class BookmarksPortletRunController extends AbstractPortletRunController putInitialPanel(bookmarksVC); //register for events targeted at this Identity - eventBusThisIdentityOres = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey()); + eventBusThisIdentityOres = OresHelper.createOLATResourceableInstance(Identity.class, getIdentity().getKey()); //TODO: LD: use this: //ureq.getUserSession().getSingleUserEventCenter().registerFor(this, ureq.getIdentity(), eventBusOres); - CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, ureq.getIdentity(), eventBusThisIdentityOres); + CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, getIdentity(), eventBusThisIdentityOres); //register for events targeted at all Identities (e.g. delete bookmark for a course if a course is deleted) eventBusAllIdentitiesOres = OresHelper.createOLATResourceableType(Identity.class); - CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, ureq.getIdentity(),eventBusAllIdentitiesOres); + CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, getIdentity(),eventBusAllIdentitiesOres); } /** @@ -144,7 +144,7 @@ public class BookmarksPortletRunController extends AbstractPortletRunController */ private List<PortletEntry> getAllPortletEntries() { BookmarkManager mb = BookmarkManager.getInstance(); - List<Bookmark> bookmarkList = mb.findBookmarksByIdentity(identity); + List<Bookmark> bookmarkList = mb.findBookmarksByIdentity(getIdentity()); return convertBookmarkToPortletEntryList(bookmarkList); } @@ -184,12 +184,12 @@ public class BookmarksPortletRunController extends AbstractPortletRunController protected void reloadModel(SortingCriteria sortingCriteria) { if (sortingCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) { BookmarkManager mb = BookmarkManager.getInstance(); - List<Bookmark> bookmarkList = mb.findBookmarksByIdentity(identity); + List<Bookmark> bookmarkList = mb.findBookmarksByIdentity(getIdentity()); bookmarkList = getSortedList(bookmarkList, sortingCriteria ); List<PortletEntry> entries = convertBookmarkToPortletEntryList(bookmarkList); - bookmarkListModel = new BookmarkPortletTableDataModel(entries, this.locale); + bookmarkListModel = new BookmarkPortletTableDataModel(entries, getLocale()); tableCtr.setTableDataModel(bookmarkListModel); } else { reloadModel(this.getPersistentManuallySortedItems()); @@ -210,7 +210,7 @@ public class BookmarksPortletRunController extends AbstractPortletRunController public void event(Event event) { if(event instanceof BookmarkEvent) { - if(((BookmarkEvent)event).getUsername().equals(identity.getName()) || ((BookmarkEvent)event).isAllUsersEvent()) { + if(((BookmarkEvent)event).getUsername().equals(getIdentity().getName()) || ((BookmarkEvent)event).isAllUsersEvent()) { reloadModel(sortingCriteria); } } diff --git a/src/main/java/org/olat/core/gui/control/generic/portal/AbstractPortletRunController.java b/src/main/java/org/olat/core/gui/control/generic/portal/AbstractPortletRunController.java index 2f45ea11f88a1e34efeae4ebc54b964850d68d61..7c6f78805e6e61346e5cf62feeff90ec259bbf76 100644 --- a/src/main/java/org/olat/core/gui/control/generic/portal/AbstractPortletRunController.java +++ b/src/main/java/org/olat/core/gui/control/generic/portal/AbstractPortletRunController.java @@ -60,19 +60,16 @@ public abstract class AbstractPortletRunController extends BasicController { protected SortingCriteria sortingCriteria; protected ArrayList<Integer> sortingTermsList = new ArrayList<Integer>(); private final String portletName; - private final Preferences guiPreferences; - protected final Identity identity; - protected final Locale locale; + protected final Preferences guiPreferences; + public AbstractPortletRunController(WindowControl wControl, UserRequest ureq, Translator trans, String portletName) { super(ureq, wControl, trans); collator = Collator.getInstance(); this.portletName = portletName; this.guiPreferences = ureq.getUserSession().getGuiPreferences(); - this.identity = ureq.getIdentity(); - this.locale = ureq.getLocale(); } - + /** * Handles portletToolsController events. diff --git a/src/main/java/org/olat/course/assessment/EfficiencyStatementsPortletRunController.java b/src/main/java/org/olat/course/assessment/EfficiencyStatementsPortletRunController.java index 9fe755d688e615686e0815e2a09914c6b62c1581..95cedf9aa1f975fd177ef32ba23a4c1328149ca9 100644 --- a/src/main/java/org/olat/course/assessment/EfficiencyStatementsPortletRunController.java +++ b/src/main/java/org/olat/course/assessment/EfficiencyStatementsPortletRunController.java @@ -129,7 +129,7 @@ public class EfficiencyStatementsPortletRunController extends AbstractPortletRun * @return the PortletEntry list. */ private List<PortletEntry> getAllPortletEntries() { - List<UserEfficiencyStatementLight> efficiencyStatementsList = EfficiencyStatementManager.getInstance().findEfficiencyStatementsLight(identity); + List<UserEfficiencyStatementLight> efficiencyStatementsList = EfficiencyStatementManager.getInstance().findEfficiencyStatementsLight(getIdentity()); List<PortletEntry> portletEntryList = convertEfficiencyStatementToPortletEntryList(efficiencyStatementsList); return portletEntryList; } @@ -154,7 +154,7 @@ public class EfficiencyStatementsPortletRunController extends AbstractPortletRun protected void reloadModel(SortingCriteria sortingCriteria) { if (sortingCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) { EfficiencyStatementManager esm = EfficiencyStatementManager.getInstance(); - List<UserEfficiencyStatementLight> efficiencyStatementsList = esm.findEfficiencyStatementsLight(identity); + List<UserEfficiencyStatementLight> efficiencyStatementsList = esm.findEfficiencyStatementsLight(getIdentity()); efficiencyStatementsList = getSortedList(efficiencyStatementsList, sortingCriteria); List<PortletEntry> entries = convertEfficiencyStatementToPortletEntryList(efficiencyStatementsList); diff --git a/src/main/java/org/olat/group/BusinessGroupOrder.java b/src/main/java/org/olat/group/BusinessGroupOrder.java new file mode 100644 index 0000000000000000000000000000000000000000..b940beec73da0bd6ff876419cdb7fdc863f66274 --- /dev/null +++ b/src/main/java/org/olat/group/BusinessGroupOrder.java @@ -0,0 +1,36 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<bnumr> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.group; + + +/** + * + * enumeration of the ordering possible with find + * + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + */ +public enum BusinessGroupOrder { + + nameAsc, + nameDesc, + creationDateAsc, + creationDateDesc + +} diff --git a/src/main/java/org/olat/group/BusinessGroupService.java b/src/main/java/org/olat/group/BusinessGroupService.java index a882c4d412b424307db14f2eff86a6ed14693f3f..e739b178d724a09b6680751abfe0c3a3e9c06f09 100644 --- a/src/main/java/org/olat/group/BusinessGroupService.java +++ b/src/main/java/org/olat/group/BusinessGroupService.java @@ -236,7 +236,7 @@ public interface BusinessGroupService { public int countBusinessGroups(SearchBusinessGroupParams params, OLATResource resource); - public List<BusinessGroup> findBusinessGroups(SearchBusinessGroupParams params, OLATResource resource, int firstResult, int maxResults); + public List<BusinessGroup> findBusinessGroups(SearchBusinessGroupParams params, OLATResource resource, int firstResult, int maxResults, BusinessGroupOrder... ordering); public List<Long> toGroupKeys(String groupNames, OLATResource resource); diff --git a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java index bdcc6fcc8d2aaaac345c359d10990d40e3e202c5..47d433eea22cca044cc2f73a98fc00e4641de2c8 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java @@ -45,6 +45,7 @@ import org.olat.core.util.StringHelper; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupImpl; import org.olat.group.BusinessGroupMembership; +import org.olat.group.BusinessGroupOrder; import org.olat.group.BusinessGroupShort; import org.olat.group.model.BGRepositoryEntryRelation; import org.olat.group.model.BGResourceRelation; @@ -372,8 +373,9 @@ public class BusinessGroupDAO { return count.intValue(); } - public List<BusinessGroup> findBusinessGroups(SearchBusinessGroupParams params, OLATResource resource, int firstResult, int maxResults) { - TypedQuery<BusinessGroup> query = createFindDBQuery(params, resource, BusinessGroup.class); + public List<BusinessGroup> findBusinessGroups(SearchBusinessGroupParams params, OLATResource resource, + int firstResult, int maxResults, BusinessGroupOrder... ordering) { + TypedQuery<BusinessGroup> query = createFindDBQuery(params, resource, BusinessGroup.class, ordering); query.setFirstResult(firstResult); if(maxResults > 0) { query.setMaxResults(maxResults); @@ -382,7 +384,7 @@ public class BusinessGroupDAO { return groups; } - private <T> TypedQuery<T> createFindDBQuery(SearchBusinessGroupParams params, OLATResource resource, Class<T> resultClass) { + private <T> TypedQuery<T> createFindDBQuery(SearchBusinessGroupParams params, OLATResource resource, Class<T> resultClass, BusinessGroupOrder... ordering) { StringBuilder query = new StringBuilder(); if(BusinessGroup.class.equals(resultClass)) { query.append("select distinct(bgi) from "); @@ -539,9 +541,21 @@ public class BusinessGroupDAO { } //order by (not for count) if(BusinessGroup.class.equals(resultClass)) { - query.append(" order by bgi.name,bgi.key"); + query.append(" order by "); + if(ordering != null && ordering.length > 0) { + for(BusinessGroupOrder o:ordering) { + switch(o) { + case nameAsc: query.append("bgi.name,");break; + case nameDesc: query.append("bgi.name desc,");break; + case creationDateAsc: query.append("bgi.creationDate,");break; + case creationDateDesc: query.append("bgi.creationDate desc,");break; + } + } + } else { + query.append("bgi.name,"); + } + query.append("bgi.key"); } - TypedQuery<T> dbq = dbInstance.getCurrentEntityManager().createQuery(query.toString(), resultClass); //add parameters diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java index 6f27fe344bcf3769e60b140465c7ae60ef660e21..24086be4f7a5ceb11fed4a77fca420bafa51fe6d 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -66,6 +66,7 @@ import org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerFactory; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupAddResponse; import org.olat.group.BusinessGroupMembership; +import org.olat.group.BusinessGroupOrder; import org.olat.group.BusinessGroupService; import org.olat.group.BusinessGroupShort; import org.olat.group.DeletableGroupData; @@ -552,7 +553,8 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD @Override @Transactional(readOnly=true) - public List<BusinessGroup> findBusinessGroups(SearchBusinessGroupParams params, OLATResource resource, int firstResult, int maxResults) { + public List<BusinessGroup> findBusinessGroups(SearchBusinessGroupParams params, OLATResource resource, + int firstResult, int maxResults, BusinessGroupOrder... ordering) { if(params == null) { params = new SearchBusinessGroupParams(); } diff --git a/src/main/java/org/olat/group/model/SearchBusinessGroupParams.java b/src/main/java/org/olat/group/model/SearchBusinessGroupParams.java index cc6deb41337feffb4376ec45a6605de6d78068c3..9eb3e4d5c8fa663849939630f751023a00d1966d 100644 --- a/src/main/java/org/olat/group/model/SearchBusinessGroupParams.java +++ b/src/main/java/org/olat/group/model/SearchBusinessGroupParams.java @@ -20,6 +20,7 @@ package org.olat.group.model; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.olat.core.id.Identity; @@ -35,10 +36,10 @@ import org.olat.core.id.Identity; */ public class SearchBusinessGroupParams { - private List<String> types; - private List<String> tools; + private Collection<String> types; + private Collection<String> tools; private String nameOrDesc; - private List<Long> groupKeys; + private Collection<Long> groupKeys; private String name; private String exactName; private String description; @@ -64,11 +65,11 @@ public class SearchBusinessGroupParams { } - public List<String> getTypes() { + public Collection<String> getTypes() { return types; } - public void setTypes(List<String> types) { + public void setTypes(Collection<String> types) { this.types = types; } @@ -81,7 +82,7 @@ public class SearchBusinessGroupParams { } } - public List<String> getTools() { + public Collection<String> getTools() { return tools; } @@ -98,11 +99,11 @@ public class SearchBusinessGroupParams { } } - public List<Long> getGroupKeys() { + public Collection<Long> getGroupKeys() { return groupKeys; } - public void setGroupKeys(List<Long> groupKeys) { + public void setGroupKeys(Collection<Long> groupKeys) { this.groupKeys = groupKeys; } diff --git a/src/main/java/org/olat/group/ui/portlet/GroupsPortletRunController.java b/src/main/java/org/olat/group/ui/portlet/GroupsPortletRunController.java index bfd4d4ebce5bf927683b831f1706ac989624dc18..44b44d1081a4c813af9b43b30c74cd46fd995246 100644 --- a/src/main/java/org/olat/group/ui/portlet/GroupsPortletRunController.java +++ b/src/main/java/org/olat/group/ui/portlet/GroupsPortletRunController.java @@ -26,19 +26,19 @@ package org.olat.group.ui.portlet; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.Date; -import java.util.Iterator; import java.util.List; +import java.util.Map; import org.apache.commons.lang.StringEscapeUtils; +import org.olat.NewControllerFactory; import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; -import org.olat.core.gui.Windows; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.link.Link; import org.olat.core.gui.components.link.LinkFactory; -import org.olat.core.gui.components.table.ColumnDescriptor; import org.olat.core.gui.components.table.DefaultColumnDescriptor; import org.olat.core.gui.components.table.Table; import org.olat.core.gui.components.table.TableController; @@ -48,22 +48,20 @@ import org.olat.core.gui.components.velocity.VelocityContainer; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.control.generic.dtabs.DTabs; import org.olat.core.gui.control.generic.portal.AbstractPortletRunController; import org.olat.core.gui.control.generic.portal.PortletDefaultTableDataModel; import org.olat.core.gui.control.generic.portal.PortletEntry; import org.olat.core.gui.control.generic.portal.PortletToolSortingControllerImpl; import org.olat.core.gui.control.generic.portal.SortingCriteria; import org.olat.core.gui.translator.Translator; -import org.olat.core.id.Identity; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.event.GenericEventListener; import org.olat.core.util.filter.FilterFactory; import org.olat.core.util.resource.OresHelper; import org.olat.group.BusinessGroup; +import org.olat.group.BusinessGroupOrder; import org.olat.group.BusinessGroupService; import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.group.site.GroupsSite; import org.olat.group.ui.BGControllerFactory; import org.olat.group.ui.edit.BusinessGroupModifiedEvent; @@ -79,8 +77,8 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp private static final String CMD_LAUNCH = "cmd.launch"; - private TableController tableCtr; - private GroupTableDataModel groupListModel; + private final TableController tableCtr; + private final GroupTableDataModel groupListModel; private VelocityContainer groupsVC; private List<BusinessGroup> groupList; private Link showAllLink; @@ -99,7 +97,6 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); - sortingTermsList.add(SortingCriteria.TYPE_SORTING); sortingTermsList.add(SortingCriteria.ALPHABETICAL_SORTING); sortingTermsList.add(SortingCriteria.DATE_SORTING); @@ -117,14 +114,14 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp tableConfig.setSortingEnabled(false); tableCtr = new TableController(tableConfig, ureq, getWindowControl(), trans); listenTo(tableCtr); - + // dummy header key, won't be used since setDisplayTableHeader is set to // false tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("groupsPortlet.bgname", 0, CMD_LAUNCH, trans.getLocale())); - tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("groupsPortlet.type", 1, null, trans.getLocale(), - ColumnDescriptor.ALIGNMENT_RIGHT)); sortingCriteria = getPersistentSortingConfiguration(ureq); + groupListModel = new GroupTableDataModel(Collections.<PortletEntry>emptyList()); + tableCtr.setTableDataModel(groupListModel); reloadModel(sortingCriteria); groupsVC.put("table", tableCtr.getInitialComponent()); @@ -140,41 +137,41 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp * @return the PortletEntry list. */ private List<PortletEntry> getAllPortletEntries() { - SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, true, true); + SearchBusinessGroupParams params = new SearchBusinessGroupParams(getIdentity(), true, true); groupList = businessGroupService.findBusinessGroups(params, null, 0, -1); - List<PortletEntry> entries = convertBusinessGroupToPortletEntryList(groupList); - return entries; + return convertBusinessGroupToPortletEntryList(groupList); } - private List<PortletEntry> convertBusinessGroupToPortletEntryList(List<BusinessGroup> items) { + private List<PortletEntry> convertBusinessGroupToPortletEntryList(List<BusinessGroup> groups) { List<PortletEntry> convertedList = new ArrayList<PortletEntry>(); - Iterator<BusinessGroup> listIterator = items.iterator(); - while(listIterator.hasNext()) { - convertedList.add(new GroupPortletEntry(listIterator.next())); + for(BusinessGroup group:groups) { + convertedList.add(new GroupPortletEntry(group)); } return convertedList; } protected void reloadModel(SortingCriteria sortingCriteria) { if (sortingCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) { - SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, true, true); - groupList = businessGroupService.findBusinessGroups(params, null, 0, sortingCriteria.getMaxEntries()); - groupList = getSortedList(groupList, sortingCriteria); - + SearchBusinessGroupParams params = new SearchBusinessGroupParams(getIdentity(), true, true); + BusinessGroupOrder order = null; + if(sortingCriteria.getSortingTerm()==SortingCriteria.ALPHABETICAL_SORTING) { + order = sortingCriteria.isAscending() ? BusinessGroupOrder.nameAsc : BusinessGroupOrder.nameDesc; + } else if(sortingCriteria.getSortingTerm()==SortingCriteria.DATE_SORTING) { + order = sortingCriteria.isAscending() ? BusinessGroupOrder.creationDateAsc : BusinessGroupOrder.creationDateDesc; + } + groupList = businessGroupService.findBusinessGroups(params, null, 0, sortingCriteria.getMaxEntries(), order); List<PortletEntry> entries = convertBusinessGroupToPortletEntryList(groupList); - - groupListModel = new GroupTableDataModel(entries); - tableCtr.setTableDataModel(groupListModel); + groupListModel.setObjects(entries); + tableCtr.modelChanged(); } else { reloadModel(getPersistentManuallySortedItems()); } } protected void reloadModel(List<PortletEntry> sortedItems) { - groupListModel = new GroupTableDataModel(sortedItems); - tableCtr.setTableDataModel(groupListModel); + groupListModel.setObjects(sortedItems); + tableCtr.modelChanged(); } - /** * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, @@ -182,10 +179,7 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp */ public void event(UserRequest ureq, Component source, Event event) { if (source == showAllLink) { - // activate group tab in top navigation - DTabs dts = (DTabs)Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs"); - //was brasato:: getWindowControl().getDTabs().activateStatic(ureq, GroupsSite.class.getName(), null); - dts.activateStatic(ureq, GroupsSite.class.getName(), null); + NewControllerFactory.getInstance().launch("[GroupsSite:0]", ureq, getWindowControl()); } } @@ -270,9 +264,15 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp * @param ureq * @return */ - private List<PortletEntry> getPersistentManuallySortedItems() { - List<PortletEntry> portletEntryList = getAllPortletEntries(); - return this.getPersistentManuallySortedItems(portletEntryList); + private List<PortletEntry> getPersistentManuallySortedItems() { + @SuppressWarnings("unchecked") + Map<Long, Integer> storedPrefs = (Map<Long, Integer>)guiPreferences.get(Map.class, getPreferenceKey(SORTED_ITEMS_PREF)); + + SearchBusinessGroupParams params = new SearchBusinessGroupParams(getIdentity(), true, true); + params.setGroupKeys(storedPrefs.keySet()); + List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, null, 0, -1); + List<PortletEntry> portletEntryList = convertBusinessGroupToPortletEntryList(groups); + return getPersistentManuallySortedItems(portletEntryList); } /** @@ -290,8 +290,6 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp comparisonResult = collator.compare(group1.getName(), group2.getName()); } else if(sortingCriteria.getSortingTerm()==SortingCriteria.DATE_SORTING) { comparisonResult = group1.getCreationDate().compareTo(group2.getCreationDate()); - } else if(sortingCriteria.getSortingTerm()==SortingCriteria.TYPE_SORTING) { - comparisonResult = group1.getType().compareTo(group2.getType()); } if(!sortingCriteria.isAscending()) { //if not isAscending return (-comparisonResult) @@ -364,7 +362,6 @@ public class GroupsPortletRunController extends AbstractPortletRunController imp return (description == null ? "n/a" : description); case 2: Date date = group.getCreationDate(); - //return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getTranslator().getLocale()).format(date); return date; default: return "error"; diff --git a/src/main/java/org/olat/login/OLATAuthenticationController.java b/src/main/java/org/olat/login/OLATAuthenticationController.java index 0bcdefdec22ab94d61b6810df6fe3dd9398ae8e1..7b5e2dec9bdbceb77c126e09c420f00f26103b1d 100644 --- a/src/main/java/org/olat/login/OLATAuthenticationController.java +++ b/src/main/java/org/olat/login/OLATAuthenticationController.java @@ -206,11 +206,12 @@ public class OLATAuthenticationController extends AuthenticationController imple } } - LoginModule.clearFailedLoginAttempts(login); + LoginModule.clearFailedLoginAttempts(login); // Check if disclaimer has been accepted if (RegistrationManager.getInstance().needsToConfirmDisclaimer(authenticatedIdentity)) { // accept disclaimer first + RegistrationManager.getInstance().setHasConfirmedDislaimer(authenticatedIdentity); removeAsListenerAndDispose(disclaimerCtr); disclaimerCtr = new DisclaimerController(ureq, getWindowControl()); diff --git a/src/main/java/org/olat/note/NotesPortletRunController.java b/src/main/java/org/olat/note/NotesPortletRunController.java index 72fdb3fca1bc6349f90cd6e4b30a265e6d1ead8a..b6de839b6c7cfa4947cdc719e624af1ca8a1c3be 100644 --- a/src/main/java/org/olat/note/NotesPortletRunController.java +++ b/src/main/java/org/olat/note/NotesPortletRunController.java @@ -125,7 +125,7 @@ public class NotesPortletRunController extends AbstractPortletRunController impl putInitialPanel(notesVC); //register for events targeted at this Identity - TODO: LD: use SingleUserEventCenter - eventBusThisIdentityOres = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey()); + eventBusThisIdentityOres = OresHelper.createOLATResourceableInstance(Identity.class, getIdentity().getKey()); CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, ureq.getIdentity(), eventBusThisIdentityOres); } @@ -166,7 +166,7 @@ public class NotesPortletRunController extends AbstractPortletRunController impl noteList = getSortedList(noteList, sortingCriteria ); List<PortletEntry> entries = convertNoteToPortletEntryList(noteList); - notesListModel = new NoteSortingTableDataModel(entries, locale); + notesListModel = new NoteSortingTableDataModel(entries, getLocale()); tableCtr.setTableDataModel(notesListModel); } else { reloadModel(this.getPersistentManuallySortedItems()); @@ -178,7 +178,7 @@ public class NotesPortletRunController extends AbstractPortletRunController impl * @see org.olat.core.gui.control.generic.portal.AbstractPortletRunController#reloadModel(org.olat.core.gui.UserRequest, java.util.List) */ protected void reloadModel(List<PortletEntry> sortedItems) { - notesListModel = new NoteSortingTableDataModel(sortedItems, locale); + notesListModel = new NoteSortingTableDataModel(sortedItems, getLocale()); tableCtr.setTableDataModel(notesListModel); } @@ -188,7 +188,7 @@ public class NotesPortletRunController extends AbstractPortletRunController impl */ public void event(Event event) { if(event instanceof NoteEvent) { - if(((NoteEvent)event).getUsername().equals(identity.getName())) { + if(((NoteEvent)event).getUsername().equals(getIdentity().getName())) { reloadModel(sortingCriteria); } } diff --git a/src/main/java/org/olat/notifications/NotificationsPortletRunController.java b/src/main/java/org/olat/notifications/NotificationsPortletRunController.java index 3a7b0fd9c010628f59f186869e6fdb1952985c4f..c35f5550dc4aaeebdbf4d7d7945fbff76aa274bf 100644 --- a/src/main/java/org/olat/notifications/NotificationsPortletRunController.java +++ b/src/main/java/org/olat/notifications/NotificationsPortletRunController.java @@ -149,7 +149,7 @@ public class NotificationsPortletRunController extends AbstractPortletRunControl } private List<PortletEntry> getAllPortletEntries() { - notificationsList = man.getValidSubscribers(identity); + notificationsList = man.getValidSubscribers(getIdentity()); // calc subscriptioninfo for all subscriptions and, if only those with news are to be shown, remove the other ones for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext();) { Subscriber subscriber = it_subs.next(); @@ -158,7 +158,7 @@ public class NotificationsPortletRunController extends AbstractPortletRunControl if(notifHandler == null) { it_subs.remove(); } else { - SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, compareDate); + SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, getLocale(), compareDate); if (!subsInfo.hasNews()) { it_subs.remove(); } @@ -195,7 +195,7 @@ public class NotificationsPortletRunController extends AbstractPortletRunControl } notificationsList = getSortedList(notificationsList, sortingCriteria ); List<PortletEntry> entries = convertNotificationToPortletEntryList(notificationsList); - notificationListModel = new NotificationsPortletTableDataModel(entries, locale, subscriptionMap); + notificationListModel = new NotificationsPortletTableDataModel(entries, getLocale(), subscriptionMap); tableCtr.setTableDataModel(notificationListModel); } else { reloadModel(this.getPersistentManuallySortedItems()); @@ -208,7 +208,7 @@ public class NotificationsPortletRunController extends AbstractPortletRunControl */ protected void reloadModel(List<PortletEntry> sortedItems) { Map subscriptionMap = NotificationHelper.getSubscriptionMap(getIdentity(), getLocale(), true, compareDate); - notificationListModel = new NotificationsPortletTableDataModel(sortedItems, locale, subscriptionMap); + notificationListModel = new NotificationsPortletTableDataModel(sortedItems, getLocale(), subscriptionMap); tableCtr.setTableDataModel(notificationListModel); } diff --git a/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java b/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java index c38929834444046bf654f0249995035007d415c3..3b838365a1dde99d8a3499f360c7fe00fd227416 100644 --- a/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java +++ b/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java @@ -124,10 +124,10 @@ public class RepositoryPortletRunController extends AbstractPortletRunController private List<PortletEntry> getAllPortletEntries() { if (studentView) { - List<RepositoryEntry> allRepoEntries = RepositoryManager.getInstance().getLearningResourcesAsStudent(identity); + List<RepositoryEntry> allRepoEntries = RepositoryManager.getInstance().getLearningResourcesAsStudent(getIdentity()); return convertRepositoryEntriesToPortletEntryList(allRepoEntries); } else { - List<RepositoryEntry> allRepoEntries = RepositoryManager.getInstance().getLearningResourcesAsTeacher(identity); + List<RepositoryEntry> allRepoEntries = RepositoryManager.getInstance().getLearningResourcesAsTeacher(getIdentity()); return convertRepositoryEntriesToPortletEntryList(allRepoEntries); } } diff --git a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java index 750f49d719e350c65015f43c20cc4035c3b42d44..b4fc30b0d4625ee37d1c49bde1f159a20739b907 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java @@ -39,6 +39,7 @@ import org.olat.core.id.Identity; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.group.BusinessGroup; +import org.olat.group.BusinessGroupOrder; import org.olat.group.BusinessGroupShort; import org.olat.group.manager.BusinessGroupDAO; import org.olat.group.manager.BusinessGroupPropertyDAO; @@ -885,6 +886,38 @@ public class BusinessGroupDAOTest extends OlatTestCase { Assert.assertTrue(markedGroups2.contains(group2)); } + @Test + public void findBusinessGroupOrdered() { + BusinessGroup group1 = businessGroupDao.createAndPersist(null, "a_ordered-grp-3", "marked-grp-1-desc", 0, 5, true, false, true, false, false); + BusinessGroup group2 = businessGroupDao.createAndPersist(null, "z_ordered-grp-4", "marked-grp-2-desc", 0, 5, true, false, true, false, false); + dbInstance.commitAndCloseSession(); + + //check the query order by name + SearchBusinessGroupParams params = new SearchBusinessGroupParams(); + List<BusinessGroup> orderedByName = businessGroupDao.findBusinessGroups(params, null, 0, 0, BusinessGroupOrder.nameAsc); + Assert.assertNotNull(orderedByName); + Assert.assertFalse(orderedByName.isEmpty()); + int index1 = orderedByName.indexOf(group1); + int index2 = orderedByName.indexOf(group2); + Assert.assertTrue(index1 < index2); + + //check the query order by creation date + List<BusinessGroup> orderedByCreationDate = businessGroupDao.findBusinessGroups(params, null, 0, 0, BusinessGroupOrder.creationDateAsc); + Assert.assertNotNull(orderedByCreationDate); + Assert.assertFalse(orderedByCreationDate.isEmpty()); + int index3 = orderedByCreationDate.indexOf(group1); + int index4 = orderedByCreationDate.indexOf(group2); + Assert.assertTrue(index3 < index4); + + //check the query order by creation date + List<BusinessGroup> orderedBy = businessGroupDao.findBusinessGroups(params, null, 0, 0, BusinessGroupOrder.nameAsc, BusinessGroupOrder.creationDateDesc); + Assert.assertNotNull(orderedBy); + Assert.assertFalse(orderedBy.isEmpty()); + int index5 = orderedBy.indexOf(group1); + int index6 = orderedBy.indexOf(group2); + Assert.assertTrue(index5 < index6); + } + @Test public void isIdentityInBusinessGroups() { Identity id = JunitTestHelper.createAndPersistIdentityAsUser("is-in-grp-" + UUID.randomUUID().toString());