Search in sources :

Example 21 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class FindNodesDependenciesCommandTest method exclude_dependencies.

@Test
public void exclude_dependencies() throws Exception {
    final Node node1 = createNodeWithReference("n1", NodePath.ROOT, "n1_1", "n1_2");
    final Node node1_1 = createNodeWithReference("n1_1", node1.path(), "n1_1_1");
    final Node node1_2 = createNodeWithReference("n1_2", node1.path(), "n1_2_1");
    createNodeWithReference("n1_1_1", node1_1.path());
    createNodeWithReference("n1_2_1", node1_2.path());
    final NodeIds dependants = FindNodesDependenciesCommand.create().recursive(true).nodeIds(NodeIds.from(node1.id())).excludedIds(NodeIds.from(node1_1.id())).indexServiceInternal(this.indexServiceInternal).searchService(this.searchService).storageService(this.storageService).build().execute();
    assertEquals(2, dependants.getSize());
    assertTrue(dependants.contains(node1_2.id()), "Should contain node1_2");
    assertTrue(dependants.contains(NodeId.from("n1_2_1")), "Should contain node1_2_1");
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 22 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class FindNodesDependenciesCommandTest method several_layers_of_dependencies.

@Test
public void several_layers_of_dependencies() throws Exception {
    final Node node1 = createNodeWithReference("n1", NodePath.ROOT, "n1_1");
    final Node node1_1 = createNodeWithReference("n1_1", node1.path(), "n1_1_1");
    createNodeWithReference("n1_1_1", node1_1.path());
    final NodeIds dependants = FindNodesDependenciesCommand.create().recursive(true).nodeIds(NodeIds.from(node1.id())).indexServiceInternal(this.indexServiceInternal).searchService(this.searchService).storageService(this.storageService).build().execute();
    assertEquals(2, dependants.getSize(), "Should contain [node1_1(r),node1_1_1(r), contains " + dependants.getAsStrings());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 23 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class DeleteIssueCommentCommand method doExecute.

private DeleteIssueCommentResult doExecute() {
    validateBlockingChecks();
    NodeIds deletedIds = nodeService.deleteById(params.getComment());
    nodeService.refresh(RefreshMode.SEARCH);
    return new DeleteIssueCommentResult(deletedIds);
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) DeleteIssueCommentResult(com.enonic.xp.issue.DeleteIssueCommentResult)

Example 24 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class FindNodesDependenciesCommandTest method several_layers_of_dependencies_non_recursive.

@Test
public void several_layers_of_dependencies_non_recursive() throws Exception {
    final Node node1 = createNodeWithReference("n1", NodePath.ROOT, "n1_1");
    final Node node1_1 = createNodeWithReference("n1_1", node1.path(), "n1_1_1");
    createNodeWithReference("n1_1_1", node1_1.path());
    final NodeIds dependants = FindNodesDependenciesCommand.create().recursive(false).nodeIds(NodeIds.from(node1.id())).indexServiceInternal(this.indexServiceInternal).searchService(this.searchService).storageService(this.storageService).build().execute();
    assertEquals(1, dependants.getSize(), "Should contain [node1_1(r)], contains " + dependants.getAsStrings());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 25 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class FindNodesDependenciesCommandTest method several_layers_of_dependencies_stopped_by_status.

@Test
public void several_layers_of_dependencies_stopped_by_status() throws Exception {
    final Node node1 = createNodeWithReference("n1", NodePath.ROOT, "n1_1");
    final Node node1_1 = createNodeWithReference("n1_1", node1.path(), "n1_1_1");
    createNodeWithReference("n1_1_1", node1_1.path());
    final NodeIds dependants = FindNodesDependenciesCommand.create().recursive(true).nodeIds(NodeIds.from(node1.id())).indexServiceInternal(this.indexServiceInternal).searchService(this.searchService).storageService(this.storageService).recursionFilter(nodeIds -> {
        final NodeIds.Builder filteredNodeIds = NodeIds.create();
        final NodeComparisons currentLevelNodeComparisons = CompareNodesCommand.create().nodeIds(nodeIds).storageService(this.storageService).target(ContextAccessor.current().getBranch()).build().execute();
        nodeIds.stream().filter(nodeId -> !CompareStatus.EQUAL.equals(currentLevelNodeComparisons.get(nodeId).getCompareStatus())).forEach(filteredNodeIds::add);
        return filteredNodeIds.build();
    }).build().execute();
    assertEquals(1, dependants.getSize(), "Should contain 'node1_1', contains " + dependants.getAsStrings());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Node(com.enonic.xp.node.Node) NodeComparisons(com.enonic.xp.node.NodeComparisons) NodePath(com.enonic.xp.node.NodePath) NodeId(com.enonic.xp.node.NodeId) Test(org.junit.jupiter.api.Test) Reference(com.enonic.xp.util.Reference) ContextAccessor(com.enonic.xp.context.ContextAccessor) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NodeIds(com.enonic.xp.node.NodeIds) CompareStatus(com.enonic.xp.content.CompareStatus) PropertyTree(com.enonic.xp.data.PropertyTree) NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) NodeComparisons(com.enonic.xp.node.NodeComparisons) Test(org.junit.jupiter.api.Test)

Aggregations

NodeIds (com.enonic.xp.node.NodeIds)38 Node (com.enonic.xp.node.Node)12 NodeId (com.enonic.xp.node.NodeId)11 Test (org.junit.jupiter.api.Test)11 NodePath (com.enonic.xp.node.NodePath)6 Collectors (java.util.stream.Collectors)5 CompareStatus (com.enonic.xp.content.CompareStatus)4 ContentIds (com.enonic.xp.content.ContentIds)4 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)4 NodeComparison (com.enonic.xp.node.NodeComparison)4 NodeComparisons (com.enonic.xp.node.NodeComparisons)4 NodeQuery (com.enonic.xp.node.NodeQuery)4 Branch (com.enonic.xp.branch.Branch)3 ContentId (com.enonic.xp.content.ContentId)3 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)3 Context (com.enonic.xp.context.Context)3 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)3 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)2 PropertyTree (com.enonic.xp.data.PropertyTree)2