diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-20 16:25:04 +0700 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-20 16:25:04 +0700 |
commit | 54b15dae509212f6661dc1f1bc4ca248cb487443 (patch) | |
tree | 85b1ceafd9a56da511513797bd263977f52b556c /src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiPartialMessage.scala | |
parent | 6d6e732368e97e319653f00e498189afceeb4671 (diff) | |
download | rest-query-54b15dae509212f6661dc1f1bc4ca248cb487443.tar.gz rest-query-54b15dae509212f6661dc1f1bc4ca248cb487443.tar.bz2 rest-query-54b15dae509212f6661dc1f1bc4ca248cb487443.zip |
PDSUI-2336 Deleted api classes of play format, userhistory and message services
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiPartialMessage.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiPartialMessage.scala | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiPartialMessage.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiPartialMessage.scala deleted file mode 100644 index a2656f2..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiPartialMessage.scala +++ /dev/null @@ -1,82 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.message - -import java.time.LocalDateTime - -import xyz.driver.pdsuicommon.domain._ -import play.api.libs.functional.syntax._ -import play.api.libs.json.{Format, JsPath} -import xyz.driver.pdsuidomain.entities.Message - -final case class ApiPartialMessage(text: Option[String], - recordId: Option[Long], - documentId: Option[Long], - patientId: Option[String], - trialId: Option[String], - startPage: Option[Double], - endPage: Option[Double], - evidence: Option[String], - archiveRequired: Option[Boolean], - meta: Option[String]) { - - def toDomain(userId: StringId[User]) = Message( - id = LongId(0), - text = text.getOrElse(""), - userId = userId, - isDraft = true, - recordId = recordId.map(LongId(_)), - documentId = documentId.map(LongId(_)), - patientId = patientId.map(UuidId(_)), - trialId = trialId.map(StringId(_)), - startPage = startPage, - endPage = endPage, - evidence = evidence, - archiveRequired = archiveRequired, - meta = meta, - lastUpdate = LocalDateTime.MIN - ) - - def applyTo(orig: Message): Message = { - orig.copy( - text = text.getOrElse(""), - recordId = recordId.map(LongId(_)), - documentId = documentId.map(LongId(_)), - patientId = patientId.map(UuidId(_)), - trialId = trialId.map(StringId(_)), - startPage = startPage, - endPage = endPage, - evidence = evidence, - archiveRequired = archiveRequired, - meta = meta, - lastUpdate = LocalDateTime.MIN - ) - } -} - -object ApiPartialMessage { - - implicit val format: Format[ApiPartialMessage] = ( - (JsPath \ "text").formatNullable[String] and - (JsPath \ "recordId").formatNullable[Long] and - (JsPath \ "documentId").formatNullable[Long] and - (JsPath \ "patientId").formatNullable[String] and - (JsPath \ "trialId").formatNullable[String] and - (JsPath \ "startPage").formatNullable[Double] and - (JsPath \ "endPage").formatNullable[Double] and - (JsPath \ "evidence").formatNullable[String] and - (JsPath \ "archiveRequired").formatNullable[Boolean] and - (JsPath \ "meta").formatNullable[String] - )(ApiPartialMessage.apply, unlift(ApiPartialMessage.unapply)) - - def fromDomain(domain: Message) = ApiPartialMessage( - text = Some(domain.text), - recordId = domain.recordId.map(_.id), - documentId = domain.documentId.map(_.id), - patientId = domain.patientId.map(_.toString), - trialId = domain.trialId.map(_.toString), - startPage = domain.startPage, - endPage = domain.endPage, - evidence = domain.evidence, - archiveRequired = domain.archiveRequired, - meta = domain.meta - ) -} |