use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class FindNodeBranchEntriesByIdCommand method getNodeIds.
private NodeIds getNodeIds(final Context context) {
if (this.ids.isEmpty()) {
return NodeIds.empty();
}
final NodeQuery.Builder queryBuilder = NodeQuery.create().addQueryFilters(Filters.create().add(IdFilter.create().fieldName(NodeIndexPath.ID.getPath()).values(this.ids).build()).build()).from(0).size(ids.getSize()).batchSize(10000).addQueryFilter(AclFilterBuilderFactory.create(context.getAuthInfo().getPrincipals()));
if (!this.orderExpressions.isEmpty()) {
queryBuilder.setOrderExpressions(this.orderExpressions);
}
final SearchResult result = this.nodeSearchService.query(queryBuilder.build(), SingleRepoSearchSource.from(ContextAccessor.current()));
return NodeIds.from(result.getIds());
}
use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class FindNodesDependenciesCommand method addNodeIdsFromReferenceReturnValues.
private void addNodeIdsFromReferenceReturnValues(final SearchResult result, final NodeIds.Builder builder) {
for (SearchHit hit : result.getHits()) {
final ReturnValue returnValue = hit.getReturnValues().get(NodeIndexPath.REFERENCE.getPath());
if (returnValue == null || returnValue.getValues().isEmpty()) {
continue;
}
returnValue.getValues().stream().map((value) -> NodeId.from(value.toString())).filter((value) -> !processed.contains(value)).filter((value) -> !excludedIds.contains(value)).forEach(builder::add);
}
}
use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class FindNodesDependenciesCommand method resolveDependencies.
private NodeIds resolveDependencies(final NodeIds nodeIds) {
Set<NodeId> nonProcessedNodes = nodeIds.getSet().stream().filter((nodeId) -> !processed.contains(nodeId)).collect(Collectors.toSet());
if (nonProcessedNodes.isEmpty()) {
return NodeIds.empty();
}
final SearchResult result = getReferences(nonProcessedNodes);
this.processed.addAll(nonProcessedNodes);
final NodeIds.Builder builder = NodeIds.create();
if (result.isEmpty()) {
return NodeIds.empty();
}
addNodeIdsFromReferenceReturnValues(result, builder);
if (this.recursive) {
NodeIds currentLevelDependencies = builder.build();
if (recursionFilter != null) {
currentLevelDependencies = recursionFilter.apply(currentLevelDependencies);
}
builder.addAll(resolveDependencies(currentLevelDependencies));
}
return builder.build();
}
use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class FindNodesWithVersionDifferenceCommand method execute.
public NodeVersionDiffResult execute() {
final InternalContext context = InternalContext.from(ContextAccessor.current());
final ExcludeEntries excludeEntries = getExcludePaths(context);
final SearchResult result = this.nodeSearchService.query(NodeVersionDiffQuery.create().source(source).target(target).nodePath(nodePath).excludes(excludeEntries).size(this.size).batchSize(BATCH_SIZE).build(), SingleRepoStorageSource.create(ContextAccessor.current().getRepositoryId(), SingleRepoStorageSource.Type.VERSION));
return NodeVersionDiffResultFactory.create(result);
}
use of com.enonic.xp.repo.impl.search.result.SearchResult in project xp by enonic.
the class MoveNodeCommand method doMoveNode.
private Node doMoveNode(final NodePath newParentPath, final NodeName newNodeName, final NodeId id) {
final Node persistedNode = doGetById(id);
final SearchResult result = this.nodeSearchService.query(NodeQuery.create().parent(persistedNode.path()).from(0).size(NodeSearchService.GET_ALL_SIZE_FLAG).build(), SingleRepoSearchSource.from(ContextAccessor.current()));
final NodeBranchEntries nodeBranchEntries = this.nodeStorageService.getBranchNodeVersions(NodeIds.from(result.getIds()), false, InternalContext.from(ContextAccessor.current()));
final Node.Builder nodeToMoveBuilder = Node.create(persistedNode).name(newNodeName).data(processor.process(persistedNode.data())).parentPath(newParentPath).indexConfigDocument(persistedNode.getIndexConfigDocument()).timestamp(Instant.now(CLOCK));
final Node movedNode;
final boolean isTheOriginalMovedNode = persistedNode.id().equals(this.nodeId);
if (isTheOriginalMovedNode) {
final boolean isRenaming = newParentPath.equals(persistedNode.parentPath());
if (!isRenaming) {
updateStoredNodeProperties(newParentPath, nodeToMoveBuilder);
}
}
movedNode = doStore(nodeToMoveBuilder.build());
this.result.addMovedNode(MoveNodeResult.MovedNode.create().previousPath(persistedNode.path()).node(movedNode).build());
nodeMoved(1);
for (final NodeBranchEntry nodeBranchEntry : nodeBranchEntries) {
doMoveNode(nodeToMoveBuilder.build().path(), getNodeName(nodeBranchEntry), nodeBranchEntry.getNodeId());
}
return movedNode;
}
Aggregations