mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
First sketch for custom data threaded through item processing
Refs: #2334
This commit is contained in:
@ -15,10 +15,10 @@ import docspell.common.ProcessItemArgs.ProcessMeta
|
||||
import docspell.common.{CollectiveId, Ident, Language}
|
||||
import docspell.logging.Logger
|
||||
|
||||
import io.circe.Codec
|
||||
import io.circe.generic.extras.Configuration
|
||||
import io.circe.generic.extras.semiauto.deriveConfiguredCodec
|
||||
import io.circe.generic.semiauto.deriveCodec
|
||||
import io.circe.{Codec, Json}
|
||||
|
||||
case class NewFile(metadata: Meta = Meta.empty, file: String) {
|
||||
|
||||
@ -41,7 +41,8 @@ object NewFile {
|
||||
case class Meta(
|
||||
language: Option[Language],
|
||||
skipDuplicate: Option[Boolean],
|
||||
attachmentsOnly: Option[Boolean]
|
||||
attachmentsOnly: Option[Boolean],
|
||||
customData: Option[Json]
|
||||
) {
|
||||
|
||||
def toProcessMeta(
|
||||
@ -62,12 +63,13 @@ object NewFile {
|
||||
fileFilter = None,
|
||||
tags = None,
|
||||
reprocess = false,
|
||||
attachmentsOnly = attachmentsOnly
|
||||
attachmentsOnly = attachmentsOnly,
|
||||
customData = customData
|
||||
)
|
||||
}
|
||||
|
||||
object Meta {
|
||||
val empty = Meta(None, None, None)
|
||||
val empty = Meta(None, None, None, None)
|
||||
implicit val jsonCodec: Codec[Meta] = deriveCodec
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import docspell.common._
|
||||
import docspell.logging.Logger
|
||||
|
||||
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
|
||||
import io.circe.{Decoder, Encoder}
|
||||
import io.circe.{Decoder, Encoder, Json}
|
||||
|
||||
case class NewItem(metadata: Option[Meta], files: List[String]) {
|
||||
|
||||
@ -25,7 +25,7 @@ case class NewItem(metadata: Option[Meta], files: List[String]) {
|
||||
sourceAbbrev: String
|
||||
): ProcessItemArgs.ProcessMeta =
|
||||
metadata
|
||||
.getOrElse(Meta(None, None, None, None, None, None, None))
|
||||
.getOrElse(Meta.empty)
|
||||
.toProcessArgs(cid, collLang, sourceAbbrev)
|
||||
|
||||
def resolveFiles[F[_]: Files: Monad](
|
||||
@ -58,7 +58,8 @@ object NewItem {
|
||||
source: Option[String],
|
||||
skipDuplicate: Option[Boolean],
|
||||
tags: Option[List[String]],
|
||||
attachmentsOnly: Option[Boolean]
|
||||
attachmentsOnly: Option[Boolean],
|
||||
customData: Option[Json]
|
||||
) {
|
||||
|
||||
def toProcessArgs(
|
||||
@ -78,11 +79,14 @@ object NewItem {
|
||||
fileFilter = None,
|
||||
tags = tags,
|
||||
reprocess = false,
|
||||
attachmentsOnly = attachmentsOnly
|
||||
attachmentsOnly = attachmentsOnly,
|
||||
customData = customData
|
||||
)
|
||||
}
|
||||
|
||||
object Meta {
|
||||
val empty: Meta = Meta(None, None, None, None, None, None, None, None)
|
||||
|
||||
implicit val jsonEncoder: Encoder[Meta] = deriveEncoder
|
||||
implicit val jsonDecoder: Decoder[Meta] = deriveDecoder
|
||||
}
|
||||
|
Reference in New Issue
Block a user