Search in sources :

Example 1 with GetByIdRequest

use of com.enonic.xp.repo.impl.storage.GetByIdRequest in project xp by enonic.

the class BranchServiceImpl method doGetById.

private NodeBranchEntry doGetById(final NodeId nodeId, final InternalContext context) {
    final GetByIdRequest getByIdRequest = createGetByIdRequest(nodeId, context);
    final GetResult getResult = this.storageDao.getById(getByIdRequest);
    if (getResult.isEmpty()) {
        return null;
    }
    return NodeBranchVersionFactory.create(getResult.getReturnValues());
}
Also used : GetResult(com.enonic.xp.repo.impl.storage.GetResult) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest)

Example 2 with GetByIdRequest

use of com.enonic.xp.repo.impl.storage.GetByIdRequest 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);
}
Also used : MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest) GetResults(com.enonic.xp.repo.impl.storage.GetResults) StorageSource(com.enonic.xp.repo.impl.StorageSource) MultiGetRequest(org.elasticsearch.action.get.MultiGetRequest)

Example 3 with GetByIdRequest

use of com.enonic.xp.repo.impl.storage.GetByIdRequest in project xp by enonic.

the class VersionServiceImpl method doGetById.

private NodeVersionMetadata doGetById(final NodeId nodeId, final NodeVersionId nodeVersionId, final InternalContext context) {
    final GetByIdRequest getByIdRequest = GetByIdRequest.create().id(nodeVersionId.toString()).returnFields(VERSION_RETURN_FIELDS).storageSettings(createStorageSettings(context)).build();
    final GetResult getResult = this.storageDao.getById(getByIdRequest);
    if (getResult.isEmpty()) {
        return null;
    }
    return NodeVersionFactory.create(getResult);
}
Also used : GetResult(com.enonic.xp.repo.impl.storage.GetResult) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest)

Example 4 with GetByIdRequest

use of com.enonic.xp.repo.impl.storage.GetByIdRequest in project xp by enonic.

the class CommitServiceImpl method get.

@Override
public NodeCommitEntry get(final NodeCommitId nodeCommitId, final InternalContext context) {
    final GetByIdRequest getByIdRequest = createGetByIdRequest(nodeCommitId, context);
    final GetResult getResult = this.storageDao.getById(getByIdRequest);
    if (getResult.isEmpty()) {
        return null;
    }
    return NodeCommitEntryFactory.create(getResult.getReturnValues());
}
Also used : GetResult(com.enonic.xp.repo.impl.storage.GetResult) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest)

Aggregations

GetByIdRequest (com.enonic.xp.repo.impl.storage.GetByIdRequest)4 GetResult (com.enonic.xp.repo.impl.storage.GetResult)3 StorageSource (com.enonic.xp.repo.impl.StorageSource)1 GetResults (com.enonic.xp.repo.impl.storage.GetResults)1 MultiGetRequest (org.elasticsearch.action.get.MultiGetRequest)1 MultiGetRequestBuilder (org.elasticsearch.action.get.MultiGetRequestBuilder)1 MultiGetResponse (org.elasticsearch.action.get.MultiGetResponse)1