Search in sources :

Example 6 with SnomedRelationship

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()));
            }
        });
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)

Example 7 with SnomedRelationship

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);
                }
            }
        });
    }
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) Set(java.util.Set) SnomedRelationships(com.b2international.snowowl.snomed.core.domain.SnomedRelationships) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) BaseRevisionResourceConverter(com.b2international.snowowl.core.request.BaseRevisionResourceConverter) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) List(java.util.List) ExtendedLocale(com.b2international.commons.http.ExtendedLocale) Options(com.b2international.commons.options.Options) FluentIterable(com.google.common.collect.FluentIterable) BranchContext(com.b2international.snowowl.core.domain.BranchContext) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache) Options(com.b2international.commons.options.Options) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 8 with SnomedRelationship

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()));
            }
        });
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)

Example 9 with SnomedRelationship

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);
}
Also used : SnomedCoreComponent(com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 10 with SnomedRelationship

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);
}
Also used : SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Aggregations

SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)16 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)8 Options (com.b2international.commons.options.Options)6 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)5 SnomedConceptRequestCache (com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)5 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)4 BranchContext (com.b2international.snowowl.core.domain.BranchContext)3 SnomedConcepts (com.b2international.snowowl.snomed.core.domain.SnomedConcepts)3 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)3 Test (org.junit.Test)3 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)2 Json (com.b2international.commons.json.Json)2 ComponentIdentifier (com.b2international.snowowl.core.ComponentIdentifier)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)2 SnomedCoreComponent (com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent)2 SnomedRelationships (com.b2international.snowowl.snomed.core.domain.SnomedRelationships)2 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)2 SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)2 List (java.util.List)2