Search in sources :

Example 1 with Merges

use of com.b2international.snowowl.core.merge.Merges in project snow-owl by b2ihealthcare.

the class SearchMergeRequest method doExecute.

@Override
public Merges doExecute(RepositoryContext context) {
    final ExpressionBuilder queryBuilder = Expressions.builder();
    // add mergerequest type filter
    queryBuilder.filter(RemoteJobEntry.Expressions.matchRequestType(ImmutableSet.of(BranchRebaseRequest.class.getSimpleName(), BranchMergeRequest.class.getSimpleName())));
    if (containsKey(OptionKey.SOURCE)) {
        queryBuilder.filter(RemoteJobEntry.Expressions.matchParameter(SOURCE_FIELD, getCollection(OptionKey.SOURCE, String.class)));
    }
    if (containsKey(OptionKey.TARGET)) {
        queryBuilder.filter(RemoteJobEntry.Expressions.matchParameter(TARGET_FIELD, getCollection(OptionKey.TARGET, String.class)));
    }
    if (containsKey(OptionKey.STATUS)) {
        queryBuilder.filter(RemoteJobEntry.Expressions.matchParameter(STATUS_FIELD, getCollection(OptionKey.STATUS, String.class)));
    }
    final RemoteJobs jobs = context.service(RemoteJobTracker.class).search(queryBuilder.build(), Integer.MAX_VALUE);
    final ObjectMapper mapper = context.service(ObjectMapper.class);
    final List<Merge> items = jobs.stream().map(job -> createMergefromJobEntry(job, mapper)).collect(Collectors.toList());
    return new Merges(items, jobs.getSearchAfter(), jobs.getLimit(), jobs.getTotal());
}
Also used : RepositoryContext(com.b2international.snowowl.core.domain.RepositoryContext) ImmutableSet(com.google.common.collect.ImmutableSet) Status(com.b2international.snowowl.core.merge.Merge.Status) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Merge(com.b2international.snowowl.core.merge.Merge) RemoteJobEntry(com.b2international.snowowl.core.jobs.RemoteJobEntry) Collectors(java.util.stream.Collectors) SearchResourceRequest(com.b2international.snowowl.core.request.SearchResourceRequest) List(java.util.List) Merges(com.b2international.snowowl.core.merge.Merges) Expressions(com.b2international.index.query.Expressions) AccessControl(com.b2international.snowowl.core.authorization.AccessControl) Map(java.util.Map) ApiError(com.b2international.commons.exceptions.ApiError) RemoteJobs(com.b2international.snowowl.core.jobs.RemoteJobs) ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder) Permission(com.b2international.snowowl.core.identity.Permission) Builder(com.b2international.snowowl.core.merge.Merge.Builder) NotImplementedException(com.b2international.commons.exceptions.NotImplementedException) RemoteJobTracker(com.b2international.snowowl.core.jobs.RemoteJobTracker) RemoteJobs(com.b2international.snowowl.core.jobs.RemoteJobs) Merges(com.b2international.snowowl.core.merge.Merges) RemoteJobTracker(com.b2international.snowowl.core.jobs.RemoteJobTracker) Merge(com.b2international.snowowl.core.merge.Merge) ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ApiError (com.b2international.commons.exceptions.ApiError)1 NotImplementedException (com.b2international.commons.exceptions.NotImplementedException)1 Expressions (com.b2international.index.query.Expressions)1 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)1 AccessControl (com.b2international.snowowl.core.authorization.AccessControl)1 RepositoryContext (com.b2international.snowowl.core.domain.RepositoryContext)1 Permission (com.b2international.snowowl.core.identity.Permission)1 RemoteJobEntry (com.b2international.snowowl.core.jobs.RemoteJobEntry)1 RemoteJobTracker (com.b2international.snowowl.core.jobs.RemoteJobTracker)1 RemoteJobs (com.b2international.snowowl.core.jobs.RemoteJobs)1 Merge (com.b2international.snowowl.core.merge.Merge)1 Builder (com.b2international.snowowl.core.merge.Merge.Builder)1 Status (com.b2international.snowowl.core.merge.Merge.Status)1 Merges (com.b2international.snowowl.core.merge.Merges)1 SearchResourceRequest (com.b2international.snowowl.core.request.SearchResourceRequest)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1