private static Query.SortDirection getSortDirection(OrderExpression oe) { return oe.getSortOrder() == null || oe.getSortOrder().equals("ascending") ? Query.SortDirection.ASCENDING : Query.SortDirection.DESCENDING; }
OrderExpression order = new OrderExpression(); order.AttributeName = "name"; order.OrderType = OrderType.Ascending;
Expression expr = orderExpr.getLeft(); if (expr instanceof PrimaryExpression) orderSqlExprs[i] = (SQLExpression)orderExpr.getLeft().evaluate(this); String orderDir = orderExpr.getSortOrder(); directions[i] = ((orderDir == null || orderDir.equals("ascending")) ? false : true); nullOrders[i] = orderExpr.getNullOrder();
/** * Method to compile the ordering clause of the query */ protected void compileOrdering() { if (compilation.getExprOrdering() != null) { compileComponent = CompilationComponent.ORDERING; orderingObject = new BasicDBObject(); for (Expression expr : compilation.getExprOrdering()) { OrderExpression orderExpr = (OrderExpression)expr; MongoFieldExpression orderMongoExpr = (MongoFieldExpression) orderExpr.getLeft().evaluate(this); if(orderMongoExpr == null) continue; String orderDir = orderExpr.getSortOrder(); int direction = ((orderDir == null || orderDir.equals("ascending")) ? 1 : -1); orderingObject.put(orderMongoExpr.getPropertyName(), direction); } compileComponent = null; } }
orderExpr.evaluate(this); Neo4jExpression neoExpr = stack.pop(); orderStr.append(neoExpr.getCypherText()); String orderDir = orderExpr.getSortOrder(); if (orderDir.equalsIgnoreCase("descending"))
new org.datanucleus.query.expression.OrderExpression(((ExpressionImpl)order.getExpression()).getQueryExpression(), order.getDirection() == OrderDirection.ASC ? "ascending" : "descending"); orderExpr.bind(symtbl); orderExprs[i++] = orderExpr;
/** * @param qd The QueryData * @param orderExpr The OrderExpression * @return The name of the sort property that was added to the primary datastore query. */ String getSortProperty(QueryData qd, OrderExpression orderExpr) { PrimaryExpression left = (PrimaryExpression) orderExpr.getLeft(); AbstractClassMetaData acmd = qd.acmd; List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias()); if (isJoin(left.getLeft(), tuples)) { // Change the class meta data to the meta-data for the joined class acmd = getJoinClassMetaData(left.getLeft(), tuples, qd); } AbstractMemberMetaData ammd = getMemberMetaDataForTuples(acmd, tuples); if (ammd == null) { throw noMetaDataException(left.getId(), acmd.getFullClassName()); } if (MetaDataUtils.isParentPKField(ammd)) { throw new UnsupportedDatastoreFeatureException("Cannot sort by parent."); } else { String sortProp; if (ammd.isPrimaryKey()) { sortProp = Entity.KEY_RESERVED_PROPERTY; } else { sortProp = determinePropertyName(ammd); } return sortProp; } }
orderExpr.bind(symtbl); orderExprs[i++] = orderExpr;
if (((OrderExpression)orderingExpr[i]).getSortOrder() == null || ((OrderExpression)orderingExpr[i]).getSortOrder().equals("ascending"))
/** * Method to return the underlying DataNucleus query expression that this equates to. * @return The order Expression */ public org.datanucleus.query.expression.OrderExpression getQueryExpression() { return new OrderExpression(((ExpressionImpl)expr).getQueryExpression(), ascending ? "ascending" : "descending"); }
Query q = query.descend(descendedObject); if (((OrderExpression)orderingExpr[i]).getSortOrder() == null || ((OrderExpression)orderingExpr[i]).getSortOrder().equals("ascending"))
private OrderExpression createJoinOrderExpression(PrimaryExpression expression) { PrimaryExpression primaryOrderExpr = new PrimaryExpression(expression.getTuples()); return new OrderExpression(primaryOrderExpr); }
appendExpression(h, expr.getLeft(), executionContext); OrderExpression order = (OrderExpression) expr; h.sb.append(String.format(" %s ", "ascending".equals(order.getSortOrder()) ? "ASC" : "DESC")); } else if (expr instanceof CreatorExpression) { CreatorExpression ce = (CreatorExpression) expr;
appendExpression(h, expr.getLeft(), executionContext); OrderExpression order = (OrderExpression) expr; h.sb.append(String.format(" %s ", "ascending".equals(order.getSortOrder()) ? "ASC" : "DESC")); } else if (expr instanceof CreatorExpression) { CreatorExpression ce = (CreatorExpression) expr;