use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class QItemQueriesDAOTest method getItemsByAuthor_orderBy.
@Test
public void getItemsByAuthor_orderBy() {
// create an author with 2 items
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("QOwn-2-" + UUID.randomUUID().toString());
QuestionItem item1 = questionDao.createAndPersist(id, "NGC 2171", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
QuestionItem item2 = questionDao.createAndPersist(id, "NGC 2172", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(item1);
Assert.assertNotNull(item2);
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
params.setAuthor(id);
// test order by
for (QuestionItemView.OrderBy order : QuestionItemView.OrderBy.values()) {
SortKey sortAsc = new SortKey(order.name(), true);
List<QuestionItemView> ascOrderedItems = qItemQueriesDao.getItemsByAuthor(params, null, 0, -1, sortAsc);
Assert.assertNotNull(ascOrderedItems);
SortKey sortDesc = new SortKey(order.name(), false);
List<QuestionItemView> descOrderedItems = qItemQueriesDao.getItemsByAuthor(params, null, 0, -1, sortDesc);
Assert.assertNotNull(descOrderedItems);
}
}
use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class AuthorListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// search form
if (withSearch) {
setFormDescription("table.search.author.desc");
searchCtrl = new AuthorSearchController(ureq, getWindowControl(), true, mainForm);
searchCtrl.setEnabled(false);
listenTo(searchCtrl);
}
if (withClosedfilter) {
String[] statusValues = new String[] { translate("cif.resources.status.all"), translate("cif.resources.status.active"), translate("cif.resources.status.closed") };
closedEl = uifactory.addRadiosHorizontal("cif_status", "cif.resources.status", formLayout, statusKeys, statusValues);
closedEl.addActionListener(FormEvent.ONCHANGE);
closedEl.setDomReplacementWrapperRequired(false);
closedEl.select(statusKeys[1], true);
searchParams.setClosed(Boolean.FALSE);
}
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
DefaultFlexiColumnModel markColumn = new DefaultFlexiColumnModel(true, Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.favorit.name());
markColumn.setExportable(false);
columnsModel.addFlexiColumnModel(markColumn);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.type.i18nKey(), Cols.type.ordinal(), true, OrderBy.type.name(), FlexiColumnModel.ALIGNMENT_LEFT, new TypeRenderer()));
FlexiCellRenderer renderer = new StaticFlexiCellRenderer("select", new TextFlexiCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18nKey(), Cols.displayName.ordinal(), "select", true, OrderBy.displayname.name(), renderer));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.authors.i18nKey(), Cols.authors.ordinal(), true, OrderBy.authors.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.location.i18nKey(), Cols.location.ordinal(), true, OrderBy.location.name()));
if (repositoryModule.isManagedRepositoryEntries()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalId.i18nKey(), Cols.externalId.ordinal(), true, OrderBy.externalId.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalRef.i18nKey(), Cols.externalRef.ordinal(), true, OrderBy.externalRef.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lifecycleLabel.i18nKey(), Cols.lifecycleLabel.ordinal(), true, OrderBy.lifecycleLabel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lifecycleSoftkey.i18nKey(), Cols.lifecycleSoftkey.ordinal(), true, OrderBy.lifecycleSoftkey.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleStart.i18nKey(), Cols.lifecycleStart.ordinal(), true, OrderBy.lifecycleStart.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleEnd.i18nKey(), Cols.lifecycleEnd.ordinal(), true, OrderBy.lifecycleEnd.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.author.i18nKey(), Cols.author.ordinal(), true, OrderBy.author.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.access.i18nKey(), Cols.access.ordinal(), true, OrderBy.access.name(), FlexiColumnModel.ALIGNMENT_LEFT, new AccessRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.ac.i18nKey(), Cols.ac.ordinal(), true, OrderBy.ac.name(), FlexiColumnModel.ALIGNMENT_LEFT, new ACRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.creationDate.i18nKey(), Cols.creationDate.ordinal(), true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastUsage.i18nKey(), Cols.lastUsage.ordinal(), true, OrderBy.lastUsage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.references.i18nKey(), Cols.references.ordinal(), true, OrderBy.references.name()));
if (licenseModule.isEnabled(licenseHandler)) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, Cols.license.i18nKey(), Cols.license.ordinal(), "license", false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer("license", new LicenseRenderer(getLocale()))));
}
initActionsColumns(columnsModel);
model = new AuthoringEntryDataModel(dataSource, columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setSearchEnabled(withSearch);
tableEl.setCssDelegate(this);
tableEl.setExportEnabled(true);
tableEl.setExtendedSearch(searchCtrl);
tableEl.setCustomizeColumns(true);
tableEl.setElementCssClass("o_coursetable");
tableEl.setShowAllRowsEnabled(true);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setSortSettings(new FlexiTableSortOptions(true, new SortKey(OrderBy.displayname.name(), true)));
tableEl.setAndLoadPersistedPreferences(ureq, "authors-list-" + i18nName);
if (!withSearch) {
tableEl.reloadData();
tableEl.setFilters(null, getFilters(), false);
}
initBatchButtons(formLayout);
}
use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class PaypalTransactionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
backLink = uifactory.addFormLink("back", formLayout, Link.LINK_BACK);
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.status, new PaypalTransactionStatusRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.orderNr));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.payResponseDate));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.payAmount));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.ipnTransactionId));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.ipnTransactionStatus));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.ipnSenderTransactionId));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.ipnSenderTransactionStatus));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.ipnPendingReason));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.ipnSender));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.payAck));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.payPaymentExecStatus));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.olatStatus));
DefaultFlexiColumnModel selectColumns = new DefaultFlexiColumnModel("select", translate("select"), CMD_SELECT);
selectColumns.setExportable(false);
selectColumns.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(selectColumns);
dataModel = new PaypalTransactionDataModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "results", dataModel, 25, false, getTranslator(), formLayout);
tableEl.setEmtpyTableMessageKey("paypal.transactions.empty");
tableEl.setCustomizeColumns(true);
tableEl.setExportEnabled(true);
tableEl.setSearchEnabled(true);
FlexiTableSortOptions options = new FlexiTableSortOptions();
options.setDefaultOrderBy(new SortKey(Columns.payResponseDate.name(), false));
options.setFromColumnModel(true);
tableEl.setSortSettings(options);
List<FlexiTableFilter> filters = new ArrayList<>();
filters.add(new FlexiTableFilter(translate("show.all"), "showAll"));
filters.add(FlexiTableFilter.SPACER);
for (PaypalMergedState state : PaypalMergedState.values()) {
filters.add(new FlexiTableFilter(translate("filter.".concat(state.name())), state.name()));
}
tableEl.setFilters("", filters, false);
;
tableEl.setAndLoadPersistedPreferences(ureq, "FPaypalTransaction");
}
use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class ParticipantLectureBlocksController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
if (withPrint) {
layoutCont.contextPut("winid", "w" + layoutCont.getFormItemComponent().getDispatchID());
layoutCont.getFormItemComponent().addListener(this);
layoutCont.getFormItemComponent().contextPut("withPrint", Boolean.TRUE);
layoutCont.contextPut("title", StringHelper.escapeHtml(entry.getDisplayname()));
openCourseButton = uifactory.addFormLink("open.course", formLayout, Link.BUTTON);
openCourseButton.setIconLeftCSS("o_icon o_CourseModule_icon");
} else {
layoutCont.contextPut("title", translate("lectures.repository.print.title", new String[] { StringHelper.escapeHtml(entry.getDisplayname()), StringHelper.escapeHtml(userManager.getUserDisplayName(assessedIdentity)) }));
}
layoutCont.contextPut("authorizedAbsenceEnabled", authorizedAbsenceEnabled);
}
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.date, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.entry));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.lectureBlock));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.coach));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.plannedLectures, new LecturesCompulsoryRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.attendedLectures));
if (authorizedAbsenceEnabled) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.unauthorizedAbsentLectures));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.authorizedAbsentLectures));
} else {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.absentLectures));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantCols.status, new LectureBlockRollCallStatusCellRenderer(authorizedAbsenceEnabled, absenceDefaultAuthorized, getTranslator())));
if (appealEnabled && withAppeal && assessedIdentity.equals(getIdentity())) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("appeal", ParticipantCols.appeal.ordinal(), "appeal", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("appeal"), "appeal"), null)));
}
tableModel = new ParticipantLectureBlocksDataModel(columnsModel, authorizedAbsenceEnabled, absenceDefaultAuthorized, getLocale());
int paging = withPrint ? 20 : -1;
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, paging, false, getTranslator(), formLayout);
FlexiTableSortOptions options = new FlexiTableSortOptions();
options.setDefaultOrderBy(new SortKey(ParticipantCols.date.name(), true));
tableEl.setSortSettings(options);
tableEl.setCustomizeColumns(withPrint);
tableEl.setAndLoadPersistedPreferences(ureq, "participant-roll-call-appeal");
tableEl.setEmtpyTableMessageKey("empty.repository.entry.lectures");
List<FlexiTableFilter> filters = new ArrayList<>();
filters.add(new FlexiTableFilter(translate("filter.showAll"), "showAll", true));
filters.add(new FlexiTableFilter(translate("filter.mandatory"), "mandatory"));
tableEl.setFilters("", filters, false);
}
use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.
the class LectureListRepositoryController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (!lectureManagementManaged) {
addLectureButton = uifactory.addFormLink("add.lecture", formLayout, Link.BUTTON);
addLectureButton.setIconLeftCSS("o_icon o_icon_add");
addLectureButton.setElementCssClass("o_sel_repo_add_lecture");
deleteLecturesButton = uifactory.addFormLink("delete", formLayout, Link.BUTTON);
}
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, BlockCols.id));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.title));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.location));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.date, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.startTime, new TimeFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.endTime, new TimeFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.teachers));
if (lectureManagementManaged) {
// edit check it
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("details", translate("details"), "edit"));
} else {
DefaultFlexiColumnModel editColumn = new DefaultFlexiColumnModel("table.header.edit", -1, "edit", new StaticFlexiCellRenderer("", "edit", "o_icon o_icon-lg o_icon_edit", translate("edit"), null));
editColumn.setExportable(false);
editColumn.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(editColumn);
DefaultFlexiColumnModel toolsColumn = new DefaultFlexiColumnModel(BlockCols.tools);
toolsColumn.setExportable(false);
toolsColumn.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(toolsColumn);
}
tableModel = new LectureListRepositoryDataModel(columnsModel, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
tableEl.setEmtpyTableMessageKey("empty.table.lectures.blocks.admin");
FlexiTableSortOptions options = new FlexiTableSortOptions();
options.setDefaultOrderBy(new SortKey(BlockCols.date.name(), false));
tableEl.setSortSettings(options);
tableEl.setAndLoadPersistedPreferences(ureq, "repo-lecture-block-list");
}
Aggregations