Search in sources :

Example 51 with NodeId

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

the class GetBranchEntriesMethod method execute.

@Override
public void execute(final Collection<NodeId> nodeIds, final NodeBranchEntries.Builder builder) {
    final GetByIdsRequest getByIdsRequest = new GetByIdsRequest();
    for (final NodeId nodeId : nodeIds) {
        getByIdsRequest.add(GetByIdRequest.create().id(new BranchDocumentId(nodeId, context.getBranch()).toString()).storageSettings(StorageSource.create().storageName(StoreStorageName.from(context.getRepositoryId())).storageType(StaticStorageType.BRANCH).build()).returnFields(returnFields).routing(nodeId.toString()).build());
    }
    final GetResults getResults = this.storageDao.getByIds(getByIdsRequest);
    for (final GetResult getResult : getResults) {
        if (!getResult.isEmpty()) {
            final NodeBranchEntry nodeBranchEntry = NodeBranchVersionFactory.create(getResult.getReturnValues());
            builder.add(nodeBranchEntry);
        }
    }
}
Also used : GetResult(com.enonic.xp.repo.impl.storage.GetResult) NodeId(com.enonic.xp.node.NodeId) GetResults(com.enonic.xp.repo.impl.storage.GetResults) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) GetByIdsRequest(com.enonic.xp.repo.impl.storage.GetByIdsRequest)

Example 52 with NodeId

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

the class BranchStorageRequestFactory method create.

public static StoreRequest create(final NodeBranchEntry nodeBranchEntry, final InternalContext context) {
    final StorageData data = StorageData.create().add(BranchIndexPath.VERSION_ID.getPath(), nodeBranchEntry.getVersionId().toString()).add(BranchIndexPath.NODE_BLOB_KEY.getPath(), nodeBranchEntry.getNodeVersionKey().getNodeBlobKey().toString()).add(BranchIndexPath.INDEX_CONFIG_BLOB_KEY.getPath(), nodeBranchEntry.getNodeVersionKey().getIndexConfigBlobKey().toString()).add(BranchIndexPath.ACCESS_CONTROL_BLOB_KEY.getPath(), nodeBranchEntry.getNodeVersionKey().getAccessControlBlobKey().toString()).add(BranchIndexPath.BRANCH_NAME.getPath(), context.getBranch().getValue()).add(BranchIndexPath.NODE_ID.getPath(), nodeBranchEntry.getNodeId().toString()).add(BranchIndexPath.STATE.getPath(), nodeBranchEntry.getNodeState().value()).add(BranchIndexPath.PATH.getPath(), nodeBranchEntry.getNodePath().toString()).add(BranchIndexPath.TIMESTAMP.getPath(), nodeBranchEntry.getTimestamp() != null ? nodeBranchEntry.getTimestamp() : Instant.now()).build();
    final NodeId nodeId = nodeBranchEntry.getNodeId();
    return StoreRequest.create().id(new BranchDocumentId(nodeId, context.getBranch()).toString()).nodePath(nodeBranchEntry.getNodePath()).settings(StorageSource.create().storageName(StoreStorageName.from(context.getRepositoryId())).storageType(StaticStorageType.BRANCH).build()).data(data).parent(nodeBranchEntry.getVersionId().toString()).routing(nodeId.toString()).build();
}
Also used : NodeId(com.enonic.xp.node.NodeId) StorageData(com.enonic.xp.repo.impl.storage.StorageData)

Example 53 with NodeId

use of com.enonic.xp.node.NodeId 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();
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeComparison(com.enonic.xp.node.NodeComparison) NodeId(com.enonic.xp.node.NodeId) CompareStatus(com.enonic.xp.content.CompareStatus) NodeComparisons(com.enonic.xp.node.NodeComparisons) HashSet(java.util.HashSet)

Example 54 with NodeId

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

the class FindNodesDependenciesCommand method resolveDependencies.

private NodeIds resolveDependencies(final NodeIds nodeIds) {
    Set<NodeId> nonProcessedNodes = nodeIds.getSet().stream().filter((nodeId) -> !processed.contains(nodeId)).collect(Collectors.toSet());
    if (nonProcessedNodes.isEmpty()) {
        return NodeIds.empty();
    }
    final SearchResult result = getReferences(nonProcessedNodes);
    this.processed.addAll(nonProcessedNodes);
    final NodeIds.Builder builder = NodeIds.create();
    if (result.isEmpty()) {
        return NodeIds.empty();
    }
    addNodeIdsFromReferenceReturnValues(result, builder);
    if (this.recursive) {
        NodeIds currentLevelDependencies = builder.build();
        if (recursionFilter != null) {
            currentLevelDependencies = recursionFilter.apply(currentLevelDependencies);
        }
        builder.addAll(resolveDependencies(currentLevelDependencies));
    }
    return builder.build();
}
Also used : IdFilter(com.enonic.xp.query.filter.IdFilter) ReturnFields(com.enonic.xp.repo.impl.ReturnFields) ReturnValue(com.enonic.xp.repo.impl.ReturnValue) NodeIndexPath(com.enonic.xp.node.NodeIndexPath) ExistsFilter(com.enonic.xp.query.filter.ExistsFilter) Set(java.util.Set) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) SingleRepoSearchSource(com.enonic.xp.repo.impl.SingleRepoSearchSource) NodeId(com.enonic.xp.node.NodeId) HashSet(java.util.HashSet) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult) ContextAccessor(com.enonic.xp.context.ContextAccessor) SearchHit(com.enonic.xp.repo.impl.search.result.SearchHit) NodeQuery(com.enonic.xp.node.NodeQuery) NodeIds(com.enonic.xp.node.NodeIds) NodeIds(com.enonic.xp.node.NodeIds) NodeId(com.enonic.xp.node.NodeId) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult)

Example 55 with NodeId

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

the class NodeServiceImpl method reorderChildren.

@Override
public ReorderChildNodesResult reorderChildren(final ReorderChildNodesParams params) {
    verifyContext();
    final ReorderChildNodesResult reorderChildNodesResult = ReorderChildNodesCommand.create().params(params).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).build().execute();
    for (Node parentNode : reorderChildNodesResult.getParentNodes()) {
        this.eventPublisher.publish(NodeEvents.sorted(parentNode));
    }
    refresh(RefreshMode.SEARCH);
    for (NodeId nodeId : reorderChildNodesResult.getNodeIds()) {
        this.eventPublisher.publish(NodeEvents.manualOrderUpdated(getById(nodeId)));
    }
    return reorderChildNodesResult;
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) ReorderChildNodesResult(com.enonic.xp.node.ReorderChildNodesResult)

Aggregations

NodeId (com.enonic.xp.node.NodeId)91 Node (com.enonic.xp.node.Node)44 Test (org.junit.jupiter.api.Test)36 NodePath (com.enonic.xp.node.NodePath)23 InternalContext (com.enonic.xp.repo.impl.InternalContext)18 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)15 NodeIds (com.enonic.xp.node.NodeIds)14 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)11 Context (com.enonic.xp.context.Context)10 PropertyTree (com.enonic.xp.data.PropertyTree)10 Branch (com.enonic.xp.branch.Branch)9 ContextAccessor (com.enonic.xp.context.ContextAccessor)9 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)9 NodeVersionId (com.enonic.xp.node.NodeVersionId)9 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)8 RefreshMode (com.enonic.xp.node.RefreshMode)8 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)8 ContextBuilder (com.enonic.xp.context.ContextBuilder)6 Event (com.enonic.xp.event.Event)6 RenameNodeParams (com.enonic.xp.node.RenameNodeParams)6