use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method getFavoritItems_orderBy.
@Test
public void getFavoritItems_orderBy() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("fav-item-" + UUID.randomUUID().toString());
QuestionItem item1 = questionDao.createAndPersist(id, "NGC 55", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
QuestionItem item2 = questionDao.createAndPersist(id, "NGC 253", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
markManager.setMark(item1, id, null, "[QuestionItem:" + item1 + "]");
markManager.setMark(item2, id, null, "[QuestionItem:" + item2 + "]");
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
// test order by
for (QuestionItemView.OrderBy order : QuestionItemView.OrderBy.values()) {
SortKey sortAsc = new SortKey(order.name(), true);
List<QuestionItemView> ascOrderedItems = qItemQueriesDao.getFavoritItems(params, null, 0, -1, sortAsc);
Assert.assertNotNull(ascOrderedItems);
SortKey sortDesc = new SortKey(order.name(), false);
List<QuestionItemView> descOrderedItems = qItemQueriesDao.getFavoritItems(params, null, 0, -1, sortDesc);
Assert.assertNotNull(descOrderedItems);
}
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class VideoListingController method initSorters.
private void initSorters(FlexiTableElement tableElement) {
List<FlexiTableSort> sorters = new ArrayList<>(8);
sorters.add(new FlexiTableSort(translate("orderby.automatic"), OrderBy.automatic.name()));
sorters.add(new FlexiTableSort(translate("orderby.title"), OrderBy.title.name()));
sorters.add(new FlexiTableSort(translate("orderby.author"), OrderBy.author.name()));
sorters.add(new FlexiTableSort(translate("orderby.creationDate"), OrderBy.creationDate.name()));
sorters.add(new FlexiTableSort(translate("orderby.launchCounter"), OrderBy.launchCounter.name()));
if (repositoryModule.isRatingEnabled()) {
sorters.add(new FlexiTableSort(translate("orderby.rating"), OrderBy.rating.name()));
}
FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
options.setDefaultOrderBy(new SortKey(OrderBy.creationDate.name(), false));
tableElement.setSortSettings(options);
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class ThreadListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (foCallback.mayOpenNewThread()) {
newThreadButton = uifactory.addFormLink("msg.create", formLayout, Link.BUTTON_SMALL);
newThreadButton.setIconLeftCSS("o_icon o_icon-fw o_forum_status_thread_icon");
newThreadButton.setElementCssClass("o_sel_forum_thread_new");
}
if (foCallback.mayArchiveForum()) {
archiveForumButton = uifactory.addFormLink("archive.forum", formLayout, Link.BUTTON_SMALL);
archiveForumButton.setIconLeftCSS("o_icon o_icon-fw o_icon_archive_tool");
archiveForumButton.setElementCssClass("o_sel_forum_archive");
}
if (securityModule.isUserAllowedAutoComplete(ureq.getUserSession().getRoles()) && foCallback.mayFilterForUser()) {
userListButton = uifactory.addFormLink("filter", formLayout, Link.BUTTON_SMALL);
userListButton.setIconLeftCSS("o_icon o_icon-fw o_icon_user");
userListButton.setElementCssClass("o_sel_forum_filter");
}
if (formLayout instanceof FormLayoutContainer) {
SearchServiceUIFactory searchServiceUIFactory = (SearchServiceUIFactory) CoreSpringFactory.getBean(SearchServiceUIFactory.class);
searchController = searchServiceUIFactory.createInputController(ureq, getWindowControl(), DisplayOption.STANDARD, mainForm);
if (guestOnly && !searchModule.isGuestEnabled()) {
searchController.setResourceContextEnable(false);
}
listenTo(searchController);
((FormLayoutContainer) formLayout).add("search_input", searchController.getFormItem());
}
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.type, new StatusTypeCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.thread, "select", new StaticFlexiCellRenderer("select", new StickyCellRenderer())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.creator));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.lastModified));
if (!guestOnly) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.markedMessages, "marked", new StaticFlexiCellRenderer("marked", new TextFlexiCellRenderer())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.unreadMessages, "unread", new StaticFlexiCellRenderer("unread", new TextFlexiCellRenderer())));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ThreadListCols.totalMessages));
threadTableModel = new ThreadListDataModel(columnsModel, getTranslator());
threadTable = uifactory.addTableElement(getWindowControl(), "threads", threadTableModel, getTranslator(), formLayout);
threadTable.setCustomizeColumns(false);
threadTable.setElementCssClass("o_forum");
threadTable.setEmtpyTableMessageKey("forum.emtpy");
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
sortOptions.setDefaultOrderBy(new SortKey(ThreadListCols.lastModified.name(), false));
threadTable.setSortSettings(sortOptions);
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class MediaCenterController method initSorters.
private void initSorters(FlexiTableElement tableElement) {
List<FlexiTableSort> sorters = new ArrayList<>(14);
sorters.add(new FlexiTableSort(translate(MediaCols.key.i18nHeaderKey()), MediaCols.key.name()));
sorters.add(new FlexiTableSort(translate(MediaCols.type.i18nHeaderKey()), MediaCols.type.name()));
sorters.add(new FlexiTableSort(translate(MediaCols.title.i18nHeaderKey()), MediaCols.title.name()));
sorters.add(new FlexiTableSort(translate(MediaCols.collectionDate.i18nHeaderKey()), MediaCols.collectionDate.name()));
sorters.add(FlexiTableSort.SPACER);
FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
options.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
tableElement.setSortSettings(options);
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class FlexiTableElementImpl method loadCustomSettings.
private void loadCustomSettings(UserRequest ureq) {
if (StringHelper.containsNonWhitespace(persistentId)) {
Preferences prefs = ureq.getUserSession().getGuiPreferences();
FlexiTablePreferences tablePrefs = (FlexiTablePreferences) prefs.get(FlexiTableElement.class, persistentId);
if (tablePrefs != null) {
if (tablePrefs.getPageSize() != getDefaultPageSize() && tablePrefs.getPageSize() != 0) {
setPageSize(tablePrefs.getPageSize());
}
if (tablePrefs.getEnabledColumnKeys() != null) {
enabledColumnIndex.clear();
enabledColumnIndex.addAll(convertColumnKeysToIndex(tablePrefs.getEnabledColumnKeys()));
}
if (StringHelper.containsNonWhitespace(tablePrefs.getSortedColumnKey())) {
String sortKey = null;
String columnKey = tablePrefs.getSortedColumnKey();
FlexiTableColumnModel colModel = dataModel.getTableColumnModel();
for (int i = colModel.getColumnCount(); i-- > 0; ) {
FlexiColumnModel col = colModel.getColumnModel(i);
if (columnKey.equals(col.getColumnKey()) && col.isSortable()) {
sortKey = col.getSortKey();
}
}
if (sortKey == null && sortOptions != null && sortOptions.getSorts() != null) {
for (FlexiTableSort sortOption : sortOptions.getSorts()) {
if (sortOption.getSortKey().getKey().equals(columnKey)) {
sortKey = columnKey;
}
}
}
if (sortKey != null) {
orderBy = new SortKey[] { new SortKey(sortKey, tablePrefs.isSortDirection()) };
selectSortOption(sortKey, tablePrefs.isSortDirection());
}
}
if (tablePrefs.getRendererType() != null) {
setRendererType(tablePrefs.getRendererType());
}
}
}
}
Aggregations