Search in sources :

Example 1 with Status

use of org.olat.resource.accesscontrol.ui.OrderTableItem.Status in project OpenOLAT by OpenOLAT.

the class ACFrontendManager method findOrderItems.

@Override
public List<OrderTableItem> findOrderItems(OLATResource resource, IdentityRef delivery, Long orderNr, Date from, Date to, OrderStatus[] status, int firstResult, int maxResults, List<UserPropertyHandler> userPropertyHandlers, SortKey... orderBy) {
    List<AccessMethod> methods = methodManager.getAllMethods();
    Map<String, AccessMethod> methodMap = new HashMap<>();
    for (AccessMethod method : methods) {
        methodMap.put(method.getKey().toString(), method);
    }
    List<RawOrderItem> rawOrders = orderManager.findNativeOrderItems(resource, delivery, orderNr, from, to, status, firstResult, maxResults, userPropertyHandlers, orderBy);
    List<OrderTableItem> items = new ArrayList<>(rawOrders.size());
    for (RawOrderItem rawOrder : rawOrders) {
        String orderStatusStr = rawOrder.getOrderStatus();
        OrderStatus orderStatus = OrderStatus.valueOf(orderStatusStr);
        Status finalStatus = getStatus(orderStatusStr, rawOrder.getTrxStatus(), rawOrder.getPspTrxStatus());
        String methodIds = rawOrder.getTrxMethodIds();
        List<AccessMethod> orderMethods = new ArrayList<>(2);
        if (StringHelper.containsNonWhitespace(methodIds)) {
            String[] methodIdArr = methodIds.split(",");
            for (String methodId : methodIdArr) {
                if (methodMap.containsKey(methodId)) {
                    orderMethods.add(methodMap.get(methodId));
                }
            }
        }
        OrderTableItem item = new OrderTableItem(rawOrder.getOrderKey(), rawOrder.getOrderNr(), rawOrder.getTotal(), rawOrder.getCreationDate(), orderStatus, finalStatus, rawOrder.getDeliveryKey(), rawOrder.getUsername(), rawOrder.getUserProperties(), orderMethods);
        item.setResourceDisplayname(rawOrder.getResourceName());
        items.add(item);
    }
    return items;
}
Also used : OrderStatus(org.olat.resource.accesscontrol.OrderStatus) Status(org.olat.resource.accesscontrol.ui.OrderTableItem.Status) AccessTransactionStatus(org.olat.resource.accesscontrol.model.AccessTransactionStatus) PSPTransactionStatus(org.olat.resource.accesscontrol.model.PSPTransactionStatus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RawOrderItem(org.olat.resource.accesscontrol.model.RawOrderItem) OrderStatus(org.olat.resource.accesscontrol.OrderStatus) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) OrderTableItem(org.olat.resource.accesscontrol.ui.OrderTableItem)

Example 2 with Status

use of org.olat.resource.accesscontrol.ui.OrderTableItem.Status in project openolat by klemens.

the class ACFrontendManager method findOrderItems.

@Override
public List<OrderTableItem> findOrderItems(OLATResource resource, IdentityRef delivery, Long orderNr, Date from, Date to, OrderStatus[] status, int firstResult, int maxResults, List<UserPropertyHandler> userPropertyHandlers, SortKey... orderBy) {
    List<AccessMethod> methods = methodManager.getAllMethods();
    Map<String, AccessMethod> methodMap = new HashMap<>();
    for (AccessMethod method : methods) {
        methodMap.put(method.getKey().toString(), method);
    }
    List<RawOrderItem> rawOrders = orderManager.findNativeOrderItems(resource, delivery, orderNr, from, to, status, firstResult, maxResults, userPropertyHandlers, orderBy);
    List<OrderTableItem> items = new ArrayList<>(rawOrders.size());
    for (RawOrderItem rawOrder : rawOrders) {
        String orderStatusStr = rawOrder.getOrderStatus();
        OrderStatus orderStatus = OrderStatus.valueOf(orderStatusStr);
        Status finalStatus = getStatus(orderStatusStr, rawOrder.getTrxStatus(), rawOrder.getPspTrxStatus());
        String methodIds = rawOrder.getTrxMethodIds();
        List<AccessMethod> orderMethods = new ArrayList<>(2);
        if (StringHelper.containsNonWhitespace(methodIds)) {
            String[] methodIdArr = methodIds.split(",");
            for (String methodId : methodIdArr) {
                if (methodMap.containsKey(methodId)) {
                    orderMethods.add(methodMap.get(methodId));
                }
            }
        }
        OrderTableItem item = new OrderTableItem(rawOrder.getOrderKey(), rawOrder.getOrderNr(), rawOrder.getTotal(), rawOrder.getCreationDate(), orderStatus, finalStatus, rawOrder.getDeliveryKey(), rawOrder.getUsername(), rawOrder.getUserProperties(), orderMethods);
        item.setResourceDisplayname(rawOrder.getResourceName());
        items.add(item);
    }
    return items;
}
Also used : OrderStatus(org.olat.resource.accesscontrol.OrderStatus) Status(org.olat.resource.accesscontrol.ui.OrderTableItem.Status) AccessTransactionStatus(org.olat.resource.accesscontrol.model.AccessTransactionStatus) PSPTransactionStatus(org.olat.resource.accesscontrol.model.PSPTransactionStatus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RawOrderItem(org.olat.resource.accesscontrol.model.RawOrderItem) OrderStatus(org.olat.resource.accesscontrol.OrderStatus) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) OrderTableItem(org.olat.resource.accesscontrol.ui.OrderTableItem)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 OrderStatus (org.olat.resource.accesscontrol.OrderStatus)2 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)2 AccessTransactionStatus (org.olat.resource.accesscontrol.model.AccessTransactionStatus)2 PSPTransactionStatus (org.olat.resource.accesscontrol.model.PSPTransactionStatus)2 RawOrderItem (org.olat.resource.accesscontrol.model.RawOrderItem)2 OrderTableItem (org.olat.resource.accesscontrol.ui.OrderTableItem)2 Status (org.olat.resource.accesscontrol.ui.OrderTableItem.Status)2