Search in sources :

Example 41 with ResolveSyncWorkResult

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

the class ResolveContentsToBePublishedCommand method getWorkResult.

private ResolveSyncWorkResult getWorkResult(final ContentId contentId) {
    final NodeIds nodeIds = excludedContentIds != null ? NodeIds.from(excludedContentIds.stream().map(id -> NodeId.from(id.toString())).collect(Collectors.toList())) : NodeIds.empty();
    final boolean includeChildren = excludeChildrenIds == null || !this.excludeChildrenIds.contains(contentId);
    return nodeService.resolveSyncWork(SyncWorkResolverParams.create().includeChildren(includeChildren).includeDependencies(this.includeDependencies).nodeId(NodeId.from(contentId.toString())).excludedNodeIds(nodeIds).branch(this.target).statusesToStopDependenciesSearch(Set.of(CompareStatus.EQUAL)).build());
}
Also used : ContentId(com.enonic.xp.content.ContentId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) ContentIds(com.enonic.xp.content.ContentIds) Set(java.util.Set) Preconditions(com.google.common.base.Preconditions) Collectors(java.util.stream.Collectors) Branch(com.enonic.xp.branch.Branch) NodeIds(com.enonic.xp.node.NodeIds) CompareContentResults(com.enonic.xp.content.CompareContentResults) CompareStatus(com.enonic.xp.content.CompareStatus) NodeId(com.enonic.xp.node.NodeId) SyncWorkResolverParams(com.enonic.xp.node.SyncWorkResolverParams) NodeIds(com.enonic.xp.node.NodeIds)

Example 42 with ResolveSyncWorkResult

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

the class ResolveContentsToBePublishedCommand method resolveDependencies.

private void resolveDependencies() {
    for (final ContentId contentId : this.contentIds) {
        final ResolveSyncWorkResult syncWorkResult = getWorkResult(contentId);
        this.resultBuilder.addAll(CompareResultTranslator.translate(syncWorkResult.getNodeComparisons()));
    }
}
Also used : ContentId(com.enonic.xp.content.ContentId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Example 43 with ResolveSyncWorkResult

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

the class ResolveSyncWorkResultMapperTest method full.

@Test
public void full() throws Exception {
    final ResolveSyncWorkResult result = ResolveSyncWorkResult.create().add(new NodeComparison(createEntry("a"), createEntry("a"), CompareStatus.NEW)).add(new NodeComparison(createEntry("b"), createEntry("b"), CompareStatus.MOVED)).add(new NodeComparison(createEntry("c"), createEntry("c"), CompareStatus.NEWER)).build();
    final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
    new ResolveSyncWorkResultMapper(result).serialize(jsonGenerator);
    assertJson("resolveSyncWork/full.json", jsonGenerator);
}
Also used : NodeComparison(com.enonic.xp.node.NodeComparison) JsonMapGenerator(com.enonic.xp.script.serializer.JsonMapGenerator) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 44 with ResolveSyncWorkResult

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

the class PushNodeHandler method doResolve.

private void doResolve(final NodeIds nodeIds, final NodeIds.Builder toBePushed, final NodeIds.Builder toBeDeleted) {
    for (final NodeId nodeId : nodeIds) {
        final ResolveSyncWorkResult result = this.nodeService.resolveSyncWork(SyncWorkResolverParams.create().nodeId(nodeId).branch(targetBranch).excludedNodeIds(getNodeIds(exclude)).includeChildren(includeChildren).build());
        result.getNodeComparisons().forEach(nodeComparison -> {
            if (nodeComparison.getCompareStatus().equals(CompareStatus.PENDING_DELETE)) {
                toBeDeleted.add(nodeComparison.getNodeId());
            } else {
                toBePushed.add(nodeComparison.getNodeId());
            }
        });
    }
}
Also used : NodeId(com.enonic.xp.node.NodeId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Aggregations

ResolveSyncWorkResult (com.enonic.xp.node.ResolveSyncWorkResult)44 Test (org.junit.jupiter.api.Test)39 Node (com.enonic.xp.node.Node)14 PropertyTree (com.enonic.xp.data.PropertyTree)3 NodeId (com.enonic.xp.node.NodeId)3 ContentId (com.enonic.xp.content.ContentId)2 NodeIds (com.enonic.xp.node.NodeIds)2 Stopwatch (com.google.common.base.Stopwatch)2 Disabled (org.junit.jupiter.api.Disabled)2 Branch (com.enonic.xp.branch.Branch)1 CompareContentResults (com.enonic.xp.content.CompareContentResults)1 CompareStatus (com.enonic.xp.content.CompareStatus)1 ContentIds (com.enonic.xp.content.ContentIds)1 ResolveSyncWorkResultMapper (com.enonic.xp.lib.node.mapper.ResolveSyncWorkResultMapper)1 NodeComparison (com.enonic.xp.node.NodeComparison)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 PushNodesResult (com.enonic.xp.node.PushNodesResult)1 SyncWorkResolverParams (com.enonic.xp.node.SyncWorkResolverParams)1 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)1 Preconditions (com.google.common.base.Preconditions)1