use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry.Expressions in project snow-owl by b2ihealthcare.
the class SnomedEclRefinementEvaluator method evalRefinement.
/**
* Evaluates an {@link AttributeConstraint} refinement on the given focusConceptId set on the given {@link BranchContext}.
* Grouped parameter can
*/
private Promise<Collection<Property>> evalRefinement(final BranchContext context, final AttributeConstraint refinement, final boolean grouped, final Set<String> focusConceptIds) {
final Comparison comparison = refinement.getComparison();
final Collection<String> typeConceptFilter = evalToConceptIds(context, refinement.getAttribute(), expressionForm).getSync(1, TimeUnit.MINUTES);
if (comparison instanceof AttributeComparison) {
// resolve non-* focusConcept ECLs to IDs, so we can filter relationships by source/destination
// filterByType and filterByDestination accepts ECL expressions as well, so serialize them into ECL and pass as String when required
// if reversed refinement, then we are interested in the destinationIds otherwise we need the sourceIds
final Collection<String> destinationConceptFilter = evalToConceptIds(context, ((AttributeComparison) comparison).getValue(), expressionForm).getSync(1, TimeUnit.MINUTES);
final Collection<String> focusConceptFilter = refinement.isReversed() ? destinationConceptFilter : focusConceptIds;
final Collection<String> valueConceptFilter = refinement.isReversed() ? focusConceptIds : destinationConceptFilter;
return evalStatements(context, focusConceptFilter, typeConceptFilter, valueConceptFilter, grouped, expressionForm);
} else if (comparison instanceof DataTypeComparison) {
if (refinement.isReversed()) {
throw new BadRequestException("Reversed flag is not supported in data type based comparison (string/numeric)");
} else {
final Promise<Collection<Property>> statementsWithValue = evalStatementsWithValue(context, focusConceptIds, typeConceptFilter, (DataTypeComparison) comparison);
final Promise<Collection<Property>> members = evalMembers(context, focusConceptIds, typeConceptFilter, (DataTypeComparison) comparison);
return Promise.all(statementsWithValue, members).then(results -> {
final Collection<Property> s = (Collection<Property>) results.get(0);
final Collection<Property> m = (Collection<Property>) results.get(1);
return FluentIterable.concat(s, m).toSet();
});
}
} else {
return SnomedEclEvaluationRequest.throwUnsupported(comparison);
}
}
Aggregations