use of com.enonic.xp.repo.impl.storage.GetResults in project xp by enonic.
the class StorageDaoImpl method getByIds.
@Override
public GetResults getByIds(final GetByIdsRequest requests) {
if (requests.getRequests().isEmpty()) {
return new GetResults();
}
final MultiGetRequestBuilder multiGetRequestBuilder = new MultiGetRequestBuilder(this.client, MultiGetAction.INSTANCE).setPreference(SearchPreference.LOCAL.getName());
for (final GetByIdRequest request : requests.getRequests()) {
final StorageSource storageSource = request.getStorageSource();
final MultiGetRequest.Item item = new MultiGetRequest.Item(storageSource.getStorageName().getName(), storageSource.getStorageType().getName(), request.getId());
if (request.getReturnFields().isNotEmpty()) {
item.fields(request.getReturnFields().getReturnFieldNames());
}
if (request.getRouting() != null) {
item.routing(request.getRouting());
}
multiGetRequestBuilder.add(item);
}
final MultiGetResponse multiGetItemResponses = this.client.multiGet(multiGetRequestBuilder.request()).actionGet();
return GetResultsFactory.create(multiGetItemResponses);
}
use of com.enonic.xp.repo.impl.storage.GetResults 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.repo.impl.storage.GetResults in project xp by enonic.
the class GetResultsFactory method create.
public static GetResults create(final MultiGetResponse getResponse) {
final MultiGetItemResponse[] responses = getResponse.getResponses();
final GetResults getResults = new GetResults();
for (final MultiGetItemResponse response : responses) {
getResults.add(GetResultFactory.create(response.getResponse()));
}
return getResults;
}
Aggregations