use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.
the class ClassificationSaveRequest method execute.
@Override
public String execute(final RepositoryContext context) {
final Request<RepositoryContext, ClassificationTask> classificationRequest = ClassificationRequests.prepareGetClassification(classificationId).build();
final ClassificationTask classification = classificationRequest.execute(context);
final String branchPath = classification.getBranch();
final Request<RepositoryContext, Branch> branchRequest = RepositoryRequests.branching().prepareGet(branchPath).build();
final Branch branch = branchRequest.execute(context);
if (!SAVEABLE_STATUSES.contains(classification.getStatus())) {
throw new BadRequestException("Classification '%s' is not in the expected state to start saving changes.", classificationId);
}
if (classification.getTimestamp() < branch.headTimestamp()) {
throw new BadRequestException("Classification '%s' on branch '%s' is stale (classification timestamp: %s, head timestamp: %s).", classificationId, branchPath, classification.getTimestamp(), branch.headTimestamp());
}
final String user = !Strings.isNullOrEmpty(userId) ? userId : context.service(User.class).getUsername();
final AsyncRequest<?> saveRequest = new SaveJobRequestBuilder().setClassificationId(classificationId).setUserId(user).setParentLockContext(parentLockContext).setCommitComment(commitComment).setModuleId(moduleId).setNamespace(namespace).setAssignerType(assignerType).setFixEquivalences(fixEquivalences).setHandleConcreteDomains(handleConcreteDomains).build(branchPath);
return JobRequests.prepareSchedule().setUser(userId).setRequest(saveRequest).setDescription(String.format("Saving classification changes on %s", branch.path())).buildAsync().get(context, SCHEDULE_TIMEOUT_MILLIS);
}
use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.
the class ClassificationTaskConverter method expandRelationshipChanges.
private void expandRelationshipChanges(final List<ClassificationTask> results, final Set<String> classificationTaskIds) {
if (!expand().containsKey(ClassificationTask.Expand.RELATIONSHIP_CHANGES)) {
return;
}
final Options expandOptions = expand().get(ClassificationTask.Expand.RELATIONSHIP_CHANGES, Options.class);
final RelationshipChangeSearchRequestBuilder builder = ClassificationRequests.prepareSearchRelationshipChange().all().filterByClassificationId(classificationTaskIds);
if (expandOptions.containsKey("sourceId")) {
builder.filterBySourceId(expandOptions.getCollection("sourceId", String.class));
}
final RelationshipChanges relationshipChanges = builder.setExpand(expandOptions.get("expand", Options.class)).setLocales(locales()).build().execute(context());
final ListMultimap<String, RelationshipChange> relationshipChangesByTaskId = Multimaps.index(relationshipChanges, RelationshipChange::getClassificationId);
for (final ClassificationTask classificationTask : results) {
final List<RelationshipChange> taskChanges = relationshipChangesByTaskId.get(classificationTask.getId());
classificationTask.setRelationshipChanges(new RelationshipChanges(taskChanges, null, taskChanges.size(), taskChanges.size()));
}
}
use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.
the class ClassificationTaskConverter method expandEquivalentConceptSets.
private void expandEquivalentConceptSets(final List<ClassificationTask> results, final Set<String> classificationTaskIds) {
if (!expand().containsKey(ClassificationTask.Expand.EQUIVALENT_CONCEPT_SETS)) {
return;
}
final Options expandOptions = expand().get(ClassificationTask.Expand.EQUIVALENT_CONCEPT_SETS, Options.class);
final EquivalentConceptSets equivalentConceptSets = ClassificationRequests.prepareSearchEquivalentConceptSet().filterByClassificationId(classificationTaskIds).all().setExpand(expandOptions.get("expand", Options.class)).setLocales(locales()).build().execute(context());
final ListMultimap<String, EquivalentConceptSet> setsByTaskId = Multimaps.index(equivalentConceptSets, EquivalentConceptSet::getClassificationId);
for (final ClassificationTask classificationTask : results) {
final List<EquivalentConceptSet> taskSets = setsByTaskId.get(classificationTask.getId());
classificationTask.setEquivalentConceptSets(new EquivalentConceptSets(taskSets, null, taskSets.size(), taskSets.size()));
}
}
use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.
the class ClassificationTaskConverter method toResource.
@Override
protected ClassificationTask toResource(final ClassificationTaskDocument entry) {
final ClassificationTask resource = new ClassificationTask();
resource.setId(entry.getId());
resource.setUserId(entry.getUserId());
resource.setReasonerId(entry.getReasonerId());
resource.setBranch(entry.getBranch());
resource.setTimestamp(entry.getTimestamp());
resource.setStatus(entry.getStatus());
resource.setCreationDate(entry.getCreationDate());
resource.setCompletionDate(entry.getCompletionDate());
resource.setSaveDate(entry.getSaveDate());
resource.setInferredRelationshipChangesFound(entry.getHasInferredChanges());
resource.setRedundantStatedRelationshipsFound(entry.getHasRedundantStatedChanges());
resource.setEquivalentConceptsFound(entry.getHasEquivalentConcepts());
return resource;
}
use of com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask in project snow-owl by b2ihealthcare.
the class ClassificationTaskConverter method expandConcreteDomainChanges.
private void expandConcreteDomainChanges(final List<ClassificationTask> results, final Set<String> classificationTaskIds) {
if (!expand().containsKey(ClassificationTask.Expand.CONCRETE_DOMAIN_CHANGES)) {
return;
}
final Options expandOptions = expand().get(ClassificationTask.Expand.CONCRETE_DOMAIN_CHANGES, Options.class);
final ConcreteDomainChanges concreteDomainChanges = ClassificationRequests.prepareSearchConcreteDomainChange().filterByClassificationId(classificationTaskIds).all().setExpand(expandOptions.get("expand", Options.class)).setLocales(locales()).build().execute(context());
final ListMultimap<String, ConcreteDomainChange> concreteDomainChangesByTaskId = Multimaps.index(concreteDomainChanges, ConcreteDomainChange::getClassificationId);
for (final ClassificationTask classificationTask : results) {
final List<ConcreteDomainChange> taskChanges = concreteDomainChangesByTaskId.get(classificationTask.getId());
classificationTask.setConcreteDomainChanges(new ConcreteDomainChanges(taskChanges, null, taskChanges.size(), taskChanges.size()));
}
}
Aggregations