Skip to content

Commit

Permalink
fix(optimize): ensure that optimize generates ECL expressions...
Browse files Browse the repository at this point in the history
...with FSN labels
  • Loading branch information
cmark committed Sep 21, 2022
1 parent f36bd9e commit d11fd38
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.b2international.snowowl.core.id.IDs;
import com.b2international.snowowl.core.request.QueryOptimizer;
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts;
import com.b2international.snowowl.snomed.core.SnomedDisplayTermType;
import com.b2international.snowowl.snomed.core.domain.SnomedConcept;
import com.b2international.snowowl.snomed.core.domain.SnomedConcepts;
import com.b2international.snowowl.snomed.datastore.request.SnomedRequests;
Expand Down Expand Up @@ -120,7 +121,7 @@ public QueryExpressionDiffs optimize(BranchContext context, Options params) {

SnomedConcept parent = SnomedRequests.prepareGetConcept(parentId)
.setLocales(locales)
.setExpand("pt(),descendants(direct:false,limit:0)")
.setExpand("fsn(),descendants(direct:false,limit:0)")
.build()
.execute(context);

Expand All @@ -134,7 +135,7 @@ public QueryExpressionDiffs optimize(BranchContext context, Options params) {

// The optimization is a "net win" if we can remove at least two clauses from the original
if (remove.size() > 1) {
final QueryExpression replacement = new QueryExpression(IDs.base62UUID(), String.format("<%s%s", parent.getId(), getTerm(parent)), false);
final QueryExpression replacement = new QueryExpression(IDs.base62UUID(), String.format("<%s", Concept.toConceptString(parentId, SnomedDisplayTermType.FSN.getLabel(parent))), false);
final List<QueryExpression> addToInclusion = List.of(replacement);
final List<QueryExpression> addToExclusion = List.of();

Expand All @@ -147,10 +148,6 @@ public QueryExpressionDiffs optimize(BranchContext context, Options params) {
return new QueryExpressionDiffs(diffs.build());
}

private String getTerm(SnomedConcept parent) {
return parent.getPt() != null ? String.format("|%s|", parent.getPt().getTerm()) : "";
}

private boolean isSingleConceptExpression(LoadingCache<String, ExpressionConstraint> eclCache, String query) {
try {
final ExpressionConstraint expressionConstraint = eclCache.getUnchecked(query);
Expand Down

0 comments on commit d11fd38

Please sign in to comment.