Search in sources :

Example 1 with NodePaths

use of com.enonic.xp.node.NodePaths 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);
}
Also used : NodeComparison(com.enonic.xp.node.NodeComparison) NodePaths(com.enonic.xp.node.NodePaths) ContentId(com.enonic.xp.content.ContentId)

Example 2 with NodePaths

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

the class ContentNodeHelperTest method translateNodePathsToContentPaths.

@Test
public void translateNodePathsToContentPaths() {
    final NodePaths nodePaths = NodePaths.from("/content/site/myContent", "/content/folder/other/content");
    final ContentPaths contentPaths = ContentNodeHelper.translateNodePathsToContentPaths(nodePaths);
    assertEquals(ContentPaths.from("/site/myContent", "/folder/other/content"), contentPaths);
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) NodePaths(com.enonic.xp.node.NodePaths) Test(org.junit.jupiter.api.Test)

Example 3 with NodePaths

use of com.enonic.xp.node.NodePaths 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);
    }
}
Also used : NodeComparison(com.enonic.xp.node.NodeComparison) NodePaths(com.enonic.xp.node.NodePaths) NodeIds(com.enonic.xp.node.NodeIds) NodeComparisons(com.enonic.xp.node.NodeComparisons)

Example 4 with NodePaths

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

the class ContentNodeHelperTest method translateContentPathsToNodePaths.

@Test
public void translateContentPathsToNodePaths() {
    final ContentPaths contentPaths = ContentPaths.create().add(ContentPath.from("/site/myContent")).add(ContentPath.from("/folder/other/content")).build();
    final NodePaths nodePaths = ContentNodeHelper.translateContentPathsToNodePaths(contentPaths);
    assertEquals(NodePaths.from("/content/site/myContent", "/content/folder/other/content"), nodePaths);
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) NodePaths(com.enonic.xp.node.NodePaths) Test(org.junit.jupiter.api.Test)

Example 5 with NodePaths

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

the class GetContentByPathsCommand method doExecute.

private Contents doExecute() {
    final NodePaths paths = ContentNodeHelper.translateContentPathsToNodePaths(contentPaths);
    final Nodes nodes = nodeService.getByPaths(paths);
    return this.translator.fromNodes(nodes, true);
}
Also used : NodePaths(com.enonic.xp.node.NodePaths) Nodes(com.enonic.xp.node.Nodes)

Aggregations

NodePaths (com.enonic.xp.node.NodePaths)5 ContentPaths (com.enonic.xp.content.ContentPaths)2 NodeComparison (com.enonic.xp.node.NodeComparison)2 Test (org.junit.jupiter.api.Test)2 ContentId (com.enonic.xp.content.ContentId)1 NodeComparisons (com.enonic.xp.node.NodeComparisons)1 NodeIds (com.enonic.xp.node.NodeIds)1 Nodes (com.enonic.xp.node.Nodes)1