use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByBooleanSorting.
@Test
public void testByBooleanSorting() {
String[] orders = { FIELD_BOOL + " " + ORDER_DESC };
FindNodesByQueryResult result = sort(orders);
Iterator<Node> iterator = getNodes(result.getNodeIds()).iterator();
assertEquals("node2", iterator.next().name().toString());
assertEquals("node1", iterator.next().name().toString());
assertEquals("node3", iterator.next().name().toString());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindIssueCommentsCommand method execute.
public FindIssueCommentsResult execute() {
validateBlockingChecks();
final Node issue = nodeService.getById(NodeId.from(this.query.getIssue()));
final NodeQuery nodeQuery = IssueCommentQueryNodeQueryTranslator.translate(this.query, issue.name());
final FindNodesByQueryResult result = nodeService.findByQuery(nodeQuery);
final Nodes foundNodes = this.nodeService.getByIds(result.getNodeIds());
final List<IssueComment> issues = IssueCommentNodeTranslator.fromNodes(foundNodes);
return FindIssueCommentsResult.create().comments(issues).hits(result.getHits()).totalHits(result.getTotalHits()).build();
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindIssuesCommand method execute.
public FindIssuesResult execute() {
final NodeQuery nodeQuery = IssueQueryNodeQueryTranslator.translate(this.query);
final FindNodesByQueryResult result = nodeService.findByQuery(nodeQuery);
final Nodes foundNodes = this.nodeService.getByIds(result.getNodeIds());
final List<Issue> issues = IssueNodeTranslator.fromNodes(foundNodes);
return FindIssuesResult.create().issues(issues).hits(result.getHits()).totalHits(result.getTotalHits()).build();
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindContentIdsByQueryCommandTest method test.
@Test
public void test() {
FindNodesByQueryResult nodesByQueryResult = FindNodesByQueryResult.create().addNodeHit(NodeHit.create().nodeId(NodeId.from("nodeId")).score(1.0f).sort(SortValuesProperty.create().values(84).build()).highlight(HighlightedProperties.create().add(HighlightedProperty.create().name("name").addFragment("fragment").build()).build()).build()).hits(1).build();
Mockito.when(nodeService.findByQuery(Mockito.any(NodeQuery.class))).thenReturn(nodesByQueryResult);
FindContentIdsByQueryCommand command = FindContentIdsByQueryCommand.create().translator(translator).nodeService(nodeService).contentTypeService(contentTypeService).eventPublisher(eventPublisher).query(ContentQuery.create().queryExpr(QueryExpr.from(null, new DynamicOrderExpr(FunctionExpr.from("geoDistance", ValueExpr.string("my-value"), ValueExpr.geoPoint("83,80"), ValueExpr.string("km")), OrderExpr.Direction.ASC))).build()).build();
FindContentIdsByQueryResult result = command.execute();
Assertions.assertFalse(result.getSort().isEmpty());
Assertions.assertEquals(1, result.getSort().size());
Assertions.assertEquals(1, result.getScore().size());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class IndexServiceImplTest method queryForNode.
private Node queryForNode(final NodeId nodeId) {
final FindNodesByQueryResult result = FindNodesByQueryCommand.create().indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).query(NodeQuery.create().query(QueryParser.parse("_id = '" + nodeId.toString() + "'")).build()).build().execute();
final Nodes nodes = getNodes(result.getNodeIds());
return nodes.getNodeById(nodeId);
}
Aggregations