Search in sources :

Example 6 with NodeComparisons

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

the class PushNodesCommand method execute.

public InternalPushNodesResult execute() {
    final Context context = ContextAccessor.current();
    refresh();
    final NodeBranchEntries nodeBranchEntries = getNodeBranchEntries();
    final NodeComparisons comparisons = getNodeComparisons(nodeBranchEntries);
    final InternalPushNodesResult.Builder builder = pushNodes(context, nodeBranchEntries, comparisons);
    refresh();
    return builder.build();
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeComparisons(com.enonic.xp.node.NodeComparisons)

Example 7 with NodeComparisons

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

the class FindNodesDependenciesCommandTest method several_layers_of_dependencies_stopped_by_status.

@Test
public void several_layers_of_dependencies_stopped_by_status() 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());
    final NodeIds dependants = FindNodesDependenciesCommand.create().recursive(true).nodeIds(NodeIds.from(node1.id())).indexServiceInternal(this.indexServiceInternal).searchService(this.searchService).storageService(this.storageService).recursionFilter(nodeIds -> {
        final NodeIds.Builder filteredNodeIds = NodeIds.create();
        final NodeComparisons currentLevelNodeComparisons = CompareNodesCommand.create().nodeIds(nodeIds).storageService(this.storageService).target(ContextAccessor.current().getBranch()).build().execute();
        nodeIds.stream().filter(nodeId -> !CompareStatus.EQUAL.equals(currentLevelNodeComparisons.get(nodeId).getCompareStatus())).forEach(filteredNodeIds::add);
        return filteredNodeIds.build();
    }).build().execute();
    assertEquals(1, dependants.getSize(), "Should contain 'node1_1', contains " + dependants.getAsStrings());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Node(com.enonic.xp.node.Node) NodeComparisons(com.enonic.xp.node.NodeComparisons) NodePath(com.enonic.xp.node.NodePath) NodeId(com.enonic.xp.node.NodeId) Test(org.junit.jupiter.api.Test) Reference(com.enonic.xp.util.Reference) ContextAccessor(com.enonic.xp.context.ContextAccessor) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NodeIds(com.enonic.xp.node.NodeIds) CompareStatus(com.enonic.xp.content.CompareStatus) PropertyTree(com.enonic.xp.data.PropertyTree) NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) NodeComparisons(com.enonic.xp.node.NodeComparisons) Test(org.junit.jupiter.api.Test)

Example 8 with NodeComparisons

use of com.enonic.xp.node.NodeComparisons 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)

Aggregations

NodeComparisons (com.enonic.xp.node.NodeComparisons)8 NodeComparison (com.enonic.xp.node.NodeComparison)3 NodeId (com.enonic.xp.node.NodeId)3 NodeIds (com.enonic.xp.node.NodeIds)3 CompareStatus (com.enonic.xp.content.CompareStatus)2 Context (com.enonic.xp.context.Context)2 Node (com.enonic.xp.node.Node)2 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)2 InternalContext (com.enonic.xp.repo.impl.InternalContext)2 Test (org.junit.jupiter.api.Test)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 NodePath (com.enonic.xp.node.NodePath)1 NodePaths (com.enonic.xp.node.NodePaths)1 Reference (com.enonic.xp.util.Reference)1 HashSet (java.util.HashSet)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1