in entity-browser-app/src/main/kotlin/jetbrains/xodus/browser/web/search/SearchTerm.kt [169:198]
override fun search(txn: StoreTransaction, entityType: String, entityTypeId: Int): EntityIterable {
val equalityResult = if (oppositeEntityTypeName == null || oppositeEntityLocalId == null) {
txn.getAll(entityType).minus(txn.findWithLinks(entityType, name))
} else if (txn is PersistentStoreTransaction) {
val oppositeTypeId = txn.store.getEntityTypeId(txn, oppositeEntityTypeName, false)
if (oppositeTypeId < 0) {
EntityIterableBase.EMPTY
} else {
val oppositeEntityId = txn.toEntityId("$oppositeTypeId-$oppositeEntityLocalId")
val oppositeEntity = try {
txn.getEntity(oppositeEntityId)
} catch (ex: EntityRemovedInDatabaseException) {
null
}
if (oppositeEntity == null) {
EntityIterableBase.EMPTY
} else {
txn.findLinks(entityType, oppositeEntity, name)
}
}
} else {
throw RuntimeException("Can't search by a link. The transaction should be persistent")
}
return if (equals) {
equalityResult
} else {
txn.getAll(entityType).minus(equalityResult)
}
}