From d462f4f7c2832f25a34be1f7fae2d0158fce5e5e Mon Sep 17 00:00:00 2001 From: Darryn McGaw Date: Thu, 11 Apr 2024 12:40:50 +0100 Subject: [PATCH] MAINT-2452 Use current OWL Expression if axiom inactive --- .../data/services/AxiomConversionService.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/snomed/snowstorm/core/data/services/AxiomConversionService.java b/src/main/java/org/snomed/snowstorm/core/data/services/AxiomConversionService.java index 0f322f01b..efb11aa2d 100644 --- a/src/main/java/org/snomed/snowstorm/core/data/services/AxiomConversionService.java +++ b/src/main/java/org/snomed/snowstorm/core/data/services/AxiomConversionService.java @@ -61,11 +61,25 @@ public void populateAxiomMembers(Collection concepts, String branchPath AxiomRelationshipConversionService conversionService = setupConversionService(branchPath); for (Concept concept : concepts) { for (Axiom axiom : concept.getClassAxioms()) { - String owlExpression = conversionService.convertRelationshipsToAxiom(mapFromInternalRelationshipType(concept.getConceptId(), axiom.getDefinitionStatusId(), axiom.getRelationships(), true)); + String owlExpression; + ReferenceSetMember referenceSetMember = getReferenceSetMember(axiom, branchPath); + if (!axiom.isActive() && referenceSetMember != null) { + owlExpression = referenceSetMember.getAdditionalField(ReferenceSetMember.OwlExpressionFields.OWL_EXPRESSION); + } else { + owlExpression = conversionService.convertRelationshipsToAxiom(mapFromInternalRelationshipType(concept.getConceptId(), axiom.getDefinitionStatusId(), axiom.getRelationships(), true)); + } + axiom.setReferenceSetMember(createMember(concept, axiom, owlExpression)); } for (Axiom gciAxiom : concept.getGciAxioms()) { - String owlExpression = conversionService.convertRelationshipsToAxiom(mapFromInternalRelationshipType(concept.getConceptId(), gciAxiom.getDefinitionStatusId(), gciAxiom.getRelationships(), false)); + String owlExpression; + ReferenceSetMember referenceSetMember = getReferenceSetMember(gciAxiom, branchPath); + if (!gciAxiom.isActive() && referenceSetMember != null) { + owlExpression = referenceSetMember.getAdditionalField(ReferenceSetMember.OwlExpressionFields.OWL_EXPRESSION); + } else { + owlExpression = conversionService.convertRelationshipsToAxiom(mapFromInternalRelationshipType(concept.getConceptId(), gciAxiom.getDefinitionStatusId(), gciAxiom.getRelationships(), false)); + } + gciAxiom.setReferenceSetMember(createMember(concept, gciAxiom, owlExpression)); } } @@ -167,4 +181,13 @@ private AxiomRepresentation mapFromInternalRelationshipType(String conceptId, St } return axiomRepresentation; } + + private ReferenceSetMember getReferenceSetMember(Axiom axiom, String branchPath) { + ReferenceSetMember referenceSetMember = axiom.getReferenceSetMember(); + if (referenceSetMember == null && axiom.getId() != null) { + return memberService.findMember(branchPath, axiom.getId()); + } + + return referenceSetMember; + } }