@Override public int compare(final T entity1, final T entity2) { try { int result = 0; for (final OrderExpression expression : orderBy.getOrders()) { String first = evaluateExpression(entity1, expression.getExpression()); String second = evaluateExpression(entity2, expression.getExpression()); if (first != null && second != null) { result = first.compareTo(second); } else if (first == null && second != null) { result = 1; } else if (first != null && second == null) { result = -1; } if (expression.getSortOrder() == SortOrder.desc) { result = -result; } if (result != 0) { break; } } return result; } catch (final ODataException e) { return 0; } } });
.append(orderBy.getOrdersCount() == 1 ? "<ul" : "<ol").append(" class=\"expr\">\n"); for (final OrderExpression order : orderBy.getOrders()) { writer.append("<li>"); appendExpression(order.getExpression(), writer); .append("</span></li>\n"); writer.append(orderBy.getOrdersCount() == 1 ? "</ul" : "</ol").append(">\n");
String orderByString; try { orderByString = (String) orderBy.accept(new JsonVisitor()); } catch (final ExceptionVisitExpression e) { orderByString = null;
+ (uriInfo.getOrderBy() == null ? "" : "&$orderby=" + uriInfo.getOrderBy().getExpressionString())
String orderByString; try { orderByString = (String) orderBy.accept(new JsonVisitor()); } catch (final ExceptionVisitExpression e) { orderByString = null;
+ (inlineCount == null ? "" : "&$inlinecount=" + InlineCount.ALLPAGES.toString().toLowerCase(Locale.ROOT)) + (uriInfo.getFilter() == null ? "" : "&$filter=" + uriInfo.getFilter().getExpressionString()) + (uriInfo.getOrderBy() == null ? "" : "&$orderby=" + uriInfo.getOrderBy().getExpressionString()) + (uriInfo.getTop() == null ? "" : (resultEntriesSize < uriInfo.getTop()) ? "&$top=" + top : ""); + (uriInfo.getOrderBy() == null ? "" : "&$orderby=" + uriInfo.getOrderBy().getExpressionString()) + (uriInfo.getTop() == null ? "" : (resultEntriesSize < uriInfo.getTop()) ? "&$top=" + top : "");
@Override public int compare(final T entity1, final T entity2) { try { int result = 0; for (final OrderExpression expression : orderBy.getOrders()) { String first = evaluateExpression(entity1, expression.getExpression()); String second = evaluateExpression(entity2, expression.getExpression()); if (first != null && second != null) { result = first.compareTo(second); } else if (first == null && second != null) { result = 1; } else if (first != null && second == null) { result = -1; } if (expression.getSortOrder() == SortOrder.desc) { result = -result; } if (result != 0) { break; } } return result; } catch (final ODataException e) { return 0; } } });
.append(orderBy.getOrdersCount() == 1 ? "<ul" : "<ol").append(" class=\"expr\">\n"); for (final OrderExpression order : orderBy.getOrders()) { writer.append("<li>"); appendExpression(order.getExpression(), writer); .append("</span></li>\n"); writer.append(orderBy.getOrdersCount() == 1 ? "</ul" : "</ol").append(">\n");
String orderByString; try { orderByString = (String) orderBy.accept(new JsonVisitor()); } catch (final ExceptionVisitExpression e) { orderByString = null;
@Override public int compare(final T entity1, final T entity2) { try { int result = 0; for (final OrderExpression expression : orderBy.getOrders()) { String first = evaluateExpression(entity1, expression.getExpression()); String second = evaluateExpression(entity2, expression.getExpression()); if (first != null && second != null) { result = first.compareTo(second); } else if (first == null && second != null) { result = 1; } else if (first != null && second == null) { result = -1; } if (expression.getSortOrder() == SortOrder.desc) { result = -result; } if (result != 0) { break; } } return result; } catch (final ODataException e) { return 0; } } });
private void setOrderBy(QueryRequest queryRequest, GetEntitySetUriInfo uriInfo) { OrderByExpressionImpl orderItem = null; if (uriInfo.getOrderBy() != null) { for (OrderExpression orderExpr : uriInfo.getOrderBy().getOrders()) { SortOrder sortOrder = orderExpr.getSortOrder(); String order = sortOrder.name(); boolean isDescending = order.equals("desc"); String expression = orderExpr.getExpression().getUriLiteral(); orderItem = new OrderByExpressionImpl(isDescending, expression); ((QueryRequestImpl) queryRequest).setOrderByOption(orderItem); } } }
private void populateQueryOptions(QueryRequestImpl qr, UriInfo uriInfo) throws EdmException { if(uriInfo.getTop() != null) qr.setTopOption(uriInfo.getTop()); if(uriInfo.getSkip() != null) qr.setSkipOption(uriInfo.getSkip()); if(uriInfo.getOrderBy() != null) { for(OrderExpression oe : uriInfo.getOrderBy().getOrders()) { qr.setOrderByOption(new OrderByExpressionImpl(oe.getSortOrder().equals(SortOrder.desc), oe.getExpression().getUriLiteral())); } } if(!uriInfo.getSelect().isEmpty()) { for(SelectItem selectItem : uriInfo.getSelect()) if(selectItem.getProperty() != null) qr.setSelectItems(selectItem.getProperty().getName()); } /* * Custom query options are possible not just for query, but currently the api * to get custom query options is only there in QueryRequest. Hence its done * only here. */ if(!uriInfo.getCustomQueryOptions().isEmpty()) { qr.setCustomQueryOptions(uriInfo.getCustomQueryOptions()); } }