Search in sources :

Example 6 with FindNodesByParentResult

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());
}
Also used : Node(com.enonic.xp.node.Node) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Test(org.junit.jupiter.api.Test)

Example 7 with FindNodesByParentResult

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()));
}
Also used : Node(com.enonic.xp.node.Node) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Test(org.junit.jupiter.api.Test)

Example 8 with FindNodesByParentResult

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);
}
Also used : FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Nodes(com.enonic.xp.node.Nodes)

Example 9 with FindNodesByParentResult

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();
}
Also used : Contents(com.enonic.xp.content.Contents) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Nodes(com.enonic.xp.node.Nodes)

Example 10 with FindNodesByParentResult

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();
    }
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Test(org.junit.jupiter.api.Test)

Aggregations

FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)39 Node (com.enonic.xp.node.Node)28 Test (org.junit.jupiter.api.Test)17 NodeId (com.enonic.xp.node.NodeId)14 Nodes (com.enonic.xp.node.Nodes)9 FindNodesByParentParams (com.enonic.xp.node.FindNodesByParentParams)5 Context (com.enonic.xp.context.Context)3 ContextAccessor (com.enonic.xp.context.ContextAccessor)3 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)3 RefreshMode (com.enonic.xp.node.RefreshMode)3 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)3 ArchiveConstants (com.enonic.xp.archive.ArchiveConstants)2 Branch (com.enonic.xp.branch.Branch)2 ContentAccessException (com.enonic.xp.content.ContentAccessException)2 ContentConstants (com.enonic.xp.content.ContentConstants)2 ContentIds (com.enonic.xp.content.ContentIds)2 ContentInheritType (com.enonic.xp.content.ContentInheritType)2 ARCHIVED_BY (com.enonic.xp.content.ContentPropertyNames.ARCHIVED_BY)2 ARCHIVED_TIME (com.enonic.xp.content.ContentPropertyNames.ARCHIVED_TIME)2 ORIGINAL_NAME (com.enonic.xp.content.ContentPropertyNames.ORIGINAL_NAME)2