Search in sources :

Example 26 with NodeIds

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

the class PushNodeHandler method execute.

@Override
public Object execute() {
    final NodeIds.Builder toBePushed = NodeIds.create();
    final NodeIds.Builder toBeDeleted = NodeIds.create();
    final NodeIds nodeIds = getNodeIds();
    if (resolve) {
        doResolve(nodeIds, toBePushed, toBeDeleted);
    } else {
        toBePushed.addAll(getNodeIds());
    }
    final PushNodesResult push = this.nodeService.push(toBePushed.build(), targetBranch);
    final NodeIds deletedNodes = doDelete(toBeDeleted);
    return new PushNodesResultMapper(push, deletedNodes);
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) PushNodesResult(com.enonic.xp.node.PushNodesResult) PushNodesResultMapper(com.enonic.xp.lib.node.mapper.PushNodesResultMapper)

Example 27 with NodeIds

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

the class CompareContentsCommand method execute.

public CompareContentResults execute() {
    this.nodeService.refresh(RefreshMode.ALL);
    final NodeIds nodeIds = ContentNodeHelper.toNodeIds(this.contentIds);
    final NodeComparisons comparisons = this.nodeService.compare(nodeIds, this.target);
    return CompareResultTranslator.translate(comparisons);
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) NodeComparisons(com.enonic.xp.node.NodeComparisons)

Example 28 with NodeIds

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

the class ContentNodeHelperTest method toNodeIds.

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

Example 29 with NodeIds

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

the class DeleteNodeByIdCommandTest method delete_with_capital_letter_in_id.

@Test
public void delete_with_capital_letter_in_id() {
    final Node node = createNode(CreateNodeParams.create().setNodeId(NodeId.from("myNodeId")).name("myNode").parent(NodePath.ROOT).build());
    final Node childNode = createNode(CreateNodeParams.create().setNodeId(NodeId.from("myChildNodeId")).name("myChildNode").parent(node.path()).build());
    final NodeIds nodeIds = doDeleteNode(node.id());
    assertEquals(2, nodeIds.getSize());
    assertNull(getNode(node.id()));
    assertNull(getNode(childNode.id()));
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 30 with NodeIds

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

the class ResolveContentsToBePublishedCommand method getWorkResult.

private ResolveSyncWorkResult getWorkResult(final ContentId contentId) {
    final NodeIds nodeIds = excludedContentIds != null ? NodeIds.from(excludedContentIds.stream().map(id -> NodeId.from(id.toString())).collect(Collectors.toList())) : NodeIds.empty();
    final boolean includeChildren = excludeChildrenIds == null || !this.excludeChildrenIds.contains(contentId);
    return nodeService.resolveSyncWork(SyncWorkResolverParams.create().includeChildren(includeChildren).includeDependencies(this.includeDependencies).nodeId(NodeId.from(contentId.toString())).excludedNodeIds(nodeIds).branch(this.target).statusesToStopDependenciesSearch(Set.of(CompareStatus.EQUAL)).build());
}
Also used : ContentId(com.enonic.xp.content.ContentId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) ContentIds(com.enonic.xp.content.ContentIds) Set(java.util.Set) Preconditions(com.google.common.base.Preconditions) Collectors(java.util.stream.Collectors) Branch(com.enonic.xp.branch.Branch) NodeIds(com.enonic.xp.node.NodeIds) CompareContentResults(com.enonic.xp.content.CompareContentResults) CompareStatus(com.enonic.xp.content.CompareStatus) NodeId(com.enonic.xp.node.NodeId) SyncWorkResolverParams(com.enonic.xp.node.SyncWorkResolverParams) NodeIds(com.enonic.xp.node.NodeIds)

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