From 0ee8ff66d5ba3888d94febd5eb30ee99e752725a Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Mon, 30 Nov 2020 14:07:45 +0100 Subject: [PATCH] Allow to search by source name --- .../restapi/src/main/resources/docspell-openapi.yml | 2 ++ .../scala/docspell/restserver/conv/Conversions.scala | 1 + .../src/main/scala/docspell/store/queries/QItem.scala | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/restapi/src/main/resources/docspell-openapi.yml b/modules/restapi/src/main/resources/docspell-openapi.yml index b40609e5..db8a440d 100644 --- a/modules/restapi/src/main/resources/docspell-openapi.yml +++ b/modules/restapi/src/main/resources/docspell-openapi.yml @@ -5065,6 +5065,8 @@ components: type: array items: $ref: "#/components/schemas/CustomFieldValue" + source: + type: string ItemLight: description: | An item with only a few important properties. diff --git a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala index 48728535..b17ca5f7 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala @@ -144,6 +144,7 @@ trait Conversions { .map(_.ids.flatMap(i => Ident.fromString(i).toOption).toSet) .filter(_.nonEmpty), m.customValues.map(mkCustomValue), + m.source, None ) diff --git a/modules/store/src/main/scala/docspell/store/queries/QItem.scala b/modules/store/src/main/scala/docspell/store/queries/QItem.scala index 4252d590..494bf2b2 100644 --- a/modules/store/src/main/scala/docspell/store/queries/QItem.scala +++ b/modules/store/src/main/scala/docspell/store/queries/QItem.scala @@ -216,6 +216,7 @@ object QItem { allNames: Option[String], itemIds: Option[Set[Ident]], customValues: Seq[CustomValue], + source: Option[String], orderAsc: Option[RItem.Columns.type => Column] ) @@ -242,6 +243,7 @@ object QItem { None, None, Seq.empty, + None, None ) } @@ -413,9 +415,10 @@ object QItem { val tagSelectsExcl = TagItemName.itemsWithTagOrCategory(q.tagsExclude, q.tagCategoryExcl) - val iFolder = IC.folder.prefix("i") - val name = q.name.map(_.toLowerCase).map(QueryWildcard.apply) - val allNames = q.allNames.map(_.toLowerCase).map(QueryWildcard.apply) + val iFolder = IC.folder.prefix("i") + val name = q.name.map(_.toLowerCase).map(QueryWildcard.apply) + val allNames = q.allNames.map(_.toLowerCase).map(QueryWildcard.apply) + val sourceName = q.source.map(_.toLowerCase).map(QueryWildcard.apply) val cond = and( IC.cid.prefix("i").is(q.account.collective), IC.state.prefix("i").isOneOf(q.states), @@ -458,6 +461,7 @@ object QItem { .getOrElse(Fragment.empty), q.dueDateFrom.map(d => IC.dueDate.prefix("i").isGt(d)).getOrElse(Fragment.empty), q.dueDateTo.map(d => IC.dueDate.prefix("i").isLt(d)).getOrElse(Fragment.empty), + sourceName.map(s => IC.source.prefix("i").lowerLike(s)).getOrElse(Fragment.empty), q.itemIds .map(ids => NonEmptyList