use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class ParticipantListRepositoryController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer && !printView) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("winid", "w" + layoutCont.getFormItemComponent().getDispatchID());
layoutCont.getFormItemComponent().addListener(this);
layoutCont.getFormItemComponent().contextPut("withPrint", Boolean.TRUE);
}
FlexiTableSortOptions options = new FlexiTableSortOptions();
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.username));
options.setDefaultOrderBy(new SortKey(ParticipantsCols.username.sortKey(), true));
}
int colPos = USER_PROPS_OFFSET;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
FlexiColumnModel col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
columnsModel.addFlexiColumnModel(col);
colPos++;
if (!options.hasDefaultOrderBy()) {
options.setDefaultOrderBy(new SortKey(propName, true));
} else if (UserConstants.LASTNAME.equals(propName)) {
options.setDefaultOrderBy(new SortKey(propName, true));
}
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.plannedLectures));
if (rollCallEnabled) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.attendedLectures));
if (authorizedAbsenceEnabled) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.unauthorizedAbsenceLectures));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.authorizedAbsenceLectures));
} else {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.absentLectures, new LongCellRenderer("o_sel_absences")));
}
FlexiColumnModel progressCol = new DefaultFlexiColumnModel(ParticipantsCols.progress, new LectureStatisticsCellRenderer());
progressCol.setExportable(false);
columnsModel.addFlexiColumnModel(progressCol);
}
if (rateEnabled) {
FlexiColumnModel warningCol = new DefaultFlexiColumnModel(ParticipantsCols.rateWarning, new RateWarningCellRenderer(getTranslator()));
warningCol.setExportable(false);
columnsModel.addFlexiColumnModel(warningCol);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.rate, new PercentCellRenderer()));
}
FlexiColumnModel infoCol = new DefaultFlexiColumnModel(ParticipantsCols.infos, new ParticipantInfosRenderer(getTranslator(), defaultRate));
infoCol.setExportable(false);
columnsModel.addFlexiColumnModel(infoCol);
if (!printView) {
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);
}
tableModel = new ParticipantListDataModel(columnsModel, getTranslator(), getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
tableEl.setExportEnabled(!printView);
tableEl.setEmtpyTableMessageKey("empty.table.participant.list");
tableEl.setSortSettings(options);
tableEl.setAndLoadPersistedPreferences(ureq, "participant-list-repo-entry");
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
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");
}
Aggregations