use of com.b2international.snowowl.snomed.core.domain.SnomedRelationship in project snow-owl by b2ihealthcare.
the class SnomedRelationshipConverter method expandModifier.
private void expandModifier(List<SnomedRelationship> results) {
if (expand().containsKey(SnomedRelationship.Expand.MODIFIER)) {
final Options modifierOptions = expand().get(SnomedRelationship.Expand.MODIFIER, Options.class);
final Iterable<String> modifierIds = FluentIterable.from(results).transform(SnomedRelationship::getModifierId);
context().service(SnomedConceptRequestCache.class).request(modifierIds, modifierOptions.getOptions("expand"), locales(), modifiersById -> {
for (SnomedRelationship relationship : results) {
((SnomedRelationship) relationship).setModifier(modifiersById.get(relationship.getModifierId()));
}
});
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedRelationship in project snow-owl by b2ihealthcare.
the class SnomedRelationshipConverter method expandDestination.
private void expandDestination(List<SnomedRelationship> results) {
if (expand().containsKey(SnomedRelationship.Expand.DESTINATION)) {
final Options destinationOptions = expand().get(SnomedRelationship.Expand.DESTINATION, Options.class);
final Iterable<String> destinationConceptIds = FluentIterable.from(results).filter(// skip expand on relationships with value
r -> !r.hasValue()).transform(SnomedRelationship::getDestinationId);
context().service(SnomedConceptRequestCache.class).request(destinationConceptIds, destinationOptions.getOptions("expand"), locales(), destinationConceptsById -> {
for (SnomedRelationship relationship : results) {
final String destinationId = relationship.getDestinationId();
// containsKey handles any null values here
if (destinationConceptsById.containsKey(destinationId)) {
final SnomedConcept destinationConcept = destinationConceptsById.get(destinationId);
((SnomedRelationship) relationship).setDestination(destinationConcept);
}
}
});
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedRelationship in project snow-owl by b2ihealthcare.
the class SnomedRelationshipConverter method expandCharacteristicType.
private void expandCharacteristicType(List<SnomedRelationship> results) {
if (expand().containsKey(SnomedRelationship.Expand.CHARACTERISTIC_TYPE)) {
final Options characteristicTypeOptions = expand().get(SnomedRelationship.Expand.CHARACTERISTIC_TYPE, Options.class);
final Iterable<String> characteristicTypeConceptIds = FluentIterable.from(results).transform(SnomedRelationship::getCharacteristicTypeId);
context().service(SnomedConceptRequestCache.class).request(characteristicTypeConceptIds, characteristicTypeOptions.getOptions("expand"), locales(), characteristicTypesById -> {
for (SnomedRelationship relationship : results) {
((SnomedRelationship) relationship).setCharacteristicType(characteristicTypesById.get(relationship.getCharacteristicTypeId()));
}
});
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedRelationship in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetMemberConverter method setReferencedComponent.
private void setReferencedComponent(SnomedReferenceSetMember member, String referencedComponentId, String referencedComponentType) {
// XXX: partial field loading support
if (referencedComponentType == null || referencedComponentId == null)
return;
final SnomedCoreComponent component;
switch(referencedComponentType) {
// TODO support query type refset refcomp expansion, currently it's a concept
case SnomedConcept.REFSET_TYPE:
case SnomedConcept.TYPE:
component = new SnomedConcept();
((SnomedConcept) component).setId(referencedComponentId);
break;
case SnomedDescription.TYPE:
component = new SnomedDescription();
((SnomedDescription) component).setId(referencedComponentId);
break;
case SnomedRelationship.TYPE:
component = new SnomedRelationship();
((SnomedRelationship) component).setId(referencedComponentId);
break;
default:
throw new UnsupportedOperationException("UnsupportedReferencedComponentType: " + referencedComponentType);
}
member.setReferencedComponent(component);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedRelationship in project snow-owl by b2ihealthcare.
the class SnomedRelationshipApiTest method updateRelationshipWithSamePropertiesShouldNotCauseAnyChange.
@Test
public void updateRelationshipWithSamePropertiesShouldNotCauseAnyChange() throws Exception {
final String relationshipId = createNewRelationship(branchPath);
final SnomedRelationship relationship = getRelationship(relationshipId);
// explicitly create a new Boolean object with same value to simulate deserialization "bug"
relationship.setActive(new Boolean(true));
Boolean updated = SnomedRequests.prepareCommit().setCommitComment("Update relationship").setBody(relationship.toUpdateRequest()).build(branchPath.getPath()).execute(getBus()).getSync(1, TimeUnit.MINUTES).getResultAs(Boolean.class);
assertFalse(updated);
}
Aggregations