use of org.olat.core.gui.ShortName in project OpenOLAT by OpenOLAT.
the class MailListController method reloadModel.
private void reloadModel() {
List<DBMailLight> mails;
if (outbox) {
if (StringHelper.containsNonWhitespace(metaId)) {
mails = mailManager.getEmailsByMetaId(metaId);
} else {
mails = mailManager.getOutbox(getIdentity(), 0, -1, true);
}
// strip meta emails
Set<String> metaIds = new HashSet<>();
for (Iterator<DBMailLight> it = mails.iterator(); it.hasNext(); ) {
DBMailLight mail = it.next();
if (StringHelper.containsNonWhitespace(mail.getMetaId())) {
if (metaIds.contains(mail.getMetaId())) {
it.remove();
} else {
metaIds.add(mail.getMetaId());
}
}
}
} else {
mails = mailManager.getInbox(getIdentity(), null, Boolean.TRUE, null, 0, -1);
}
// extract contexts
Map<String, String> bpToContexts = new HashMap<>();
for (DBMailLight mail : mails) {
String businessPath = mail.getContext().getBusinessPath();
if (StringHelper.containsNonWhitespace(businessPath) && !bpToContexts.containsKey(businessPath)) {
String contextName = contextResolver.getName(businessPath, getLocale());
if (StringHelper.containsNonWhitespace(contextName)) {
bpToContexts.put(businessPath, contextName);
}
}
}
if (!bpToContexts.isEmpty()) {
List<ShortName> filters = new ArrayList<>();
Map<String, MailContextShortName> uniqueNames = new HashMap<>();
ShortName allContextFilter = new MailContextShortName("-");
filters.add(allContextFilter);
for (Map.Entry<String, String> entry : bpToContexts.entrySet()) {
String businessPath = entry.getKey();
String contextName = entry.getValue();
if (!uniqueNames.containsKey(contextName)) {
MailContextShortName cxt = new MailContextShortName(contextName, new HashSet<String>());
filters.add(cxt);
uniqueNames.put(contextName, cxt);
}
uniqueNames.get(contextName).getBusinessPaths().add(businessPath);
}
tableCtr.setFilters(filters, allContextFilter);
}
Formatter formatter = Formatter.getInstance(getLocale());
MailDataModel dataModel = new MailDataModel(mails, bpToContexts, getIdentity(), getTranslator(), formatter, outbox);
tableCtr.setTableDataModel(dataModel);
}
use of org.olat.core.gui.ShortName in project OpenOLAT by OpenOLAT.
the class OrderDetailController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
backLink = uifactory.addFormLink("back", formLayout, Link.LINK_BACK);
FormLayoutContainer mainLayout = FormLayoutContainer.createDefaultFormLayout("mainCmp", getTranslator());
mainLayout.setRootForm(mainForm);
formLayout.add("mainCmp", mainLayout);
String orderNr = order.getOrderNr();
uifactory.addStaticTextElement("order-nr", "order.nr", orderNr, mainLayout);
Date creationDate = order.getCreationDate();
String creationDateStr = Formatter.getInstance(getLocale()).formatDateAndTime(creationDate);
uifactory.addStaticTextElement("creation-date", "order.creationDate", creationDateStr, mainLayout);
String orderTotal = PriceFormat.fullFormat(order.getTotal());
String orderTotalStr;
if (acModule.isVatEnabled()) {
BigDecimal vat = acModule.getVat();
String vatStr = vat == null ? "" : vat.setScale(3, BigDecimal.ROUND_HALF_EVEN).toPlainString();
orderTotalStr = translate("access.info.price.vat", new String[] { orderTotal, vatStr });
} else {
orderTotalStr = translate("access.info.price.noVat", new String[] { orderTotal });
}
uifactory.addStaticTextElement("order-total", "order.total", orderTotalStr, mainLayout);
OrderItemsDataModel tableModel = getOrderItemsDataModel();
if (tableModel.getRowCount() == 1) {
OrderItemWrapper wrapper = tableModel.getObject(0);
if (wrapper.getItem().getOffer().getResource() != null) {
// resource is null if the resource has been deleted
String linkName = StringHelper.escapeHtml(wrapper.getDisplayName());
selectResourceLink = uifactory.addFormLink("resource", linkName, translate("order.item"), mainLayout, Link.NONTRANSLATED);
selectResourceLink.setUserObject(wrapper);
selectResourceLink.setCustomEnabledLinkCSS("form-control-static");
}
}
User user = order.getDelivery().getUser();
String delivery = StringHelper.escapeHtml(userManager.getUserDisplayName(user));
uifactory.addStaticTextElement("delivery", "order.delivery", delivery, mainLayout);
if (formLayout instanceof FormLayoutContainer) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setDownloadOffered(false);
tableConfig.setTableEmptyMessage(translate("orders.empty"));
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), Collections.<ShortName>emptyList(), null, null, null, false, getTranslator());
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("order.item.name", 0, null, getLocale()));
tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("order.part.payment", 1, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new AccessMethodRenderer(acModule)));
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(CMD_SELECT, "table.order.details", getTranslator().translate("order.details")));
tableCtr.setTableDataModel(tableModel);
listenTo(tableCtr);
FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;
layoutContainer.put("orderItemList", tableCtr.getInitialComponent());
}
}
use of org.olat.core.gui.ShortName in project OpenOLAT by OpenOLAT.
the class RepositorySearchController method updateFilters.
protected void updateFilters(List<RepositoryEntry> entries, Identity owner) {
List<ShortName> restrictedTypes = new ArrayList<ShortName>();
Set<String> uniqueTypes = new HashSet<String>();
for (RepositoryEntry entry : entries) {
// no red screen for that
if (entry.getOlatResource() == null)
continue;
String type = entry.getOlatResource().getResourceableTypeName();
if (type != null && !uniqueTypes.contains(type)) {
String label = translate(type);
restrictedTypes.add(new TypeFilter(type, label, owner));
uniqueTypes.add(type);
}
}
if (restrictedTypes.size() > 1) {
tableCtr.setFilters(restrictedTypes, null);
} else {
tableCtr.setFilters(null, null);
}
}
use of org.olat.core.gui.ShortName in project openolat by klemens.
the class OrderDetailController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
backLink = uifactory.addFormLink("back", formLayout, Link.LINK_BACK);
FormLayoutContainer mainLayout = FormLayoutContainer.createDefaultFormLayout("mainCmp", getTranslator());
mainLayout.setRootForm(mainForm);
formLayout.add("mainCmp", mainLayout);
String orderNr = order.getOrderNr();
uifactory.addStaticTextElement("order-nr", "order.nr", orderNr, mainLayout);
Date creationDate = order.getCreationDate();
String creationDateStr = Formatter.getInstance(getLocale()).formatDateAndTime(creationDate);
uifactory.addStaticTextElement("creation-date", "order.creationDate", creationDateStr, mainLayout);
String orderTotal = PriceFormat.fullFormat(order.getTotal());
String orderTotalStr;
if (acModule.isVatEnabled()) {
BigDecimal vat = acModule.getVat();
String vatStr = vat == null ? "" : vat.setScale(3, BigDecimal.ROUND_HALF_EVEN).toPlainString();
orderTotalStr = translate("access.info.price.vat", new String[] { orderTotal, vatStr });
} else {
orderTotalStr = translate("access.info.price.noVat", new String[] { orderTotal });
}
uifactory.addStaticTextElement("order-total", "order.total", orderTotalStr, mainLayout);
OrderItemsDataModel tableModel = getOrderItemsDataModel();
if (tableModel.getRowCount() == 1) {
OrderItemWrapper wrapper = tableModel.getObject(0);
if (wrapper.getItem().getOffer().getResource() != null) {
// resource is null if the resource has been deleted
String linkName = StringHelper.escapeHtml(wrapper.getDisplayName());
selectResourceLink = uifactory.addFormLink("resource", linkName, translate("order.item"), mainLayout, Link.NONTRANSLATED);
selectResourceLink.setUserObject(wrapper);
selectResourceLink.setCustomEnabledLinkCSS("form-control-static");
}
}
User user = order.getDelivery().getUser();
String delivery = StringHelper.escapeHtml(userManager.getUserDisplayName(user));
uifactory.addStaticTextElement("delivery", "order.delivery", delivery, mainLayout);
if (formLayout instanceof FormLayoutContainer) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setDownloadOffered(false);
tableConfig.setTableEmptyMessage(translate("orders.empty"));
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), Collections.<ShortName>emptyList(), null, null, null, false, getTranslator());
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("order.item.name", 0, null, getLocale()));
tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("order.part.payment", 1, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new AccessMethodRenderer(acModule)));
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(CMD_SELECT, "table.order.details", getTranslator().translate("order.details")));
tableCtr.setTableDataModel(tableModel);
listenTo(tableCtr);
FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;
layoutContainer.put("orderItemList", tableCtr.getInitialComponent());
}
}
use of org.olat.core.gui.ShortName in project openolat by klemens.
the class MailListController method reloadModel.
private void reloadModel() {
List<DBMailLight> mails;
if (outbox) {
if (StringHelper.containsNonWhitespace(metaId)) {
mails = mailManager.getEmailsByMetaId(metaId);
} else {
mails = mailManager.getOutbox(getIdentity(), 0, -1, true);
}
// strip meta emails
Set<String> metaIds = new HashSet<>();
for (Iterator<DBMailLight> it = mails.iterator(); it.hasNext(); ) {
DBMailLight mail = it.next();
if (StringHelper.containsNonWhitespace(mail.getMetaId())) {
if (metaIds.contains(mail.getMetaId())) {
it.remove();
} else {
metaIds.add(mail.getMetaId());
}
}
}
} else {
mails = mailManager.getInbox(getIdentity(), null, Boolean.TRUE, null, 0, -1);
}
// extract contexts
Map<String, String> bpToContexts = new HashMap<>();
for (DBMailLight mail : mails) {
String businessPath = mail.getContext().getBusinessPath();
if (StringHelper.containsNonWhitespace(businessPath) && !bpToContexts.containsKey(businessPath)) {
String contextName = contextResolver.getName(businessPath, getLocale());
if (StringHelper.containsNonWhitespace(contextName)) {
bpToContexts.put(businessPath, contextName);
}
}
}
if (!bpToContexts.isEmpty()) {
List<ShortName> filters = new ArrayList<>();
Map<String, MailContextShortName> uniqueNames = new HashMap<>();
ShortName allContextFilter = new MailContextShortName("-");
filters.add(allContextFilter);
for (Map.Entry<String, String> entry : bpToContexts.entrySet()) {
String businessPath = entry.getKey();
String contextName = entry.getValue();
if (!uniqueNames.containsKey(contextName)) {
MailContextShortName cxt = new MailContextShortName(contextName, new HashSet<String>());
filters.add(cxt);
uniqueNames.put(contextName, cxt);
}
uniqueNames.get(contextName).getBusinessPaths().add(businessPath);
}
tableCtr.setFilters(filters, allContextFilter);
}
Formatter formatter = Formatter.getInstance(getLocale());
MailDataModel dataModel = new MailDataModel(mails, bpToContexts, getIdentity(), getTranslator(), formatter, outbox);
tableCtr.setTableDataModel(dataModel);
}
Aggregations