Search in sources :

Example 66 with SortKey

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);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 67 with SortKey

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);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource) SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 68 with SortKey

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);
    }
}
Also used : SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 69 with SortKey

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);
    }
}
Also used : QuestionItemCollection(org.olat.modules.qpool.QuestionItemCollection) SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 70 with SortKey

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);
    }
}
Also used : Pool(org.olat.modules.qpool.Pool) SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Aggregations

SortKey (org.olat.core.commons.persistence.SortKey)82 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)48 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)42 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)42 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)30 ArrayList (java.util.ArrayList)20 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)18 Identity (org.olat.core.id.Identity)18 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)14 Test (org.junit.Test)12 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)12 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)12 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)10 QuestionItem (org.olat.modules.qpool.QuestionItem)10 QuestionItemView (org.olat.modules.qpool.QuestionItemView)10 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)8 DateFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer)8 FlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer)6 BusinessGroup (org.olat.group.BusinessGroup)6