Search in sources :

Example 1 with NodeVersionDiffResult

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

the class NodeVersionDiffResultFactory method create.

public static NodeVersionDiffResult create(final SearchResult result) {
    if (result.isEmpty()) {
        return NodeVersionDiffResult.create().totalHits(result.getTotalHits()).build();
    }
    final NodeVersionDiffResult.Builder builder = NodeVersionDiffResult.create();
    builder.totalHits(result.getTotalHits());
    for (final SearchHit hit : result.getHits()) {
        builder.add(NodeId.from(hit.getField(VersionIndexPath.NODE_ID.toString()).getSingleValue().toString()));
    }
    return builder.build();
}
Also used : NodeVersionDiffResult(com.enonic.xp.node.NodeVersionDiffResult) SearchHit(com.enonic.xp.repo.impl.search.result.SearchHit)

Example 2 with NodeVersionDiffResult

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

the class ResolveSyncWorkCommand method getInitialDiff.

private NodeIds getInitialDiff() {
    final NodeIds.Builder initialDiff = NodeIds.create().add(this.publishRootNode.id());
    if (!includeChildren && !forceCheckChildren()) {
        return initialDiff.build();
    }
    final Stopwatch timer = Stopwatch.createStarted();
    final NodeVersionDiffResult nodesWithVersionDifference = findNodesWithVersionDifference(this.publishRootNode.path());
    LOG.debug("Diff-query result in " + timer.stop());
    NodeIds nodeIds = NodeIds.from(nodesWithVersionDifference.getNodesWithDifferences().stream().filter((nodeId) -> !this.excludedIds.contains(nodeId)).collect(Collectors.toSet()));
    if (this.initialDiffFilter != null) {
        nodeIds = this.initialDiffFilter.apply(nodeIds);
    }
    return initialDiff.addAll(nodeIds).build();
}
Also used : NodeVersionDiffResult(com.enonic.xp.node.NodeVersionDiffResult) NodeIds(com.enonic.xp.node.NodeIds) Stopwatch(com.google.common.base.Stopwatch)

Example 3 with NodeVersionDiffResult

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

the class FindNodesWithVersionDifferenceCommandTest method assure_correct_diff_order_when_there_are_children.

@Test
public void assure_correct_diff_order_when_there_are_children() {
    final Node node1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("dddd")).parent(NodePath.ROOT).name("dddd").build());
    final Node node1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("ccc")).parent(node1.path()).name("ccc").build());
    final Node node1_1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("11")).parent(node1_1.path()).name("11").build());
    final Node node1_1_1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("_a")).parent(node1_1_1.path()).name("_a").build());
    final Node node2 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2")).parent(NodePath.ROOT).name("node2").build());
    pushNodes(WS_OTHER, node1.id(), node1_1_1_1.id(), node1_1_1.id(), node1_1.id(), node2.id());
    ctxOther().runWith(() -> doUpdateNode(node1_1_1_1));
    ctxOther().runWith(() -> doUpdateNode(node1_1_1));
    ctxOther().runWith(() -> doUpdateNode(node1_1));
    ctxOther().runWith(() -> doUpdateNode(node1));
    NodeVersionDiffResult result = getDiff(WS_DEFAULT, WS_OTHER, node1.path());
    assertEquals(4, result.getNodesWithDifferences().getSize());
    int counter = 0;
    for (final NodeId nodeId : result.getNodesWithDifferences()) {
        if (counter == 0) {
            assertEquals("dddd", nodeId.toString());
        } else if (counter == 1) {
            assertEquals("ccc", nodeId.toString());
        } else if (counter == 2) {
            assertEquals("11", nodeId.toString());
        } else if (counter == 3) {
            assertEquals("_a", nodeId.toString());
        }
        counter++;
    }
}
Also used : NodeVersionDiffResult(com.enonic.xp.node.NodeVersionDiffResult) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) Test(org.junit.jupiter.api.Test)

Aggregations

NodeVersionDiffResult (com.enonic.xp.node.NodeVersionDiffResult)3 Node (com.enonic.xp.node.Node)1 NodeId (com.enonic.xp.node.NodeId)1 NodeIds (com.enonic.xp.node.NodeIds)1 SearchHit (com.enonic.xp.repo.impl.search.result.SearchHit)1 Stopwatch (com.google.common.base.Stopwatch)1 Test (org.junit.jupiter.api.Test)1