use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class PushNodeHandlerTest method testExample3.
@Test
public void testExample3() {
Mockito.when(nodeService.resolveSyncWork(Mockito.isA(SyncWorkResolverParams.class))).thenReturn(ResolveSyncWorkResult.create().add(new NodeComparison(createEntry("a"), createEntry("a"), CompareStatus.NEW)).add(new NodeComparison(createEntry("b"), createEntry("b"), CompareStatus.NEW)).add(new NodeComparison(createEntry("c"), createEntry("c"), CompareStatus.NEW)).build());
Mockito.when(nodeService.push(Mockito.isA(NodeIds.class), Mockito.eq(Branch.from("otherBranch")))).thenReturn(PushNodesResult.create().addSuccess(createEntry("a")).addSuccess(createEntry("d")).build());
runScript("/lib/xp/examples/node/push-3.js");
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class CompareContentCommand method execute.
public CompareContentResult execute() {
final NodeId nodeId = NodeId.from(contentId.toString());
final NodeComparison compareResult = this.nodeService.compare(nodeId, this.target);
return CompareResultTranslator.translate(compareResult);
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class DeleteContentCommand method getCompareStatus.
private CompareStatus getCompareStatus(final NodeId nodeToDelete) {
final Context context = ContextAccessor.current();
final Branch currentBranch = context.getBranch();
final NodeComparison compare;
if (currentBranch.equals(ContentConstants.BRANCH_DRAFT)) {
compare = this.nodeService.compare(nodeToDelete, ContentConstants.BRANCH_MASTER);
} else {
compare = this.nodeService.compare(nodeToDelete, ContentConstants.BRANCH_DRAFT);
}
return compare.getCompareStatus();
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class ResolveRequiredDependenciesCommand method getRequiredIds.
private ContentIds getRequiredIds(final NodeComparisons nodeComparisons) {
final NodePaths parentPaths = getParentPaths(nodeComparisons.getComparisons());
final NodePaths resultPaths = nodeComparisons.getSourcePaths();
final Set<ContentId> requiredIds = parentPaths.stream().filter(resultPaths::contains).map(parentPath -> {
final NodeComparison comparison = nodeComparisons.getBySourcePath(parentPath);
if (!CompareStatus.NEWER.equals(comparison.getCompareStatus())) {
return ContentId.from(comparison.getNodeId().toString());
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toSet());
return ContentIds.from(requiredIds);
}
use of com.enonic.xp.node.NodeComparison 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));
}
}
Aggregations