Search in sources :

Example 1 with ValidationDeleteNotification

use of com.b2international.snowowl.core.validation.ValidationDeleteNotification in project snow-owl by b2ihealthcare.

the class ValidationIssueDeleteRequest method execute.

@Override
public Boolean execute(ServiceProvider context) {
    ExpressionBuilder query = Expressions.builder();
    if (!CompareUtils.isEmpty(resourceURIs)) {
        query.filter(Expressions.matchAny(ValidationIssue.Fields.RESOURCE_URI, resourceURIs));
    }
    if (!CompareUtils.isEmpty(toolingIds)) {
        final Set<String> rulesToDelete = ValidationRequests.rules().prepareSearch().all().filterByToolings(toolingIds).build().execute(context).stream().map(ValidationRule::getId).collect(Collectors.toSet());
        query.filter(Expressions.matchAny(ValidationIssue.Fields.RULE_ID, rulesToDelete));
    }
    return context.service(ValidationRepository.class).write(writer -> {
        writer.bulkDelete(new BulkDelete<>(ValidationIssue.class, query.build()));
        writer.commit();
        new ValidationDeleteNotification(resourceURIs, toolingIds).publish(context.service(IEventBus.class));
        return Boolean.TRUE;
    });
}
Also used : ValidationRepository(com.b2international.snowowl.core.internal.validation.ValidationRepository) ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder) ValidationDeleteNotification(com.b2international.snowowl.core.validation.ValidationDeleteNotification) IEventBus(com.b2international.snowowl.eventbus.IEventBus)

Aggregations

ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)1 ValidationRepository (com.b2international.snowowl.core.internal.validation.ValidationRepository)1 ValidationDeleteNotification (com.b2international.snowowl.core.validation.ValidationDeleteNotification)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1