use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class FindNodesByParentCommandTest method from.
@Test
public void from() throws Exception {
this.createDefaultRootNode();
final Node createdNode = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").childOrder(ChildOrder.from("myOrderNumber ASC")).build());
int size = 20;
createChildren(createdNode, size);
FindNodesByParentResult children = findByParent(FindNodesByParentParams.create().parentPath(createdNode.path()).size(10).from(0).build());
assertEquals(10, children.getHits());
assertEquals("my-child-0", getNode(children.getNodeIds().first()).name().toString());
children = findByParent(FindNodesByParentParams.create().parentPath(createdNode.path()).size(10).from(10).build());
assertEquals(10, children.getHits());
assertEquals("my-child-10", getNode(children.getNodeIds().first()).name().toString());
}
use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class FindNodesByParentCommandTest method get_by_parent_one_child.
@Test
public void get_by_parent_one_child() throws Exception {
this.createDefaultRootNode();
final Node createdNode = createNode(CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).build());
final Node childNode = createNode(CreateNodeParams.create().parent(createdNode.path()).name("my-child").build());
final FindNodesByParentResult result = FindNodesByParentCommand.create().params(FindNodesByParentParams.create().parentPath(createdNode.path()).build()).indexServiceInternal(indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
assertEquals(1, result.getNodeIds().getSize());
assertEquals(childNode, getNode(result.getNodeIds().first()));
}
use of com.enonic.xp.node.FindNodesByParentResult in project xp by enonic.
the class SecurityServiceImpl method getIdProviders.
@Override
public IdProviders getIdProviders() {
final FindNodesByParentParams findByParent = FindNodesByParentParams.create().parentPath(IdProviderNodeTranslator.getIdProvidersParentPath()).build();
final Nodes nodes = callWithContext(() -> {
final FindNodesByParentResult result = this.nodeService.findByParent(findByParent);
return this.nodeService.getByIds(result.getNodeIds());
});
return IdProviderNodeTranslator.fromNodes(nodes);
}
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 SetNodeChildOrderCommandTest method order_by_name_desc.
@Test
public void order_by_name_desc() throws Exception {
final FindNodesByParentResult result = createNodeAndReturnOrderedChildren(NodeIndexPath.NAME, OrderExpr.Direction.DESC);
String previousName = "";
for (final NodeId n : result.getNodeIds()) {
final Node node = getNode(n);
final boolean largerThanPreviousName = previousName.compareTo(node.name().toString()) > 0;
assertTrue(Objects.equals(previousName, "") || largerThanPreviousName);
previousName = node.name().toString();
}
}
Aggregations