use of com.enonic.xp.node.NodeComparisons in project xp by enonic.
the class ResolveRequiredDependenciesCommand method resolveDependencies.
private void resolveDependencies() {
final NodeComparisons nodeComparisons = nodeService.compare(NodeIds.from(contentIds.asStrings()), target);
this.resultBuilder.addAll(getRequiredIds(nodeComparisons));
}
use of com.enonic.xp.node.NodeComparisons in project xp by enonic.
the class UndoPendingDeleteContentCommand method undoDeleteContent.
private void undoDeleteContent(final NodeIds nodeIds) {
final NodeComparisons compare = this.nodeService.compare(nodeIds, this.params.getTarget());
Set<NodeComparison> pendingDeleteNodes = compare.getWithStatus(CompareStatus.PENDING_DELETE);
for (final NodeComparison nodeComparison : pendingDeleteNodes) {
ensureValidParent(nodeComparison);
removePendingDeleteState(nodeComparison);
}
for (NodeId nodeId : nodeIds) {
this.undoDeleteContent(this.getAllChildren(nodeId));
}
}
use of com.enonic.xp.node.NodeComparisons in project xp by enonic.
the class ResolveSyncWorkCommand method addNewAndMovedParents.
private void addNewAndMovedParents(final Set<NodeComparison> comparisons) {
final NodePaths parentPaths = getPathsFromComparisons(comparisons);
final NodeIds parentIds = getParentIdsFromPaths(parentPaths);
final NodeIds.Builder filteredParentIdsBuilder = NodeIds.create();
getFilteredNewAndMovedParentComparisons(parentIds).stream().map(NodeComparison::getNodeId).forEach(filteredParentIdsBuilder::add);
final NodeIds filteredParentIds = filteredParentIdsBuilder.build();
final NodeIds parentsDependencies = includeDependencies ? getNodeDependencies(filteredParentIds) : NodeIds.empty();
final NodeComparisons newComparisonsToConsider = CompareNodesCommand.create().nodeIds(NodeIds.create().addAll(parentsDependencies).addAll(filteredParentIds).build()).target(this.target).storageService(this.nodeStorageService).build().execute();
final Set<NodeComparison> newAndMoved = getNewAndMoved(newComparisonsToConsider);
addToResult(NodeComparisons.create().addAll(newAndMoved).build());
if (!newAndMoved.isEmpty()) {
addNewAndMovedParents(newAndMoved);
}
}
use of com.enonic.xp.node.NodeComparisons in project xp by enonic.
the class CompareNodesCommandTest method compare_nodes.
@Test
public void compare_nodes() throws Exception {
final Node node = createNode(CreateNodeParams.create().name("node1").parent(NodePath.ROOT).build());
final Node node2 = createNode(CreateNodeParams.create().name("node2").parent(NodePath.ROOT).build());
final Node node3 = createNode(CreateNodeParams.create().name("node3").parent(NodePath.ROOT).build());
pushNodes(NodeIds.from(node.id(), node2.id()), WS_OTHER);
doDeleteNode(node2.id());
refresh();
final NodeComparisons result = CompareNodesCommand.create().nodeIds(NodeIds.from(node.id(), node2.id(), node3.id())).storageService(this.storageService).target(WS_OTHER).build().execute();
assertEquals(1, result.getWithStatus(CompareStatus.NEW_TARGET).size());
assertEquals(1, result.getWithStatus(CompareStatus.NEW).size());
assertEquals(1, result.getWithStatus(CompareStatus.EQUAL).size());
}
use of com.enonic.xp.node.NodeComparisons in project xp by enonic.
the class CompareNodesCommand method execute.
public NodeComparisons execute() {
Set<NodeId> allNodeIds = new HashSet<>();
final Context context = ContextAccessor.current();
final NodeComparisons.Builder builder = NodeComparisons.create();
final NodeBranchEntries sourceVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.from(context));
final NodeBranchEntries targetVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.create(context).branch(this.target).build());
allNodeIds.addAll(sourceVersions.getKeys());
allNodeIds.addAll(targetVersions.getKeys());
for (final NodeId id : allNodeIds) {
final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceVersions.get(id)).target(targetVersions.get(id)).storageService(this.nodeStorageService).build().resolve();
builder.add(new NodeComparison(sourceVersions.get(id), targetVersions.get(id), compareStatus));
}
return builder.build();
}
Aggregations