use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SnomedEclEvaluationRequestTest method refinementWithConjunctionAndDisjunction.
@Test
public void refinementWithConjunctionAndDisjunction() throws Exception {
generateDrugHierarchy();
generateTisselKit();
final Expression actual = eval(String.format("<%s:%s=%s OR (%s=%s AND %s=%s)", DRUG_ROOT, HAS_ACTIVE_INGREDIENT, INGREDIENT2, HAS_ACTIVE_INGREDIENT, INGREDIENT4, HAS_ACTIVE_INGREDIENT, INGREDIENT2));
final Expression expected = Expressions.builder().should(and(descendantsOf(DRUG_ROOT), ids(Set.of(TRIPHASIL_TABLET)))).should(and(and(descendantsOf(DRUG_ROOT), ids(Set.of(TISSEL_KIT))), and(descendantsOf(DRUG_ROOT), ids(Set.of(TRIPHASIL_TABLET))))).build();
assertEquals(expected, actual);
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SearchIndexResourceRequest method doExecute.
@Override
protected final B doExecute(C context) throws IOException {
final Searcher searcher = searcher(context);
final Expression where = prepareQuery(context);
// configure additional fields to load when subsetting the response
List<String> fields = fields();
if (!fields().isEmpty()) {
fields = configureFieldsToLoad(fields);
}
final Hits<D> hits = searcher.search(Query.select(getSelect()).from(getFrom()).fields(fields).where(where).searchAfter(searchAfter()).limit(limit()).sortBy(querySortBy(context)).withScores(trackScores()).cached(cacheHits(context)).build());
return toCollectionResource(context, hits);
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class DefaultOperationLockManager method getOrCreateLock.
private IOperationLock getOrCreateLock(DatastoreLockContext context, final DatastoreLockTarget target) {
synchronized (syncObject) {
final String repositoryId = target.getRepositoryId();
final String branchPath = target.getBranchPath();
final Expression searchExpression = Expressions.builder().filter(DatastoreLockIndexEntry.Expressions.repositoryId(repositoryId)).filter(DatastoreLockIndexEntry.Expressions.branchPath(branchPath)).build();
final DatastoreLockIndexEntry existingLockEntry = Iterables.getOnlyElement(search(searchExpression, 2), null);
final IOperationLock lock;
if (existingLockEntry == null) {
lastAssignedId = assignedIds.nextClearBit(lastAssignedId);
final String lockId = Integer.toString(lastAssignedId);
lock = createLock(lastAssignedId, target);
final DatastoreLockIndexEntry newEntry = buildIndexEntry(lockId, branchPath, repositoryId, context);
put(newEntry);
assignedIds.set(lastAssignedId);
/*
* XXX (apeteri): this makes the lock manager revisit low IDs after every 128 issued locks, but
* it can still assign a number over 128 if all of the early ones are in use, since the BitSet grows unbounded.
*/
lastAssignedId = lastAssignedId % EXPECTED_LOCKS;
} else {
lock = new OperationLock(Integer.parseInt(existingLockEntry.getId()), target);
}
lock.acquire(context);
return lock;
}
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SnomedEclEvaluationRequestPropertyFilterTest method preferredIn.
@Test
public void preferredIn() throws Exception {
indexRevision(MAIN, SnomedDescriptionIndexEntry.builder().id(generateDescriptionId()).active(true).moduleId(Concepts.MODULE_SCT_CORE).term("Clinical finding").conceptId(Concepts.ROOT_CONCEPT).typeId(Concepts.TEXT_DEFINITION).preferredIn(Set.of(Concepts.REFSET_LANGUAGE_TYPE_UK)).acceptableIn(Set.of(Concepts.REFSET_LANGUAGE_TYPE_US)).build());
indexRevision(MAIN, SnomedDescriptionIndexEntry.builder().id(generateDescriptionId()).active(true).moduleId(Concepts.MODULE_SCT_CORE).term("Clinical finding").conceptId(Concepts.SUBSTANCE).typeId(Concepts.TEXT_DEFINITION).preferredIn(Set.of(Concepts.REFSET_LANGUAGE_TYPE_US)).acceptableIn(Set.of(Concepts.REFSET_LANGUAGE_TYPE_UK)).build());
final Expression actual = eval("* {{ preferredIn = " + Concepts.REFSET_LANGUAGE_TYPE_UK + " }}");
final Expression expected = SnomedDocument.Expressions.ids(List.of(Concepts.ROOT_CONCEPT));
assertEquals(expected, actual);
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SnomedEclEvaluationRequestPropertyFilterTest method conceptEffectiveTime.
@Test
public void conceptEffectiveTime() throws Exception {
indexRevision(MAIN, SnomedConceptDocument.builder().id(Concepts.FINDING_SITE).active(true).released(true).effectiveTime(EffectiveTimes.getEffectiveTime("20210731", DateFormats.SHORT)).moduleId(Concepts.MODULE_SCT_CORE).build());
indexRevision(MAIN, SnomedConceptDocument.builder().id(Concepts.HAS_ACTIVE_INGREDIENT).active(true).released(true).effectiveTime(EffectiveTimes.getEffectiveTime("20020131", DateFormats.SHORT)).moduleId(Concepts.MODULE_SCT_CORE).build());
Expression expected = SnomedDocument.Expressions.effectiveTime(EffectiveTimes.getEffectiveTime("20210731", DateFormats.SHORT));
Expression actual = eval("* {{ c effectiveTime = \"20210731\" }}");
assertEquals(expected, actual);
}
Aggregations