Search in sources :

Example 16 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class SetNodeChildOrderCommand method orderChildNodes.

private void orderChildNodes(final Node parentNode) {
    final SearchResult result = nodeSearchService.query(NodeQuery.create().parent(parentNode.path()).query(new QueryExpr(parentNode.getChildOrder().getOrderExpressions())).size(NodeSearchService.GET_ALL_SIZE_FLAG).batchSize(BATCH_SIZE).searchMode(SearchMode.SEARCH).build(), SingleRepoSearchSource.from(ContextAccessor.current()));
    final NodeIds childNodeIds = NodeIds.from(result.getIds());
    final List<NodeManualOrderValueResolver.NodeIdOrderValue> orderedNodeIds = NodeManualOrderValueResolver.resolve(childNodeIds);
    for (final NodeManualOrderValueResolver.NodeIdOrderValue nodeIdOrderValue : orderedNodeIds) {
        final Node node = doGetById(nodeIdOrderValue.getNodeId());
        final Node editedNode = Node.create(node).manualOrderValue(nodeIdOrderValue.getManualOrderValue()).timestamp(Instant.now(CLOCK)).build();
        StoreNodeCommand.create(this).node(editedNode).build().execute();
    }
}
Also used : QueryExpr(com.enonic.xp.query.expr.QueryExpr) NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult)

Example 17 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class ResolveSyncWorkCommandTest method exclude_all_children.

@Test
public void exclude_all_children() {
    createS1S2Tree();
    refresh();
    final NodeIds children = NodeIds.from("a1", "a2", "a2_1", "a2_1_1", "b2_1", "b2", "s2");
    ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("s1"), children, false);
    assertNodes(result, ExpectedNodes.create().implicit("s1"));
    result = resolveSyncWorkResult(NodeId.from("s1"), children, true);
    assertNodes(result, ExpectedNodes.create().implicit("s1"));
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 18 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class ContentNodeHelperTest method toContentIds.

@Test
public void toContentIds() {
    final NodeIds nodeIds = NodeIds.from("e1f57280-d672-4cd8-b674-98e26e5b69ae", "45d67001-7f2b-4093-99ae-639be9fdd1f6");
    final ContentIds contentIds = ContentNodeHelper.toContentIds(nodeIds);
    assertEquals(ContentIds.from("e1f57280-d672-4cd8-b674-98e26e5b69ae", "45d67001-7f2b-4093-99ae-639be9fdd1f6"), contentIds);
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 19 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class BranchServiceImpl method delete.

@Override
public void delete(final NodeIds nodeIds, final InternalContext context) {
    final NodeBranchEntries nodeBranchEntries = getIgnoreOrder(nodeIds, context);
    nodeBranchEntries.forEach(entry -> pathCache.evict(createPath(entry.getNodePath(), context)));
    storageDao.delete(DeleteRequests.create().forceRefresh(false).ids(nodeIds.stream().map(nodeId -> new BranchDocumentId(nodeId, context.getBranch()).toString()).collect(Collectors.toList())).settings(createStorageSettings(context)).build());
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) NodePaths(com.enonic.xp.node.NodePaths) StoreStorageName(com.enonic.xp.repo.impl.storage.StoreStorageName) SearchRequest(com.enonic.xp.repo.impl.search.SearchRequest) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) ValueFilter(com.enonic.xp.query.filter.ValueFilter) Supplier(java.util.function.Supplier) StorageDao(com.enonic.xp.repo.impl.storage.StorageDao) BranchPath(com.enonic.xp.repo.impl.cache.BranchPath) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult) Component(org.osgi.service.component.annotations.Component) BranchService(com.enonic.xp.repo.impl.branch.BranchService) BranchCachePath(com.enonic.xp.repo.impl.cache.BranchCachePath) SingleRepoStorageSource(com.enonic.xp.repo.impl.SingleRepoStorageSource) SearchDao(com.enonic.xp.repo.impl.search.SearchDao) IdFilter(com.enonic.xp.query.filter.IdFilter) ReturnFields(com.enonic.xp.repo.impl.ReturnFields) Striped(com.google.common.util.concurrent.Striped) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) StaticStorageType(com.enonic.xp.repo.impl.storage.StaticStorageType) InternalContext(com.enonic.xp.repo.impl.InternalContext) StoreRequest(com.enonic.xp.repo.impl.storage.StoreRequest) NodePath(com.enonic.xp.node.NodePath) NodeBranchQueryResult(com.enonic.xp.repo.impl.branch.search.NodeBranchQueryResult) ValueFactory(com.enonic.xp.data.ValueFactory) GetResult(com.enonic.xp.repo.impl.storage.GetResult) Collectors(java.util.stream.Collectors) NodeId(com.enonic.xp.node.NodeId) Objects(java.util.Objects) List(java.util.List) Lock(java.util.concurrent.locks.Lock) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) StorageSource(com.enonic.xp.repo.impl.StorageSource) NodeBranchQueryResultFactory(com.enonic.xp.repo.impl.branch.search.NodeBranchQueryResultFactory) Reference(org.osgi.service.component.annotations.Reference) NodeIds(com.enonic.xp.node.NodeIds) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest) DeleteRequests(com.enonic.xp.repo.impl.storage.DeleteRequests) NodeBranchQuery(com.enonic.xp.repo.impl.branch.search.NodeBranchQuery)

Example 20 with NodeIds

use of com.enonic.xp.node.NodeIds in project xp by enonic.

the class FindNodesDependenciesCommandTest method looping_dependencies.

@Test
public void looping_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(), "n1");
    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());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Aggregations

NodeIds (com.enonic.xp.node.NodeIds)38 Node (com.enonic.xp.node.Node)12 NodeId (com.enonic.xp.node.NodeId)11 Test (org.junit.jupiter.api.Test)11 NodePath (com.enonic.xp.node.NodePath)6 Collectors (java.util.stream.Collectors)5 CompareStatus (com.enonic.xp.content.CompareStatus)4 ContentIds (com.enonic.xp.content.ContentIds)4 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)4 NodeComparison (com.enonic.xp.node.NodeComparison)4 NodeComparisons (com.enonic.xp.node.NodeComparisons)4 NodeQuery (com.enonic.xp.node.NodeQuery)4 Branch (com.enonic.xp.branch.Branch)3 ContentId (com.enonic.xp.content.ContentId)3 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)3 Context (com.enonic.xp.context.Context)3 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)3 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)2 PropertyTree (com.enonic.xp.data.PropertyTree)2