Search in sources :

Example 76 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

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);
}
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 77 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class ACOrderManagerTest method findOrderItems_1.

@Test
public void findOrderItems_1() {
    // create an offer to buy
    List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
    assertNotNull(methods);
    assertEquals(1, methods.size());
    AccessMethod tokenMethod = methods.get(0);
    OLATResource randomOres = createResource();
    Offer offer = acService.createOffer(randomOres, "TestSaveOrder");
    offer = acService.save(offer);
    dbInstance.commitAndCloseSession();
    // create and save an order
    Order order = acOrderManager.createOrder(ident1);
    OrderPart part = acOrderManager.addOrderPart(order);
    OrderLine line = acOrderManager.addOrderLine(part, offer);
    order = acOrderManager.save(order);
    Assert.assertNotNull(order);
    Assert.assertNotNull(order.getDelivery());
    Assert.assertNotNull(line);
    Assert.assertEquals(ident1, order.getDelivery());
    dbInstance.commitAndCloseSession();
    AccessTransaction accessTransaction = acTransactionManager.createTransaction(order, part, tokenMethod);
    assertNotNull(accessTransaction);
    acTransactionManager.save(accessTransaction);
    AccessTransaction accessTransaction2 = acTransactionManager.createTransaction(order, part, tokenMethod);
    assertNotNull(accessTransaction2);
    acTransactionManager.save(accessTransaction2);
    dbInstance.commitAndCloseSession();
    acTransactionManager.update(accessTransaction, AccessTransactionStatus.NEW);
    acTransactionManager.update(accessTransaction2, AccessTransactionStatus.CANCELED);
    long start = System.nanoTime();
    List<RawOrderItem> items = acOrderManager.findNativeOrderItems(randomOres, null, null, null, null, null, 0, -1, null);
    CodeHelper.printNanoTime(start, "Order itemized");
    Assert.assertNotNull(items);
    // check the order by
    for (OrderCol col : OrderCol.values()) {
        List<RawOrderItem> rawItems = acOrderManager.findNativeOrderItems(randomOres, null, null, null, null, null, 0, -1, null, new SortKey(col.sortKey(), false));
        Assert.assertNotNull(rawItems);
    }
}
Also used : OLATResource(org.olat.resource.OLATResource) SortKey(org.olat.core.commons.persistence.SortKey) RawOrderItem(org.olat.resource.accesscontrol.model.RawOrderItem) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) FreeAccessMethod(org.olat.resource.accesscontrol.model.FreeAccessMethod) TokenAccessMethod(org.olat.resource.accesscontrol.model.TokenAccessMethod) OrderCol(org.olat.resource.accesscontrol.ui.OrdersDataModel.OrderCol) Test(org.junit.Test)

Example 78 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class AssessedBusinessGroupCourseNodeListController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ABGCols.key, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ABGCols.name, "select"));
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode aNode = (AssessableCourseNode) courseNode;
        if (aNode.hasPassedConfigured()) {
            columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ABGCols.countPassed, new ProgressRenderer(false, getTranslator())));
        }
        if (aNode.hasScoreConfigured()) {
            columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ABGCols.averageScore, new ScoreCellRenderer()));
        }
    }
    tableModel = new AssessedBusinessGroupTableModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    tableEl.setExportEnabled(true);
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    options.setDefaultOrderBy(new SortKey(ABGCols.name.name(), true));
    tableEl.setSortSettings(options);
    tableEl.setAndLoadPersistedPreferences(ureq, "assessment-tool-group-list");
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutcont = (FormLayoutContainer) formLayout;
        if (courseNode != null) {
            String courseNodeCssClass = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType()).getIconCSSClass();
            layoutcont.contextPut("courseNodeCssClass", courseNodeCssClass);
            layoutcont.contextPut("courseNodeTitle", courseNode.getShortTitle());
        }
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ScoreCellRenderer(org.olat.modules.assessment.ui.ScoreCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ProgressRenderer(org.olat.modules.coach.ui.ProgressRenderer) SortKey(org.olat.core.commons.persistence.SortKey) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 79 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class CheckListAssessmentController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("coach.desc");
    setFormContextHelp("Assessment#_checklist_manage");
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
        }
    }
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (isAdministrativeUser) {
        options.setDefaultOrderBy(new SortKey(Cols.username.name(), true));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
    }
    int i = 0;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        if (visible) {
            FlexiColumnModel col;
            if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
                col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
            } else {
                col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
            }
            columnsModel.addFlexiColumnModel(col);
            if (options.getDefaultOrderBy() == null) {
                options.setDefaultOrderBy(new SortKey(propName, true));
            }
        }
    }
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    List<Checkbox> boxList = checkboxList.getList();
    int j = 0;
    for (Checkbox box : boxList) {
        int colIndex = CheckListAssessmentDataModel.CHECKBOX_OFFSET + j++;
        String colName = "checkbox_" + colIndex;
        DefaultFlexiColumnModel column = new DefaultFlexiColumnModel(true, colName, colIndex, true, colName);
        column.setHeaderLabel(StringHelper.escapeHtml(box.getTitle()));
        columnsModel.addFlexiColumnModel(column);
    }
    if (withScore) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.totalPoints.i18nKey(), Cols.totalPoints.ordinal(), true, "points"));
    }
    if (coachCourseEnv.isCourseReadOnly()) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.view.checkbox", translate("table.header.view.checkbox"), "view"));
    } else {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.edit.checkbox", translate("table.header.edit.checkbox"), "edit"));
    }
    model = new CheckListAssessmentDataModel(checkboxList, new ArrayList<>(), columnsModel, getLocale());
    table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
    if (coachCourseEnv instanceof UserCourseEnvironmentImpl) {
        UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
        List<BusinessGroup> coachedGroups = env.getCoachedGroups();
        List<FlexiTableFilter> filters = new ArrayList<>(coachedGroups.size() + 1);
        filters.add(new FlexiTableFilter(translate("filter.all"), "all"));
        for (int k = 0; k < coachedGroups.size(); k++) {
            BusinessGroup group = coachedGroups.get(k);
            String groupName = StringHelper.escapeHtml(group.getName());
            filters.add(new FlexiTableFilter(groupName, group.getKey().toString()));
        }
        table.setFilters("participants", filters, false);
    }
    table.setExportEnabled(true);
    table.setCustomizeColumns(true);
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    table.setSortSettings(sortOptions);
    table.setAndLoadPersistedPreferences(ureq, "checklist-assessment");
    pdfExportButton = uifactory.addFormLink("pdf.export", formLayout, Link.BUTTON);
    pdfExportButton.setEnabled(numOfCheckbox > 0);
    checkedPdfExportButton = uifactory.addFormLink("pdf.export.checked", formLayout, Link.BUTTON);
    checkedPdfExportButton.setEnabled(numOfCheckbox > 0);
    editButton = uifactory.addFormLink("edit", formLayout, Link.BUTTON);
    editButton.setEnabled(numOfCheckbox > 0);
    editButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    saveButton = uifactory.addFormSubmitButton("save", formLayout);
    saveButton.getComponent().setSpanAsDomReplaceable(true);
    saveButton.setVisible(false);
    cancelButton = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    cancelButton.setVisible(false);
    boxAssessmentButton = uifactory.addFormLink("box.assessment", formLayout, Link.BUTTON);
    boxAssessmentButton.setEnabled(numOfCheckbox > 0);
    boxAssessmentButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) BusinessGroup(org.olat.group.BusinessGroup) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) Checkbox(org.olat.course.nodes.cl.model.Checkbox) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 80 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class AbstractMemberListController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    SortKey defaultSortKey = initColumns(columnsModel);
    memberListModel = new MemberListTableModel(columnsModel, imModule.isOnlineStatusEnabled());
    membersTable = uifactory.addTableElement(getWindowControl(), "memberList", memberListModel, 20, false, getTranslator(), formLayout);
    membersTable.setMultiSelect(true);
    membersTable.setEmtpyTableMessageKey("nomembers");
    membersTable.setAndLoadPersistedPreferences(ureq, this.getClass().getSimpleName());
    membersTable.setSearchEnabled(true);
    membersTable.setExportEnabled(true);
    membersTable.setSelectAllEnable(true);
    membersTable.setElementCssClass("o_sel_member_list");
    if (defaultSortKey != null) {
        FlexiTableSortOptions options = new FlexiTableSortOptions();
        options.setDefaultOrderBy(defaultSortKey);
        membersTable.setSortSettings(options);
    }
    editButton = uifactory.addFormLink("edit.members", formLayout, Link.BUTTON);
    editButton.setVisible((!globallyManaged || overrideManaged) && !readOnly);
    mailButton = uifactory.addFormLink("table.header.mail", formLayout, Link.BUTTON);
    removeButton = uifactory.addFormLink("table.header.remove", formLayout, Link.BUTTON);
    removeButton.setVisible((!globallyManaged || overrideManaged) && !readOnly);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) SortKey(org.olat.core.commons.persistence.SortKey)

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