use of com.b2international.snowowl.snomed.datastore.request.SnomedOWLExpressionConverterResult in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberDocumentSerializationTest method indexOWLAxiomMember_GroupedProperties.
@Test
public void indexOWLAxiomMember_GroupedProperties() throws Exception {
final String referencedComponentId = "359728003";
final String owlExpression = "EquivalentClasses(" + ":359728003 " + "ObjectIntersectionOf(:384723003 " + " ObjectSomeValuesFrom(:609096000 " + " ObjectIntersectionOf(" + " ObjectSomeValuesFrom(:260686004 :129304002) " + " ObjectSomeValuesFrom(:405813007 :245269009)" + " )" + " ) " + " ObjectSomeValuesFrom(:609096000 " + " ObjectIntersectionOf(" + " ObjectSomeValuesFrom(:260686004 :129304002) " + " ObjectSomeValuesFrom(:405813007 :81802002)" + " )" + " )" + "))";
final SnomedOWLExpressionConverterResult owlRelationships = toSnomedOWLRelationships(referencedComponentId, owlExpression);
final SnomedRefSetMemberIndexEntry member = createBaseMember().referencedComponentId(referencedComponentId).refsetId(Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).field(Fields.OWL_EXPRESSION, owlExpression).classAxiomRelationships(owlRelationships.getClassAxiomRelationships()).gciAxiomRelationships(owlRelationships.getGciAxiomRelationships()).build();
indexRevision(RevisionBranch.MAIN_PATH, member);
final SnomedRefSetMemberIndexEntry actual = getRevision(RevisionBranch.MAIN_PATH, SnomedRefSetMemberIndexEntry.class, member.getId());
assertEquals(owlExpression, actual.getOwlExpression());
assertEquals(// expected
ImmutableList.of(SnomedOWLRelationshipDocument.create(Concepts.IS_A, "384723003", 0), SnomedOWLRelationshipDocument.create("260686004", "129304002", 1), SnomedOWLRelationshipDocument.create("405813007", "245269009", 1), SnomedOWLRelationshipDocument.create("260686004", "129304002", 2), SnomedOWLRelationshipDocument.create("405813007", "81802002", 2)), // actual
actual.getClassAxiomRelationships());
assertThat(actual.getGciAxiomRelationships()).isEmpty();
assertDocEquals(member, actual);
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedOWLExpressionConverterResult in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberDocumentSerializationTest method createGciAxiomMember.
private SnomedRefSetMemberIndexEntry createGciAxiomMember() {
final String referencedComponentId = "231907006";
final String owlExpression = "" + "SubClassOf(" + " ObjectIntersectionOf(" + " :193783008 " + " ObjectSomeValuesFrom(:609096000 " + " ObjectIntersectionOf(" + " ObjectSomeValuesFrom(:116676008 :23583003) " + " ObjectSomeValuesFrom(:246075003 :19551004) " + " ObjectSomeValuesFrom(:363698007 :65431007) " + " ObjectSomeValuesFrom(:370135005 :441862004)" + " )" + " )" + " )" + " :231907006" + ")";
final SnomedOWLExpressionConverterResult owlRelationships = toSnomedOWLRelationships(referencedComponentId, owlExpression);
return createBaseMember().referencedComponentId(referencedComponentId).refsetId(Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).field(Fields.OWL_EXPRESSION, owlExpression).classAxiomRelationships(owlRelationships.getClassAxiomRelationships()).gciAxiomRelationships(owlRelationships.getGciAxiomRelationships()).build();
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedOWLExpressionConverterResult in project snow-owl by b2ihealthcare.
the class Taxonomies method updateEdge.
private static void updateEdge(SnomedRefSetMemberIndexEntry member, TaxonomyGraph graphToUpdate, SnomedOWLExpressionConverter expressionConverter) {
if (member.isActive()) {
SnomedOWLExpressionConverterResult result = expressionConverter.toSnomedOWLRelationships(member.getReferencedComponentId(), member.getOwlExpression());
if (!CompareUtils.isEmpty(result.getClassAxiomRelationships())) {
/*
* XXX: IS A relationships are expected to have a destination ID, not a value,
* but we do not check this explicitly here -- Long#parseLong will throw a
* NumberFormatException if it encounters a null value.
*/
final long[] destinationIds = result.getClassAxiomRelationships().stream().filter(r -> Concepts.IS_A.equals(r.getTypeId())).map(SnomedOWLRelationshipDocument::getDestinationId).mapToLong(Long::parseLong).toArray();
graphToUpdate.addEdge(member.getId(), Long.parseLong(member.getReferencedComponentId()), destinationIds);
} else {
graphToUpdate.removeEdge(member.getId());
}
} else {
graphToUpdate.removeEdge(member.getId());
}
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedOWLExpressionConverterResult in project snow-owl by b2ihealthcare.
the class SnomedOWLExpressionReferenceSetMemberBuilder method init.
@Override
public void init(final SnomedRefSetMemberIndexEntry.Builder component, final TransactionContext context) {
super.init(component, context);
SnomedOWLExpressionConverterResult result = context.service(SnomedOWLExpressionConverter.class).toSnomedOWLRelationships(getReferencedComponentId(), owlExpression);
component.field(SnomedRf2Headers.FIELD_OWL_EXPRESSION, owlExpression).classAxiomRelationships(result.getClassAxiomRelationships()).gciAxiomRelationships(result.getGciAxiomRelationships());
}
use of com.b2international.snowowl.snomed.datastore.request.SnomedOWLExpressionConverterResult in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberDocumentSerializationTest method indexOWLAxiomMember_MalformedGCIAxiom.
@Test
public void indexOWLAxiomMember_MalformedGCIAxiom() throws Exception {
/*
* According to the OWL Guide (Yong):
* If an axiom is in the form of SubClassOf(C D) and C is a precoordinated concept,
* this SubclassOf axiom is NOT a GCI axiom and the concept D should not be assigned as the referencedComponentId.
*
* This would be a normal SubclassOf axiom and C is the referenced component.
*
*/
final String referencedComponentId = "231907006";
final String owlExpression = "SubClassOf(:193783008 :231907006)";
try {
final SnomedOWLExpressionConverterResult owlRelationships = toSnomedOWLRelationships(referencedComponentId, owlExpression);
final SnomedRefSetMemberIndexEntry member = createBaseMember().referencedComponentId(referencedComponentId).refsetId(Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).field(Fields.OWL_EXPRESSION, owlExpression).classAxiomRelationships(owlRelationships.getClassAxiomRelationships()).gciAxiomRelationships(owlRelationships.getGciAxiomRelationships()).build();
indexRevision(RevisionBranch.MAIN_PATH, member);
final SnomedRefSetMemberIndexEntry actual = getRevision(RevisionBranch.MAIN_PATH, SnomedRefSetMemberIndexEntry.class, member.getId());
assertThat(actual.getGciAxiomRelationships()).isEmpty();
assertThat(actual.getClassAxiomRelationships()).isEmpty();
assertDocEquals(member, actual);
} catch (Exception e) {
// the OWL conversion process must not throw any exception in such cases, but
// rather convert the expression with empty relationship results
fail();
}
}
Aggregations