use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class DeleteIssueCommentCommandTest method delete.
@Test
public void delete() {
DeleteIssueCommentParams params = DeleteIssueCommentParams.create().comment(NodeId.from(UUID.randomUUID())).build();
final NodeIds nodeIds = NodeIds.from(params.getComment());
final DeleteIssueCommentCommand command = createDeleteIssueCommentCommand(params);
Mockito.when(this.nodeService.deleteById(Mockito.any(NodeId.class))).thenReturn(nodeIds);
final DeleteIssueCommentResult result = command.execute();
assertNotNull(result);
assertEquals(1, result.getIds().getSize());
assertEquals(params.getComment(), result.getIds().first());
}
use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class DeleteScheduledJobCommand method doExecute.
private boolean doExecute() {
final NodeIds result = nodeService.deleteByPath(NodePath.create(NodePath.ROOT, name.getValue()).build());
nodeService.refresh(RefreshMode.ALL);
return !result.isEmpty();
}
use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class DeleteContentCommand method doDeleteContent.
private DeleteContentsResult doDeleteContent(NodeId nodeToDelete) {
final CompareStatus rootNodeStatus = getCompareStatus(nodeToDelete);
final DeleteContentsResult.Builder result = DeleteContentsResult.create();
if (rootNodeStatus == CompareStatus.NEW) {
// Root node is new, just delete all children
final NodeIds nodes = this.nodeService.deleteById(nodeToDelete, this);
result.addDeleted(ContentIds.from(nodes.getAsStrings()));
} else if (this.params.isDeleteOnline()) {
deleteNodeInDraftAndMaster(nodeToDelete, result);
} else {
this.nodeService.setNodeState(SetNodeStateParams.create().nodeId(nodeToDelete).nodeState(NodeState.PENDING_DELETE).build());
result.addPending(ContentId.from(nodeToDelete.toString()));
this.nodesDeleted(1);
final NodeIds children = getDirectChildren(nodeToDelete);
for (final NodeId child : children) {
final DeleteContentsResult childDeleteResult = this.doDeleteContent(child);
result.addDeleted(childDeleteResult.getDeletedContents());
result.addPending(childDeleteResult.getPendingContents());
}
}
return result.build();
}
use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class ResolveSyncWorkCommand method getAllPossibleNodesToBePublished.
private void getAllPossibleNodesToBePublished() {
final NodeIds.Builder diffAndDependantsBuilder = NodeIds.create();
final NodeIds initialDiff = getInitialDiff();
diffAndDependantsBuilder.addAll(initialDiff);
if (includeDependencies) {
final NodeIds nodeDependencies = getNodeDependencies(initialDiff);
diffAndDependantsBuilder.addAll(nodeDependencies);
}
final Set<NodeComparison> comparisons = getFilteredComparisons(diffAndDependantsBuilder);
addNewAndMovedParents(comparisons);
comparisons.forEach(this::addToResult);
markPendingDeleteChildrenForDeletion(comparisons);
}
use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class ResolveSyncWorkCommand method addNewAndMovedParents.
private void addNewAndMovedParents(final Set<NodeComparison> comparisons) {
final NodePaths parentPaths = getPathsFromComparisons(comparisons);
final NodeIds parentIds = getParentIdsFromPaths(parentPaths);
final NodeIds.Builder filteredParentIdsBuilder = NodeIds.create();
getFilteredNewAndMovedParentComparisons(parentIds).stream().map(NodeComparison::getNodeId).forEach(filteredParentIdsBuilder::add);
final NodeIds filteredParentIds = filteredParentIdsBuilder.build();
final NodeIds parentsDependencies = includeDependencies ? getNodeDependencies(filteredParentIds) : NodeIds.empty();
final NodeComparisons newComparisonsToConsider = CompareNodesCommand.create().nodeIds(NodeIds.create().addAll(parentsDependencies).addAll(filteredParentIds).build()).target(this.target).storageService(this.nodeStorageService).build().execute();
final Set<NodeComparison> newAndMoved = getNewAndMoved(newComparisonsToConsider);
addToResult(NodeComparisons.create().addAll(newAndMoved).build());
if (!newAndMoved.isEmpty()) {
addNewAndMovedParents(newAndMoved);
}
}
Aggregations