use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSets in project snow-owl by b2ihealthcare.
the class SnomedRf2ExportRequest method getIdentifierConcepts.
private List<SnomedConcept> getIdentifierConcepts(final RepositoryContext context, final String currentVersion) {
final Collection<String> refSetsToLoad;
if (refSets == null) {
// Retrieve all reference sets if refSets is null
final Request<BranchContext, SnomedReferenceSets> refSetRequest = SnomedRequests.prepareSearchRefSet().all().build();
final SnomedReferenceSets allReferenceSets = execute(context, currentVersion, refSetRequest);
refSetsToLoad = allReferenceSets.stream().map(r -> r.getId()).collect(Collectors.toSet());
} else {
refSetsToLoad = refSets;
}
final SnomedConceptSearchRequestBuilder refSetRequestBuilder = SnomedRequests.prepareSearchConcept().all().filterByIds(refSetsToLoad).setExpand("pt(),referenceSet()").setLocales(locales());
final Request<BranchContext, SnomedConcepts> request = refSetRequestBuilder.build();
final SnomedConcepts referenceSets = execute(context, currentVersion, request);
// Return only the identifier concepts which have an existing reference set on this branch
return referenceSets.stream().filter(c -> c.getReferenceSet() != null).collect(Collectors.toList());
}
use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSets in project snow-owl by b2ihealthcare.
the class SnomedRf2ImportRequest method updateCodeSystemSettings.
private void updateCodeSystemSettings(final BranchContext context, final ResourceURI codeSystemUri) throws Exception {
SnomedReferenceSets languageReferenceSets = SnomedRequests.prepareSearchRefSet().all().filterByType(SnomedRefSetType.LANGUAGE).filterByActive(true).setFields(SnomedConceptDocument.Fields.ID).sortBy(Sort.fieldAsc(SnomedConceptDocument.Fields.ID)).build().execute(context);
/*
* XXX: The default language in locales is always "en", as there is no
* machine-readable information about what language code each language type
* reference set is associated with.
*/
final List<ExtendedLocale> locales = languageReferenceSets.stream().map(refSet -> new ExtendedLocale("en", "", refSet.getId())).collect(Collectors.toList());
// fetch codesystem again to get the latest settings
CodeSystem currentSnomedCodeSystem = CodeSystemRequests.prepareGetCodeSystem(codeSystemUri.getResourceId()).buildAsync().get(context);
Map<String, SnomedLanguageConfig> mergedLanguagesConfiguration = Maps.newLinkedHashMap();
SnomedDescriptionUtils.getLanguagesConfiguration(context.service(ObjectMapper.class), currentSnomedCodeSystem).forEach(config -> {
mergedLanguagesConfiguration.put(config.getLanguageTag(), config);
});
languageReferenceSets.stream().map(SnomedReferenceSet::getId).filter(SnomedTerminologyComponentConstants.LANG_REFSET_DIALECT_ALIASES::containsKey).forEach(langRefsetId -> {
final String dialect = SnomedTerminologyComponentConstants.LANG_REFSET_DIALECT_ALIASES.get(langRefsetId);
// ignore any aliases that are already defined by using computeIfAbsent
mergedLanguagesConfiguration.computeIfAbsent(dialect, languageTag -> new SnomedLanguageConfig(languageTag, langRefsetId));
});
CodeSystemRequests.prepareUpdateCodeSystem(codeSystemUri.getResourceId()).setSettings(Map.of(CodeSystem.CommonSettings.LOCALES, locales, SnomedTerminologyComponentConstants.CODESYSTEM_LANGUAGE_CONFIG_KEY, mergedLanguagesConfiguration.values())).build(context.service(User.class).getUsername(), String.format("Update '%s' settings based on RF2 import", codeSystemUri.getResourceId())).execute(context.service(IEventBus.class)).getSync(2, TimeUnit.MINUTES);
}
Aggregations