Search in sources :

Example 6 with ChildOrder

use of com.enonic.xp.index.ChildOrder in project xp by enonic.

the class NodeChildOrderResolverTest method user_parent_child_order.

@Test
public void user_parent_child_order() throws Exception {
    final ChildOrder childOrder = ChildOrder.from("myField DESC");
    final Node parent = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("parent").childOrder(childOrder).build());
    final ChildOrder resolvedOrder = NodeChildOrderResolver.create().nodePath(parent.path()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().resolve();
    assertEquals(childOrder, resolvedOrder);
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 7 with ChildOrder

use of com.enonic.xp.index.ChildOrder in project xp by enonic.

the class NodeChildOrderResolverTest method given_child_order_as_param.

@Test
public void given_child_order_as_param() throws Exception {
    final ChildOrder childOrder = ChildOrder.from("myField DESC");
    final ChildOrder resolvedOrder = NodeChildOrderResolver.create().nodePath(NodePath.create("myPath").build()).childOrder(childOrder).build().resolve();
    assertEquals(childOrder, resolvedOrder);
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Test(org.junit.jupiter.api.Test)

Example 8 with ChildOrder

use of com.enonic.xp.index.ChildOrder in project xp by enonic.

the class NodeChildOrderResolverTest method user_parent_child_order_when_root.

@Test
public void user_parent_child_order_when_root() throws Exception {
    final ChildOrder childOrder = ChildOrder.from("myField DESC");
    CreateRootNodeCommand.create().params(CreateRootNodeParams.create().childOrder(childOrder).build()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    final ChildOrder resolvedOrder = NodeChildOrderResolver.create().nodePath(NodePath.ROOT).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().resolve();
    assertEquals(childOrder, resolvedOrder);
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Test(org.junit.jupiter.api.Test)

Example 9 with ChildOrder

use of com.enonic.xp.index.ChildOrder in project xp by enonic.

the class SecurityInitializer method initializeIdProviderParentFolder.

private void initializeIdProviderParentFolder() {
    final NodePath idProviderParentNodePath = IdProviderNodeTranslator.getIdProvidersParentPath();
    LOG.info("Initializing [" + idProviderParentNodePath.toString() + "] folder");
    final AccessControlEntry userManagerFullAccess = AccessControlEntry.create().allowAll().principal(RoleKeys.USER_MANAGER_ADMIN).build();
    final ChildOrder childOrder = ChildOrder.create().add(FieldOrderExpr.create(NodeIndexPath.NAME, OrderExpr.Direction.ASC)).build();
    nodeService.create(CreateNodeParams.create().parent(idProviderParentNodePath.getParentPath()).name(idProviderParentNodePath.getLastElement().toString()).permissions(AccessControlList.create().addAll(SystemConstants.SYSTEM_REPO_DEFAULT_ACL.getEntries()).add(userManagerFullAccess).build()).inheritPermissions(false).childOrder(childOrder).build());
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) NodePath(com.enonic.xp.node.NodePath)

Example 10 with ChildOrder

use of com.enonic.xp.index.ChildOrder in project xp by enonic.

the class ResolveInsertOrderValueCommand method execute.

public Long execute() {
    RefreshCommand.create().indexServiceInternal(this.indexServiceInternal).refreshMode(RefreshMode.SEARCH).build().execute();
    final ChildOrder childOrder = InsertManualStrategy.LAST.equals(insertManualStrategy) ? ChildOrder.reverseManualOrder() : ChildOrder.manualOrder();
    final FindNodesByParentResult findNodesByParentResult = doFindNodesByParent(FindNodesByParentParams.create().parentPath(parentPath).childOrder(childOrder).size(1).build());
    if (findNodesByParentResult.isEmpty()) {
        return NodeManualOrderValueResolver.START_ORDER_VALUE;
    } else {
        if (InsertManualStrategy.LAST.equals(insertManualStrategy)) {
            return insertAsLast(findNodesByParentResult);
        } else {
            return insertAsFirst(findNodesByParentResult);
        }
    }
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Aggregations

ChildOrder (com.enonic.xp.index.ChildOrder)10 Test (org.junit.jupiter.api.Test)6 Node (com.enonic.xp.node.Node)4 NodePath (com.enonic.xp.node.NodePath)4 PropertyTree (com.enonic.xp.data.PropertyTree)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2 SearchResult (com.enonic.xp.repo.impl.search.result.SearchResult)2 AccessControlList (com.enonic.xp.security.acl.AccessControlList)2 Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 EventPublisher (com.enonic.xp.event.EventPublisher)1 CreateRootNodeParams (com.enonic.xp.node.CreateRootNodeParams)1 DuplicateNodeParams (com.enonic.xp.node.DuplicateNodeParams)1 FindNodesByParentParams (com.enonic.xp.node.FindNodesByParentParams)1 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)1 GetNodeVersionsParams (com.enonic.xp.node.GetNodeVersionsParams)1 MoveNodeParams (com.enonic.xp.node.MoveNodeParams)1 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)1 NodeCommitId (com.enonic.xp.node.NodeCommitId)1