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