Move packages + remove circular dependencies

This commit is contained in:
2020-10-23 17:12:38 +02:00
parent ee026ec829
commit 38750a588c
116 changed files with 242 additions and 87 deletions
@@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory
private val logger = LoggerFactory.getLogger("be.simplenotes.search.dsl")
fun IndexSearcher.query(receiver: LuceneDsl.() -> Unit): List<Document> {
internal fun IndexSearcher.query(receiver: LuceneDsl.() -> Unit): List<Document> {
val indexSearcher = this
val builder = BooleanQuery.Builder()
val dsl = LuceneDsl()
@@ -23,7 +23,7 @@ fun IndexSearcher.query(receiver: LuceneDsl.() -> Unit): List<Document> {
return topDocs.scoreDocs.map { indexSearcher.doc(it.doc) }
}
class LuceneDsl {
internal class LuceneDsl {
val clauses = mutableListOf<BooleanExpression>()
var count: Int = 10
@@ -38,10 +38,10 @@ class LuceneDsl {
}
}
fun LuceneDsl.or(booleanExpression: () -> BooleanExpression) {
internal fun LuceneDsl.or(booleanExpression: () -> BooleanExpression) {
addBooleanClause(booleanExpression())
}
infix fun String.eq(query: String?) = BooleanExpression(this, query)
internal infix fun String.eq(query: String?) = BooleanExpression(this, query)
data class BooleanExpression(val term: String, val query: String?)
internal data class BooleanExpression(val term: String, val query: String?)
@@ -1,8 +1,6 @@
package be.simplenotes.search
import be.simplenotes.types.PersistedNote
import be.simplenotes.domain.usecases.search.NoteSearcher
import be.simplenotes.domain.usecases.search.SearchTerms
import be.simplenotes.search.utils.rmdir
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.document.Document
@@ -16,7 +14,7 @@ import java.io.File
import java.nio.file.Path
import java.util.*
class NoteSearcherImpl(basePath: Path = Path.of("/tmp", "lucene")) : NoteSearcher {
internal class NoteSearcherImpl(basePath: Path = Path.of("/tmp", "lucene")) : NoteSearcher {
private val baseFile = basePath.toFile()
private val logger = LoggerFactory.getLogger(javaClass)
@@ -1,6 +1,5 @@
package be.simplenotes.search
import be.simplenotes.domain.usecases.search.NoteSearcher
import org.koin.dsl.module
import java.nio.file.Path
@@ -0,0 +1,17 @@
package be.simplenotes.search
import be.simplenotes.types.PersistedNote
import be.simplenotes.types.PersistedNoteMetadata
import java.util.*
data class SearchTerms(val title: String?, val tag: String?, val content: String?, val all: String?)
interface NoteSearcher {
fun indexNote(userId: Int, note: PersistedNote)
fun indexNotes(userId: Int, notes: List<PersistedNote>)
fun deleteIndex(userId: Int, uuid: UUID)
fun updateIndex(userId: Int, note: PersistedNote)
fun search(userId: Int, terms: SearchTerms): List<PersistedNoteMetadata>
fun dropIndex(userId: Int)
fun dropAll()
}
@@ -0,0 +1,10 @@
module simplenotes.search {
requires kotlin.stdlib;
requires simplenotes.types;
exports be.simplenotes.search to simplenotes.app, simplenotes.domain;
requires lucene;
requires slf4j.api;
requires koin.core;
}