diff options
author | vlad <vlad@driver.xyz> | 2017-11-15 15:15:49 -0800 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-11-15 15:15:49 -0800 |
commit | 4c02a377d04b459bd2699b5f42c8fa5301dd72d0 (patch) | |
tree | 670484bb99182b5e2fdbfb3095edf102ca71cdb2 /src/main/scala/xyz/driver/pdsuidomain/entities | |
parent | 3e03db00fd3854930ae8daf19bd1504ea2a5bf7a (diff) | |
parent | 80e0f6e5db7f54e35551c4bf312abb58524b4003 (diff) | |
download | rest-query-4c02a377d04b459bd2699b5f42c8fa5301dd72d0.tar.gz rest-query-4c02a377d04b459bd2699b5f42c8fa5301dd72d0.tar.bz2 rest-query-4c02a377d04b459bd2699b5f42c8fa5301dd72d0.zip |
Merge remote-tracking branch 'origin/master' into master5v0.14.13
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities')
3 files changed, 112 insertions, 87 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala index 95710be..0669baf 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala @@ -428,8 +428,8 @@ object Document { }).right areDatesInThePast <- { - val dates = List(input.startDate, input.endDate).flatten - val now = LocalDate.now() + val dates = List(input.startDate, input.endDate).flatten + val now = LocalDate.now() val hasInvalid = dates.exists(_.isAfter(now)) if (hasInvalid) Validators.fail("Dates should be in the past") diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala index 0a8480b..f076074 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala @@ -6,7 +6,7 @@ import xyz.driver.core.auth.User import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuicommon.utils.Utils -import xyz.driver.pdsuidomain.entities.DocumentHistory._ +import xyz.driver.pdsuidomain.entities.DocumentHistory.{Action, _} object DocumentHistory { @@ -18,23 +18,29 @@ object DocumentHistory { sealed trait State object State { + case object New extends State case object Extract extends State case object Review extends State + case object Done extends State case object Flag extends State + case object Archive extends State - val All: Set[State] = Set[State](Extract, Review, Flag) + val All: Set[State] = Set( + State.New, + State.Extract, + State.Review, + State.Done, + State.Flag, + State.Archive + ) - val fromString: PartialFunction[String, State] = { - case "Extract" => State.Extract - case "Review" => State.Review - case "Flag" => State.Flag - } + private val stateToName: Map[State, String] = + All.map(s => s -> s.toString).toMap - def stateToString(x: State): String = x match { - case State.Extract => "Extract" - case State.Review => "Review" - case State.Flag => "Flag" - } + val fromString: PartialFunction[String, State] = + for ((k, v) <- stateToName) yield (v, k) + + def stateToString: State => String = stateToName implicit def toPhiString(x: State): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) @@ -49,38 +55,39 @@ object DocumentHistory { } object Action { - case object Start extends Action - case object Submit extends Action - case object Unassign extends Action - case object Resolve extends Action - case object Flag extends Action - case object Archive extends Action - - val All: Set[Action] = - Set[Action](Start, Submit, Unassign, Resolve, Flag, Archive) - - val fromString: PartialFunction[String, Action] = { - case "Start" => Action.Start - case "Submit" => Action.Submit - case "Unassign" => Action.Unassign - case "Resolve" => Action.Resolve - case "Flag" => Action.Flag - case "Archive" => Action.Archive - } - - def actionToString(x: Action): String = x match { - case Action.Start => "Start" - case Action.Submit => "Submit" - case Action.Unassign => "Unassign" - case Action.Resolve => "Resolve" - case Action.Flag => "Flag" - case Action.Archive => "Archive" - } + case object Start extends Action + case object Submit extends Action + case object Unassign extends Action + case object Resolve extends Action + case object Flag extends Action + case object Archive extends Action + case object PostEvidence extends Action + case object CreateDocument extends Action + case object ReadDocument extends Action + + val All: Set[Action] = Set( + Action.Start, + Action.Submit, + Action.Unassign, + Action.Resolve, + Action.Flag, + Action.Archive, + Action.PostEvidence, + Action.CreateDocument, + Action.ReadDocument + ) + + private val actionToName: Map[Action, String] = + All.map(a => a -> a.toString).toMap + + val fromString: PartialFunction[String, Action] = + for ((k, v) <- actionToName) yield (v, k) + + def actionToString: Action => String = actionToName implicit def toPhiString(x: Action): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) } - } final case class DocumentHistory(id: LongId[DocumentHistory], diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala index 4259737..5ed5805 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecordHistory.scala @@ -17,73 +17,91 @@ object MedicalRecordHistory { } sealed trait State + object State { + case object New extends State case object Clean extends State case object Organize extends State case object Review extends State + case object Done extends State case object Flag extends State + case object Archive extends State + + val All: Set[State] = Set( + State.New, + State.Clean, + State.Organize, + State.Review, + State.Done, + State.Flag, + State.Archive + ) - val All: Set[State] = Set[State](Clean, Organize, Review, Flag) + private val stateToName: Map[State, String] = + All.map(s => s -> s.toString).toMap - val fromString: PartialFunction[String, State] = { - case "Clean" => State.Clean - case "Organize" => State.Organize - case "Review" => State.Review - case "Flag" => State.Flag - } + val fromString: PartialFunction[String, State] = + for ((k, v) <- stateToName) yield (v, k) - def stateToString(x: State): String = x match { - case State.Clean => "Clean" - case State.Organize => "Organize" - case State.Review => "Review" - case State.Flag => "Flag" - } + def stateToString: State => String = stateToName implicit def toPhiString(x: State): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) } sealed trait Action extends Product with Serializable { - - def oneOf(xs: Action*): Boolean = xs.contains(this) - + def oneOf(xs: Action*): Boolean = xs.contains(this) def oneOf(xs: Set[Action]): Boolean = xs.contains(this) - } object Action { - case object Start extends Action - case object Submit extends Action - case object Unassign extends Action - case object Resolve extends Action - case object Flag extends Action - case object Archive extends Action - - val All: Set[Action] = - Set[Action](Start, Submit, Unassign, Resolve, Flag, Archive) - - val fromString: PartialFunction[String, Action] = { - case "Start" => Action.Start - case "Submit" => Action.Submit - case "Unassign" => Action.Unassign - case "Resolve" => Action.Resolve - case "Flag" => Action.Flag - case "Archive" => Action.Archive - } - - def actionToString(x: Action): String = x match { - case Action.Start => "Start" - case Action.Submit => "Submit" - case Action.Unassign => "Unassign" - case Action.Resolve => "Resolve" - case Action.Flag => "Flag" - case Action.Archive => "Archive" - } + case object Start extends Action + case object Submit extends Action + case object Unassign extends Action + case object Resolve extends Action + case object Flag extends Action + case object Archive extends Action + case object SaveDuplicate extends Action + case object SaveReorder extends Action + case object SaveRotation extends Action + case object DeleteDuplicate extends Action + case object DeleteReorder extends Action + case object DeleteRotation extends Action + case object CreateDocument extends Action + case object DeleteDocument extends Action + case object CreateRecord extends Action + case object ReadRecord extends Action + + val All: Set[Action] = Set( + Action.Start, + Action.Submit, + Action.Unassign, + Action.Resolve, + Action.Flag, + Action.Archive, + Action.SaveDuplicate, + Action.SaveReorder, + Action.SaveRotation, + Action.DeleteDuplicate, + Action.DeleteReorder, + Action.DeleteRotation, + Action.CreateDocument, + Action.DeleteDocument, + Action.CreateRecord, + Action.ReadRecord + ) + + private val actionToName: Map[Action, String] = + All.map(a => a -> a.toString).toMap + + val fromString: PartialFunction[String, Action] = + for ((k, v) <- actionToName) yield (v, k) + + def actionToString: Action => String = actionToName implicit def toPhiString(x: Action): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) } - } final case class MedicalRecordHistory(id: LongId[MedicalRecordHistory], |