aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/message
diff options
context:
space:
mode:
authorJakob Odersky <jakob@driver.xyz>2017-07-05 19:02:13 -0700
committerJakob Odersky <jakob@driver.xyz>2017-07-12 21:04:25 -0700
commitf9ac0adf5c3bcfcde03bd3ea2bc2471b0d0f99fe (patch)
tree9e26568fe6598074a6de8815b465cbfc7ff69b7c /src/main/scala/xyz/driver/pdsuidomain/formats/json/message
parent3d902b5197db861c30325c159dc10cfb211ae209 (diff)
downloadrest-query-f9ac0adf5c3bcfcde03bd3ea2bc2471b0d0f99fe.tar.gz
rest-query-f9ac0adf5c3bcfcde03bd3ea2bc2471b0d0f99fe.tar.bz2
rest-query-f9ac0adf5c3bcfcde03bd3ea2bc2471b0d0f99fe.zip
Implement REST services for trial curation
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/message')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiMessage.scala22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiMessage.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiMessage.scala
index 2591509..425eeac 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiMessage.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/message/ApiMessage.scala
@@ -4,6 +4,7 @@ import java.time.{ZoneId, ZonedDateTime}
import play.api.libs.functional.syntax._
import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
import xyz.driver.pdsuidomain.entities.Message
final case class ApiMessage(id: Long,
@@ -19,7 +20,26 @@ final case class ApiMessage(id: Long,
endPage: Option[Double],
evidence: Option[String],
archiveRequired: Option[Boolean],
- meta: Option[String])
+ meta: Option[String]) {
+
+ def toDomain = Message(
+ id = LongId(this.id),
+ text = this.text,
+ lastUpdate = this.lastUpdate.toLocalDateTime(),
+ userId = StringId(this.userId),
+ isDraft = this.isDraft,
+ recordId = this.recordId.map(id => LongId(id)),
+ documentId = this.documentId.map(id => LongId(id)),
+ patientId = this.patientId.map(id => UuidId(id)),
+ trialId = this.trialId.map(id => StringId(id)),
+ startPage = this.startPage,
+ endPage = this.endPage,
+ evidence = this.evidence,
+ archiveRequired = this.archiveRequired,
+ meta = this.meta
+ )
+
+}
object ApiMessage {