2020-06-14 20:53:20 +00:00
|
|
|
package docspell.ftsclient
|
|
|
|
|
|
|
|
import docspell.common._
|
|
|
|
|
2020-06-17 19:18:48 +00:00
|
|
|
sealed trait TextData {
|
|
|
|
|
|
|
|
def id: Ident
|
|
|
|
|
|
|
|
def item: Ident
|
|
|
|
|
|
|
|
def collective: Ident
|
|
|
|
|
2020-07-12 11:44:11 +00:00
|
|
|
def folder: Option[Ident]
|
|
|
|
|
2020-06-18 22:43:35 +00:00
|
|
|
final def fold[A](f: TextData.Attachment => A, g: TextData.Item => A): A =
|
|
|
|
this match {
|
|
|
|
case a: TextData.Attachment => f(a)
|
|
|
|
case a: TextData.Item => g(a)
|
|
|
|
}
|
2020-06-17 19:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
object TextData {
|
|
|
|
|
|
|
|
final case class Attachment(
|
|
|
|
item: Ident,
|
|
|
|
attachId: Ident,
|
|
|
|
collective: Ident,
|
2020-07-12 11:44:11 +00:00
|
|
|
folder: Option[Ident],
|
2020-06-20 20:27:26 +00:00
|
|
|
lang: Language,
|
2020-06-17 19:18:48 +00:00
|
|
|
name: Option[String],
|
|
|
|
text: Option[String]
|
|
|
|
) extends TextData {
|
|
|
|
|
|
|
|
val id = item / attachId
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
def attachment(
|
|
|
|
item: Ident,
|
|
|
|
attachId: Ident,
|
|
|
|
collective: Ident,
|
2020-07-12 11:44:11 +00:00
|
|
|
folder: Option[Ident],
|
2020-06-20 20:27:26 +00:00
|
|
|
lang: Language,
|
2020-06-17 19:18:48 +00:00
|
|
|
name: Option[String],
|
|
|
|
text: Option[String]
|
|
|
|
): TextData =
|
2020-07-12 11:44:11 +00:00
|
|
|
Attachment(item, attachId, collective, folder, lang, name, text)
|
2020-06-17 19:18:48 +00:00
|
|
|
|
|
|
|
final case class Item(
|
|
|
|
item: Ident,
|
|
|
|
collective: Ident,
|
2020-07-12 11:44:11 +00:00
|
|
|
folder: Option[Ident],
|
2020-06-17 19:18:48 +00:00
|
|
|
name: Option[String],
|
|
|
|
notes: Option[String]
|
|
|
|
) extends TextData {
|
|
|
|
|
|
|
|
val id = Ident.unsafe("item") / item
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
def item(
|
|
|
|
item: Ident,
|
|
|
|
collective: Ident,
|
2020-07-12 11:44:11 +00:00
|
|
|
folder: Option[Ident],
|
2020-06-17 19:18:48 +00:00
|
|
|
name: Option[String],
|
|
|
|
notes: Option[String]
|
|
|
|
): TextData =
|
2020-07-12 11:44:11 +00:00
|
|
|
Item(item, collective, folder, name, notes)
|
2020-06-17 19:18:48 +00:00
|
|
|
}
|