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