Source:
<code>private void convertDescriptions(TransactionContext context, final String conceptId) { <START> TransactionContext newContext = context.inject().bind(Synonyms.class, new Synonyms(context)).build(); <END> final Set<String> requiredDescriptionTypes = newHashSet(Concepts.FULLY_SPECIFIED_NAME, Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_PREFERRED); final Multiset<String> preferredLanguageRefSetIds = HashMultiset.create(); final Set<String> synonymAndDescendantIds = newContext.service(Synonyms.class).get(); for (final SnomedDescriptionCreateRequest descriptionRequest : descriptions) { descriptionRequest.setConceptId(conceptId); if (null == descriptionRequest.getModuleId()) { descriptionRequest.setModuleId(getModuleId()); } descriptionRequest.execute(context); final String typeId = descriptionRequest.getTypeId(); if (synonymAndDescendantIds.contains(typeId)) { for (final Entry<String, Acceptability> acceptability : descriptionRequest.getAcceptability().entrySet()) { if (Acceptability.PREFERRED.equals(acceptability.getValue())) { preferredLanguageRefSetIds.add(acceptability.getKey()); requiredDescriptionTypes.remove(Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_PREFERRED); } } } requiredDescriptionTypes.remove(typeId); } if (!requiredDescriptionTypes.isEmpty()) { throw new BadRequestException("At least one fully specified name and one preferred term must be supplied with the concept."); } for (final com.google.common.collect.Multiset.Entry<String> languageRefSetIdOccurence : preferredLanguageRefSetIds.entrySet()) { if (languageRefSetIdOccurence.getCount() > 1) { throw new BadRequestException("More than one preferred term has been added for language reference set %s.", languageRefSetIdOccurence.getElement()); } } }</code><technical_language>Domain-specific requests alter incoming context, services provided them. SnomedConceptCreateRequest instances executed a com.b2international.snowowl.snomed.datastore.request.SnomedBulkRequest<R>, binds Synonyms service context. Executing SnomedConceptCreateRequest instances of SnomedBulkRequest is allowed, in cases, context able provide Synonyms cache/service, meaning creator of context inject necessary services passing requests</technical_language>

Target:
private void convertDescriptions(TransactionContext context, final String conceptId) { final Set<String> requiredDescriptionTypes = newHashSet(Concepts.FULLY_SPECIFIED_NAME, Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_PREFERRED); final Multiset<String> preferredLanguageRefSetIds = HashMultiset.create(); final Set<String> synonymAndDescendantIds = context.service(Synonyms.class).get(); for (final SnomedDescriptionCreateRequest descriptionRequest : descriptions) { descriptionRequest.setConceptId(conceptId); if (null == descriptionRequest.getModuleId()) { descriptionRequest.setModuleId(getModuleId()); } descriptionRequest.execute(context); final String typeId = descriptionRequest.getTypeId(); if (synonymAndDescendantIds.contains(typeId)) { for (final Entry<String, Acceptability> acceptability : descriptionRequest.getAcceptability().entrySet()) { if (Acceptability.PREFERRED.equals(acceptability.getValue())) { preferredLanguageRefSetIds.add(acceptability.getKey()); requiredDescriptionTypes.remove(Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_PREFERRED); } } } requiredDescriptionTypes.remove(typeId); } if (!requiredDescriptionTypes.isEmpty()) { throw new BadRequestException("At least one fully specified name and one preferred term must be supplied with the concept."); } for (final com.google.common.collect.Multiset.Entry<String> languageRefSetIdOccurence : preferredLanguageRefSetIds.entrySet()) { if (languageRefSetIdOccurence.getCount() > 1) { throw new BadRequestException("More than one preferred term has been added for language reference set %s.", languageRefSetIdOccurence.getElement()); } } }