diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-19 18:38:42 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 18:38:42 +0700 |
commit | 9ca0cae09bc880ce083c2a49ae3804889cc9d4c4 (patch) | |
tree | 043fdac6926ce0a2a6e8419c1121ad43ffa4aaa6 /src/main/scala | |
parent | c04b779341e9d54e5b519db085420c9a1ea66610 (diff) | |
parent | 608bf540c38a2656dd18423b40362bedbdaeabd7 (diff) | |
download | rest-query-0.9.4.tar.gz rest-query-0.9.4.tar.bz2 rest-query-0.9.4.zip |
Merge pull request #52 from drivergroup/PDSUI-1088-2v0.9.4
PDSUI-1088 Added labelVersion to documents
Diffstat (limited to 'src/main/scala')
6 files changed, 21 insertions, 10 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala index 258aa03..fa5f4ce 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala @@ -456,7 +456,8 @@ final case class Document(id: LongId[Document] = LongId(0L), meta: Option[TextJson[Meta]], // not null startDate: Option[LocalDate], // not null endDate: Option[LocalDate], - lastUpdate: LocalDateTime) { + lastUpdate: LocalDateTime, + labelVersion: Int) { import Document.Status._ diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala index d2a648c..8ba1d82 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/recordprocessing.scala @@ -182,7 +182,8 @@ object recordprocessing { meta = nextOption(nextDocumentMetaJson()), startDate = startDate, endDate = endDate, - lastUpdate = nextLocalDateTime + lastUpdate = nextLocalDateTime, + labelVersion = generators.nextInt(100) ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala @@ -0,0 +1 @@ + diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocument.scala index 3f1ecfe..250e650 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocument.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiDocument.scala @@ -25,7 +25,8 @@ final case class ApiDocument(id: Long, assignee: Option[String], previousAssignee: Option[String], lastActiveUser: Option[String], - meta: Option[String]) { + meta: Option[String], + labelVersion: Int) { private def extractStatus(status: String): Document.Status = Document.Status.fromString(status).getOrElse(throw new NoSuchElementException(s"Status $status unknown")) @@ -50,7 +51,8 @@ final case class ApiDocument(id: Long, meta = this.meta.map(x => TextJson(JsonSerializer.deserialize[Document.Meta](x))), startDate = this.startDate, endDate = this.endDate, - lastUpdate = this.lastUpdate.toLocalDateTime() + lastUpdate = this.lastUpdate.toLocalDateTime(), + labelVersion = this.labelVersion ) } @@ -83,7 +85,8 @@ object ApiDocument { (JsPath \ "lastActiveUser").formatNullable[String] and (JsPath \ "meta").formatNullable(Format(Reads { x => JsSuccess(Json.stringify(x)) - }, Writes[String](Json.parse))) + }, Writes[String](Json.parse))) and + (JsPath \ "labelVersion").format[Int] )(ApiDocument.apply, unlift(ApiDocument.unapply)) def fromDomain(document: Document): ApiDocument = { @@ -104,7 +107,8 @@ object ApiDocument { assignee = document.assignee.map(_.id), previousAssignee = document.previousAssignee.map(_.id), lastActiveUser = document.lastActiveUserId.map(_.id), - meta = document.meta.map(meta => JsonSerializer.serialize(meta.content)) + meta = document.meta.map(meta => JsonSerializer.serialize(meta.content)), + labelVersion = document.labelVersion ) } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiPartialDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiPartialDocument.scala index 032ddf6..ecbdaed 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiPartialDocument.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document/ApiPartialDocument.scala @@ -47,7 +47,8 @@ final case class ApiPartialDocument(recordId: Option[Long], meta = meta.cata(x => Some(TextJson(JsonSerializer.deserialize[Meta](x))), None, orig.meta), startDate = startDate.cata(Some(_), None, orig.startDate), endDate = endDate.cata(Some(_), None, orig.endDate), - lastUpdate = LocalDateTime.MIN // Should update internally in a business logic module + lastUpdate = LocalDateTime.MIN, // Should update internally in a business logic module, + labelVersion = orig.labelVersion ) def toDomain: Try[Document] = Try { @@ -75,7 +76,8 @@ final case class ApiPartialDocument(recordId: Option[Long], assignee = None, previousAssignee = None, lastActiveUserId = None, - lastUpdate = LocalDateTime.MIN + lastUpdate = LocalDateTime.MIN, + labelVersion = 0 ) } else { throw new JsonValidationException(validationErrors) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala index f742915..c584b96 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala @@ -126,7 +126,8 @@ object document { "previousAssignee" -> document.previousAssignee.toJson, "meta" -> document.meta.toJson, "lastActiveUser" -> document.lastActiveUserId.toJson, - "lastUpdate" -> document.lastUpdate.toJson + "lastUpdate" -> document.lastUpdate.toJson, + "labelVersion" -> document.labelVersion.toJson ) override def read(json: JsValue): Document = json match { @@ -185,7 +186,8 @@ object document { assignee = None, previousAssignee = None, lastActiveUserId = None, - lastUpdate = LocalDateTime.MIN + lastUpdate = LocalDateTime.MIN, + labelVersion = 0 ) case _ => deserializationError(s"Expected Json Object as Document, but got $json") |