use of com.b2international.snowowl.core.branch.Branches 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);
}
use of com.b2international.snowowl.core.branch.Branches in project snow-owl by b2ihealthcare.
the class SnomedRf2ExportRequest method collectExportableCodeSystemVersions.
private void collectExportableCodeSystemVersions(final RepositoryContext context, final Set<Version> versionsToExport, final TerminologyResource codeSystem, final String referenceBranch) {
final List<Version> candidateVersions = newArrayList(getCodeSystemVersions(context, codeSystem.getResourceURI()));
if (candidateVersions.isEmpty()) {
return;
}
final Set<String> versionPaths = candidateVersions.stream().map(Version::getBranchPath).collect(Collectors.toSet());
final Branches versionBranches = getBranches(context, versionPaths);
final Map<String, Branch> versionBranchesByPath = Maps.uniqueIndex(versionBranches, Branch::path);
// cutoff timestamp represents the timestamp on the current referenceBranch segments, cutting off any versions created after this timestamp
final Branch cutoffBranch = getBranch(context, referenceBranch);
final String latestVersionParentBranch = candidateVersions.stream().findFirst().map(v -> BranchPathUtils.createPath(v.getBranchPath()).getParentPath()).get();
final long cutoffBaseTimestamp = getCutoffBaseTimestamp(context, cutoffBranch, latestVersionParentBranch);
// Remove all code system versions which were created after the cut-off date, or don't have a corresponding branch
candidateVersions.removeIf(v -> false || !versionBranchesByPath.containsKey(v.getBranchPath()) || versionBranchesByPath.get(v.getBranchPath()).baseTimestamp() > cutoffBaseTimestamp);
versionsToExport.addAll(candidateVersions);
// Exit early if only an extension code system should be exported, or we are already at the "base" code system
final ResourceURI extensionOfUri = codeSystem.getExtensionOf();
if (extensionOnly || extensionOfUri == null) {
return;
}
// Otherwise, collect applicable versions using this code system's working path
final CodeSystem extensionOfCodeSystem = CodeSystemRequests.prepareGetCodeSystem(extensionOfUri.getResourceId()).buildAsync().execute(context);
collectExportableCodeSystemVersions(context, versionsToExport, extensionOfCodeSystem, codeSystem.getBranchPath());
}
Aggregations