use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class ReorderChildNodeCommand method doMoveLast.
private Node doMoveLast() {
final SearchResult result = findLastNodeBeforeInsert(Long.MIN_VALUE);
final Long newOrderValue;
if (result.isEmpty()) {
newOrderValue = resoleOnlyNodeOrderValue();
} else {
newOrderValue = resolveInsertLastOrderValue(result);
}
return doUpdateNodeOrderValue(newOrderValue);
}
use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class NodeOrderTest method geo_distance_sorting.
@Test
public void geo_distance_sorting() throws Exception {
final Node node1 = createNode("node1", ValueFactory.newGeoPoint(GeoPoint.from("80,80")));
final Node node2 = createNode("node2", ValueFactory.newGeoPoint(GeoPoint.from("81,80")));
final Node node3 = createNode("node3", ValueFactory.newGeoPoint(GeoPoint.from("82,80")));
final Node node4 = createNode("node4", ValueFactory.newGeoPoint(GeoPoint.from("83,80")));
final NodeQuery distanceQuery = NodeQuery.create().query(QueryExpr.from(null, new DynamicOrderExpr(FunctionExpr.from("geoDistance", ValueExpr.string("my-value"), ValueExpr.geoPoint("83,80")), OrderExpr.Direction.ASC))).build();
final SearchResult result = searchService.query(distanceQuery, SingleRepoSearchSource.from(ContextAccessor.current()));
final Iterator<String> iterator = result.getIds().iterator();
assertEquals(node4.id(), NodeId.from(iterator.next()));
assertEquals(node3.id(), NodeId.from(iterator.next()));
assertEquals(node2.id(), NodeId.from(iterator.next()));
assertEquals(node1.id(), NodeId.from(iterator.next()));
}
Aggregations