use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindAuditLogCommand method runQuery.
private FindAuditLogResult runQuery() {
final NodeQuery query = createQuery();
if (query == null) {
return FindAuditLogResult.empty();
}
FindNodesByQueryResult result = nodeService.findByQuery(query);
List<AuditLog> logs = result.getNodeIds().stream().map(nodeService::getById).map(AuditLogSerializer::fromNode).collect(Collectors.toList());
return FindAuditLogResult.create().total(result.getTotalHits()).hits(AuditLogs.from(logs)).build();
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class NodesHasPermissionResolver method execute.
public boolean execute() {
final Context context = ContextAccessor.current();
if (context.getAuthInfo().hasRole(RoleKeys.ADMIN)) {
return true;
}
if (nodeIds.isEmpty()) {
return false;
}
final NodeQuery query = NodeQuery.create().addQueryFilter(IdFilter.create().fieldName(NodeIndexPath.ID.getPath()).values(nodeIds).build()).addQueryFilter(ValueFilter.create().fieldName(getPermissionFieldName().getPath()).addValues(context.getAuthInfo().getPrincipals().stream().map(PrincipalKey::toString).collect(Collectors.toList())).build()).searchMode(SearchMode.COUNT).build();
final FindNodesByQueryResult result = FindNodesByQueryCommand.create(this).query(query).build().execute();
return result.getTotalHits() == nodeIds.getSize();
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class CreateIssueCommand method countTotalIssues.
private long countTotalIssues() {
final IssueQuery query = IssueQuery.create().size(0).count(true).build();
final NodeQuery nodeQuery = IssueQueryNodeQueryTranslator.translate(query);
final FindNodesByQueryResult result = nodeService.findByQuery(nodeQuery);
return result.getTotalHits();
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindeNodesByQueryCommandTest_like method queryAndExpect.
private void queryAndExpect(final String queryString, final int expected) {
final NodeQuery query = NodeQuery.create().query(QueryParser.parse(queryString)).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(expected, result.getHits());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order_geoDistance method order_by_odd_geopoint.
@Test
public void order_by_odd_geopoint() throws Exception {
createGeoLocations();
final FindNodesByQueryResult result = doQuery("_parentPath = '/' ORDER BY geoDistance('myLocation', '" + ODD_GEOPOINT.getLatitude() + "," + ODD_GEOPOINT.getLongitude() + "')");
assertEquals(result.getNodeIds().getSize(), 8);
}
Aggregations