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);
}
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);
}
}
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());
}
}
}
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());
}
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);
}
Aggregations