use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class RepositoryEntryListController method initSorters.
private void initSorters(FlexiTableElement tableElement) {
List<FlexiTableSort> sorters = new ArrayList<>(14);
sorters.add(new FlexiTableSort(translate("orderby.automatic"), OrderBy.automatic.name()));
sorters.add(new FlexiTableSort(translate("orderby.favorit"), OrderBy.favorit.name()));
sorters.add(new FlexiTableSort(translate("orderby.lastVisited"), OrderBy.lastVisited.name()));
sorters.add(new FlexiTableSort(translate("orderby.score"), OrderBy.score.name()));
sorters.add(new FlexiTableSort(translate("orderby.passed"), OrderBy.passed.name()));
sorters.add(FlexiTableSort.SPACER);
sorters.add(new FlexiTableSort(translate("orderby.title"), OrderBy.title.name()));
sorters.add(new FlexiTableSort(translate("orderby.lifecycle"), OrderBy.lifecycle.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.lastModified"), OrderBy.lastModified.name()));
if (repositoryModule.isRatingEnabled()) {
sorters.add(new FlexiTableSort(translate("orderby.rating"), OrderBy.rating.name()));
}
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 klemens.
the class QItemQueriesDAOTest method getSharedItemByResource_orderBy.
@Test
public void getSharedItemByResource_orderBy() {
// create a group to share 1 item
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("QShare-2-" + UUID.randomUUID());
BusinessGroup group = businessGroupDao.createAndPersist(id, "gdao-3", "gdao-desc", -1, -1, false, false, false, false, false);
QuestionItem item = questionDao.createAndPersist(id, "Share-Item-3", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
dbInstance.commit();
// share them
List<OLATResource> resources = new ArrayList<>();
resources.add(group.getResource());
questionDao.share(item, resources, false);
dbInstance.commitAndCloseSession();
// test order by
for (QuestionItemView.OrderBy order : QuestionItemView.OrderBy.values()) {
SortKey sortAsc = new SortKey(order.name(), true);
List<QuestionItemView> ascOrderedItems = qItemQueriesDao.getSharedItemByResource(id, group.getResource(), null, null, 0, -1, sortAsc);
Assert.assertNotNull(ascOrderedItems);
SortKey sortDesc = new SortKey(order.name(), false);
List<QuestionItemView> descOrderedItems = qItemQueriesDao.getSharedItemByResource(id, group.getResource(), null, null, 0, -1, sortDesc);
Assert.assertNotNull(descOrderedItems);
}
}
use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
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 klemens.
the class QItemQueriesDAOTest method getItemsOfCollection_orderBy.
@Test
public void getItemsOfCollection_orderBy() {
// create a collection with 2 items
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-3-" + UUID.randomUUID().toString());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection 3", id);
QuestionItem item = questionDao.createAndPersist(null, "NGC 92", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, qItemType);
collectionDao.addItemToCollection(item, singletonList(coll));
// check if it's alright
dbInstance.commit();
// test order by
for (QuestionItemView.OrderBy order : QuestionItemView.OrderBy.values()) {
SortKey sortAsc = new SortKey(order.name(), true);
List<QuestionItemView> ascOrderedItems = qItemQueriesDao.getItemsOfCollection(id, coll, null, null, 0, -1, sortAsc);
Assert.assertNotNull(ascOrderedItems);
SortKey sortDesc = new SortKey(order.name(), false);
List<QuestionItemView> descOrderedItems = qItemQueriesDao.getItemsOfCollection(id, coll, null, null, 0, -1, sortDesc);
Assert.assertNotNull(descOrderedItems);
}
}
use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class QItemQueriesDAOTest method getItemsOfPool_orderBy.
@Test
public void getItemsOfPool_orderBy() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Poolman-" + UUID.randomUUID().toString());
// create a pool
String poolTitle = "NGC-" + UUID.randomUUID().toString();
Pool pool = poolDao.createPool(null, poolTitle, true);
QuestionItem item = questionItemDao.createAndPersist(id, "Mega cluster of galaxies", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
poolDao.addItemToPool(item, Collections.singletonList(pool), false);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
params.setPoolKey(pool.getKey());
// test order by
for (QuestionItemView.OrderBy order : QuestionItemView.OrderBy.values()) {
SortKey sortAsc = new SortKey(order.name(), true);
List<QuestionItemView> ascOrderedItems = qItemQueriesDao.getItemsOfPool(params, null, 0, -1, sortAsc);
Assert.assertNotNull(ascOrderedItems);
SortKey sortDesc = new SortKey(order.name(), false);
List<QuestionItemView> descOrderedItems = qItemQueriesDao.getItemsOfPool(params, null, 0, -1, sortDesc);
Assert.assertNotNull(descOrderedItems);
}
}
Aggregations