use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class FindContentByParentCommand method execute.
FindContentByParentResult execute() {
final FindNodesByParentResult result = nodeService.findByParent(createFindNodesByParentParams());
final Nodes nodes = this.nodeService.getByIds(result.getNodeIds());
final Contents contents = this.translator.fromNodes(nodes, true);
return FindContentByParentResult.create().contents(contents).totalHits(result.getTotalHits()).hits(result.getHits()).build();
}
use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class RestoreContentCommand method updateProperties.
private void updateProperties(final Node node, final boolean isRootContent) {
final FindNodesByParentResult childrenToRestore = nodeService.findByParent(FindNodesByParentParams.create().size(-1).recursive(true).parentId(node.id()).build());
childrenToRestore.getNodeIds().forEach(id -> nodeService.update(UpdateNodeParams.create().id(id).editor(toBeEdited -> {
toBeEdited.data.removeProperties(ARCHIVED_TIME);
toBeEdited.data.removeProperties(ARCHIVED_BY);
}).build()));
if (isRootContent) {
nodeService.update(UpdateNodeParams.create().id(node.id()).editor(toBeEdited -> {
toBeEdited.data.removeProperties(ORIGINAL_PARENT_PATH);
toBeEdited.data.removeProperties(ORIGINAL_NAME);
toBeEdited.data.removeProperties(ARCHIVED_TIME);
toBeEdited.data.removeProperties(ARCHIVED_BY);
}).build());
}
}
use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class UnpublishContentCommand method recursiveUnpublish.
private void recursiveUnpublish(final NodeId nodeId, boolean includeChildren, final ContentIds.Builder contentsBuilder) {
if (includeChildren) {
final FindNodesByParentResult result = this.nodeService.findByParent(FindNodesByParentParams.create().parentId(nodeId).build());
result.getNodeIds().forEach((id) -> recursiveUnpublish(id, true, contentsBuilder));
}
final NodeIds nodes = this.nodeService.deleteById(nodeId);
if (nodes != null && nodes.isNotEmpty()) {
if (params.getPublishContentListener() != null) {
params.getPublishContentListener().contentPushed(1);
}
contentsBuilder.add(ContentId.from(nodes.first().toString()));
}
}
use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class RepoDumper method dumpBranch.
private void dumpBranch(final BranchDumpResult.Builder dumpResult, Consumer<NodeId> nodeIdsAccumulator) {
final Node rootNode = this.nodeService.getRoot();
final FindNodesByParentResult children = this.nodeService.findByParent(FindNodesByParentParams.create().parentId(rootNode.id()).recursive(true).childOrder(ChildOrder.from("_path asc")).build());
final Branch branch = ContextAccessor.current().getBranch();
this.listener.dumpingBranch(repository.getId(), branch, children.getTotalHits() + 1);
LOG.info("Dumping repository [{}], branch [{}]", repository.getId(), branch);
doDumpNode(rootNode.id(), dumpResult);
nodeIdsAccumulator.accept(rootNode.id());
for (final NodeId child : children.getNodeIds()) {
doDumpNode(child, dumpResult);
nodeIdsAccumulator.accept(child);
}
}
use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class AbstractDeleteNodeCommand method newResolveNodesToDelete.
private NodeBranchEntries newResolveNodesToDelete(final Node node) {
final FindNodeIdsByParentCommand command = FindNodeIdsByParentCommand.create(this).parentPath(node.path()).recursive(true).childOrder(ChildOrder.reversePath()).size(NodeSearchService.GET_ALL_SIZE_FLAG).build();
final FindNodesByParentResult result = command.execute();
final NodeIds nodeIds = NodeIds.create().addAll(result.getNodeIds()).add(node.id()).build();
return FindNodeBranchEntriesByIdCommand.create(command).ids(nodeIds).orderExpressions(ChildOrder.reversePath().getOrderExpressions()).build().execute();
}
Aggregations