Search in sources :

Example 6 with ClassificationTask

use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.

the class ClassificationTaskConverter method expand.

@Override
public void expand(final List<ClassificationTask> results) {
    final Multimap<String, ClassificationTask> tasksByBranch = Multimaps.index(results, ClassificationTask::getBranch);
    final Branches branches = RepositoryRequests.branching().prepareSearch().setLimit(tasksByBranch.keySet().size()).filterByIds(tasksByBranch.keySet()).build().execute(context());
    final Map<String, Long> headTimestamps = branches.stream().collect(Collectors.toMap(Branch::path, Branch::headTimestamp));
    // Overwrite stored status if the branch has moved forward in the meantime, except if the task is saved
    for (final ClassificationTask task : results) {
        if (SAVE_AND_SCHEDULED_STATUSES.contains(task.getStatus())) {
            continue;
        }
        if (task.getTimestamp() < headTimestamps.get(task.getBranch())) {
            task.setStatus(ClassificationStatus.STALE);
        }
    }
    if (expand().isEmpty()) {
        return;
    }
    final Set<String> classificationTaskIds = results.stream().map(ClassificationTask::getId).collect(Collectors.toSet());
    expandEquivalentConceptSets(results, classificationTaskIds);
    expandRelationshipChanges(results, classificationTaskIds);
    expandConcreteDomainChanges(results, classificationTaskIds);
}
Also used : ClassificationTask(com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask) Branches(com.b2international.snowowl.core.branch.Branches)

Example 7 with ClassificationTask

use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.

the class EquivalencyChecker method processResults.

@Override
protected LongKeyLongMap processResults(final String classificationId) {
    final Set<String> conceptIdsToCheck = additionalConcepts.stream().map(SnomedConcept::getId).collect(Collectors.toSet());
    final LongKeyLongMap equivalentConceptMap = PrimitiveMaps.newLongKeyLongOpenHashMap();
    final ClassificationTask classificationTask = ClassificationRequests.prepareGetClassification(classificationId).setExpand("equivalentConceptSets()").build(repositoryId).execute(getEventBus()).getSync();
    if (!ClassificationStatus.COMPLETED.equals(classificationTask.getStatus())) {
        throw new ReasonerApiException("Selected reasoner could not start or failed to finish its job.");
    }
    if (!classificationTask.getEquivalentConceptsFound()) {
        return equivalentConceptMap;
    }
    final EquivalentConceptSets equivalentConceptSets = classificationTask.getEquivalentConceptSets();
    registerEquivalentConcepts(equivalentConceptSets, conceptIdsToCheck, equivalentConceptMap);
    return equivalentConceptMap;
}
Also used : ClassificationTask(com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask) EquivalentConceptSets(com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSets) LongKeyLongMap(com.b2international.collections.longs.LongKeyLongMap) ReasonerApiException(com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException)

Aggregations

ClassificationTask (com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask)7 Options (com.b2international.commons.options.Options)3 EquivalentConceptSets (com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSets)2 LongKeyLongMap (com.b2international.collections.longs.LongKeyLongMap)1 BadRequestException (com.b2international.commons.exceptions.BadRequestException)1 Branch (com.b2international.snowowl.core.branch.Branch)1 Branches (com.b2international.snowowl.core.branch.Branches)1 RepositoryContext (com.b2international.snowowl.core.domain.RepositoryContext)1 ConcreteDomainChange (com.b2international.snowowl.snomed.reasoner.domain.ConcreteDomainChange)1 ConcreteDomainChanges (com.b2international.snowowl.snomed.reasoner.domain.ConcreteDomainChanges)1 EquivalentConceptSet (com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSet)1 RelationshipChange (com.b2international.snowowl.snomed.reasoner.domain.RelationshipChange)1 RelationshipChanges (com.b2international.snowowl.snomed.reasoner.domain.RelationshipChanges)1 ReasonerApiException (com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException)1 RelationshipChangeSearchRequestBuilder (com.b2international.snowowl.snomed.reasoner.request.RelationshipChangeSearchRequestBuilder)1