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