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");
}
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());
}
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);
}
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());
}
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());
}
Aggregations