private void appendOrderByItemsJson(final JsonGenerator gen, final List<OrderByItem> orders) throws IOException { gen.writeStartArray(); for (final OrderByItem item : orders) { gen.writeStartObject(); gen.writeStringField("nodeType", "order"); gen.writeStringField("sortorder", item.isDescending() ? "desc" : "asc"); gen.writeFieldName("expression"); appendExpressionJson(gen, item.getExpression()); gen.writeEndObject(); } gen.writeEndArray(); }
private void appendOrderByItemsJson(final JsonGenerator gen, final List<OrderByItem> orders) throws IOException { gen.writeStartArray(); for (final OrderByItem item : orders) { gen.writeStartObject(); gen.writeStringField("nodeType", "order"); gen.writeStringField("sortorder", item.isDescending() ? "desc" : "asc"); gen.writeFieldName("expression"); appendExpressionJson(gen, item.getExpression()); gen.writeEndObject(); } gen.writeEndArray(); }
private void addOrderByExpression(final List<Order> orders, final OrderByItem orderByItem, javax.persistence.criteria.Expression<?> expression) { if (orderByItem.isDescending()) orders.add(cb.desc(expression)); else orders.add(cb.asc(expression)); }
private OrderBy processOrderBy(OrderBy orderBy, List<OrderByItem> orderByItems, DocumentNode resource) throws TeiidException { for (OrderByItem obitem:orderByItems) { ODataExpressionToSQLVisitor visitor = new ODataExpressionToSQLVisitor( resource, false, getUriInfo(), this.metadata, this.odata, this.nameGenerator, this.params, this.parseService); Expression expr = visitor.getExpression(obitem.getExpression()); if (expr instanceof ElementSymbol) { orderBy.addVariable(expr, !obitem.isDescending()); } else { AliasSymbol alias = new AliasSymbol("_orderByAlias", expr); orderBy.addVariable(alias, !obitem.isDescending()); visitor.getEntityResource().addProjectedColumn(alias, EdmInt32.getInstance(), null, false); } } return orderBy; }
result = item.isDescending() ? result * -1 : result; } catch (ExpressionVisitException | ODataApplicationException e) { throw new RuntimeException(e);
orderExp=orderExp.replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", ""); orderBy.setDescending(orderByItem.isDescending()); orderBy.setPropertyName(orderExp); Column col = eInfo.getColumnByName(orderExp, eInfo.getColumns());
orderExp=orderExp.replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", ""); orderBy.setDescending(orderByItem.isDescending()); orderBy.setPropertyName(orderExp); Column col = eInfo.getColumnByName(orderExp, eInfo.getColumns());
orderExp=orderExp.replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", ""); orderBy.setDescending(orderByItem.isDescending()); orderBy.setPropertyName(orderExp); Column col = eInfo.getColumnByName(orderExp, eInfo.getColumns());
orderExp=orderExp.replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", ""); orderBy.setDescending(orderByItem.isDescending()); orderBy.setPropertyName(orderExp); Column col = eInfo.getColumnByName(orderExp, eInfo.getColumns());