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