Search in sources :

Example 1 with DelegatingRequest

use of com.b2international.snowowl.core.events.DelegatingRequest in project snow-owl by b2ihealthcare.

the class IdRequest method collectComponentCreateRequests.

private static void collectComponentCreateRequests(Request<?, ?> request, ImmutableMultimap.Builder<ComponentCategory, SnomedComponentCreateRequest> resultBuilder) {
    if (request instanceof DelegatingRequest) {
        collectComponentCreateRequests(((DelegatingRequest<?, ?, ?>) request).next(), resultBuilder);
    } else if (request instanceof TransactionalRequest) {
        collectComponentCreateRequests(((TransactionalRequest) request).getNext(), resultBuilder);
    } else if (request instanceof BaseSnomedComponentCreateRequest) {
        final BaseSnomedComponentCreateRequest createRequest = (BaseSnomedComponentCreateRequest) request;
        for (SnomedCoreComponentCreateRequest nestedRequest : Iterables.filter(createRequest.getNestedRequests(), SnomedCoreComponentCreateRequest.class)) {
            ComponentCategory category = getComponentCategory(nestedRequest);
            resultBuilder.put(category, (BaseSnomedComponentCreateRequest) nestedRequest);
        // XXX: we could recurse here, but only concept creation requests have actual nested requests at the moment
        }
    } else if (request instanceof SnomedRefSetMemberCreateRequest) {
        final SnomedRefSetMemberCreateRequest createRequest = (SnomedRefSetMemberCreateRequest) request;
        final ComponentCategory category = getComponentCategory(createRequest);
        resultBuilder.put(category, createRequest);
    } else if (request instanceof BulkRequest) {
        final BulkRequest<?> bulkRequest = (BulkRequest<?>) request;
        for (Request<?, ?> bulkRequestItem : bulkRequest.getRequests()) {
            collectComponentCreateRequests(bulkRequestItem, resultBuilder);
        }
    }
}
Also used : DelegatingRequest(com.b2international.snowowl.core.events.DelegatingRequest) TransactionalRequest(com.b2international.snowowl.core.request.TransactionalRequest) BulkRequest(com.b2international.snowowl.core.events.bulk.BulkRequest) ComponentCategory(com.b2international.snowowl.core.terminology.ComponentCategory)

Aggregations

DelegatingRequest (com.b2international.snowowl.core.events.DelegatingRequest)1 BulkRequest (com.b2international.snowowl.core.events.bulk.BulkRequest)1 TransactionalRequest (com.b2international.snowowl.core.request.TransactionalRequest)1 ComponentCategory (com.b2international.snowowl.core.terminology.ComponentCategory)1