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