Move packages + remove circular dependencies
This commit is contained in:
@@ -21,11 +21,7 @@
|
||||
<artifactId>simplenotes-types</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.simplenotes</groupId>
|
||||
<artifactId>simplenotes-domain</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-core</artifactId>
|
||||
|
||||
+5
-5
@@ -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
-3
@@ -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
@@ -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;
|
||||
}
|
||||
-1
@@ -3,7 +3,6 @@ package be.simplenotes.search
|
||||
import be.simplenotes.types.NoteMetadata
|
||||
import be.simplenotes.types.PersistedNote
|
||||
import be.simplenotes.types.PersistedNoteMetadata
|
||||
import be.simplenotes.domain.usecases.search.SearchTerms
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
Reference in New Issue
Block a user