From e2313321736520e6acaeb9aaa6ab426e6a8415ff Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Wed, 12 Jul 2017 11:39:40 +0300 Subject: PDSUI-2018 Change user type from LongId to StringId --- .../pdsuidomain/formats/json/document/ApiDocument.scala | 12 ++++++------ .../formats/json/document/ApiPartialDocument.scala | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/document') 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 859972c..c01e65c 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 @@ -20,9 +20,9 @@ final case class ApiDocument(id: Long, requiredType: Option[String], status: Option[String], previousStatus: Option[String], - assignee: Option[Long], - previousAssignee: Option[Long], - lastActiveUser: Option[Long], + assignee: Option[String], + previousAssignee: Option[String], + lastActiveUser: Option[String], meta: Option[String]) object ApiDocument { @@ -48,9 +48,9 @@ object ApiDocument { (JsPath \ "requiredType").formatNullable[String] and (JsPath \ "status").formatNullable(statusFormat) and (JsPath \ "previousStatus").formatNullable(statusFormat) and - (JsPath \ "assignee").formatNullable[Long] and - (JsPath \ "previousAssignee").formatNullable[Long] and - (JsPath \ "lastActiveUser").formatNullable[Long] and + (JsPath \ "assignee").formatNullable[String] and + (JsPath \ "previousAssignee").formatNullable[String] and + (JsPath \ "lastActiveUser").formatNullable[String] and (JsPath \ "meta").formatNullable(Format(Reads { x => JsSuccess(Json.stringify(x)) }, Writes[String](Json.parse))) 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 84e9e09..e9485e7 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 @@ -2,16 +2,16 @@ package xyz.driver.pdsuidomain.formats.json.document import java.time.{LocalDate, LocalDateTime} -import xyz.driver.pdsuicommon.domain.{LongId, TextJson} -import xyz.driver.pdsuidomain.entities.Document.Meta -import xyz.driver.pdsuidomain.entities._ import org.davidbild.tristate.Tristate import org.davidbild.tristate.contrib.play.ToJsPathOpsFromJsPath import play.api.data.validation._ import play.api.libs.functional.syntax._ import play.api.libs.json._ +import xyz.driver.pdsuicommon.domain.{LongId, StringId, TextJson} import xyz.driver.pdsuicommon.json.{JsonSerializer, JsonValidationException} import xyz.driver.pdsuicommon.validation.{AdditionalConstraints, JsonValidationErrors} +import xyz.driver.pdsuidomain.entities.Document.Meta +import xyz.driver.pdsuidomain.entities._ import scala.collection.breakOut import scala.util.Try @@ -24,7 +24,7 @@ final case class ApiPartialDocument(recordId: Option[Long], provider: Tristate[String], providerTypeId: Tristate[Long], status: Option[String], - assignee: Tristate[Long], + assignee: Tristate[String], meta: Tristate[String]) { import xyz.driver.pdsuicommon.domain.User @@ -33,7 +33,7 @@ final case class ApiPartialDocument(recordId: Option[Long], id = orig.id, status = status.map(Document.Status.fromString).getOrElse(orig.status), previousStatus = orig.previousStatus, - assignee = assignee.map(LongId[User]).cata(Some(_), None, orig.assignee), + assignee = assignee.map(StringId[User]).cata(Some(_), None, orig.assignee), previousAssignee = orig.previousAssignee, lastActiveUserId = orig.lastActiveUserId, recordId = recordId.map(LongId[MedicalRecord]).getOrElse(orig.recordId), @@ -94,7 +94,7 @@ object ApiPartialDocument { case x if Document.Status.fromString.isDefinedAt(x) => true case _ => false })) and - (JsPath \ "assignee").readTristate[Long] and + (JsPath \ "assignee").readTristate[String] and (JsPath \ "meta").readTristate(Reads { x => JsSuccess(Json.stringify(x)) }).map { case Tristate.Present("{}") => Tristate.Absent case x => x @@ -110,7 +110,7 @@ object ApiPartialDocument { (JsPath \ "provider").writeTristate[String] and (JsPath \ "providerTypeId").writeTristate[Long] and (JsPath \ "status").writeNullable[String] and - (JsPath \ "assignee").writeTristate[Long] and + (JsPath \ "assignee").writeTristate[String] and (JsPath \ "meta").writeTristate(Writes[String](Json.parse)) ) (unlift(ApiPartialDocument.unapply)) -- cgit v1.2.3