diff options
author | Vyatcheslav Suharnikov <arz.freezy@gmail.com> | 2017-07-10 13:33:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-10 13:33:31 +0300 |
commit | 64b1565004ff530c34484dd80bff268e46c864ca (patch) | |
tree | 5ea67125bf59ac867d59097b0cb0bef130e788f3 /src/main/scala/xyz/driver/pdsuidomain/services/TrialIssueService.scala | |
parent | e0b7150b1fa7e1667307e1bbc47577914fb27866 (diff) | |
parent | 1f941bc2722a94e3a1b30d2aea7d7acbb3789aaf (diff) | |
download | rest-query-64b1565004ff530c34484dd80bff268e46c864ca.tar.gz rest-query-64b1565004ff530c34484dd80bff268e46c864ca.tar.bz2 rest-query-64b1565004ff530c34484dd80bff268e46c864ca.zip |
Merge pull request #5 from drivergroup/PDSUI-2013v0.1.22
PDSUI-2013 Create Trial Curation's own messages table for trials
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/TrialIssueService.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/services/TrialIssueService.scala | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/TrialIssueService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/TrialIssueService.scala new file mode 100644 index 0000000..df231ac --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/services/TrialIssueService.scala @@ -0,0 +1,93 @@ +package xyz.driver.pdsuidomain.services + +import java.time.LocalDateTime + +import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext +import xyz.driver.pdsuicommon.db.{Pagination, SearchFilterExpr, Sorting} +import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import xyz.driver.pdsuicommon.error.DomainError +import xyz.driver.pdsuidomain.entities.{Trial, TrialIssue} + +import scala.concurrent.Future + +object TrialIssueService { + + trait DefaultNotFoundError { + def userMessage: String = "TrialIssue not found" + } + + trait DefaultAccessDeniedError { + def userMessage: String = "Access denied" + } + + sealed trait CreateReply + object CreateReply { + type Error = CreateReply with DomainError + case class Created(x: TrialIssue) extends CreateReply + case object AuthorizationError + extends CreateReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case class CommonError(userMessage: String) extends CreateReply with DomainError + } + + sealed trait GetByIdReply + object GetByIdReply { + type Error = GetByIdReply with DomainError + case class Entity(x: TrialIssue) extends GetByIdReply + case object NotFoundError extends GetByIdReply with DomainError.NotFoundError with DefaultNotFoundError + case class CommonError(userMessage: String) extends GetByIdReply with DomainError + case object AuthorizationError + extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + } + + sealed trait GetListByTrialIdReply + object GetListByTrialIdReply { + type Error = GetListByTrialIdReply with DomainError + case class EntityList(xs: Seq[TrialIssue], totalFound: Int, lastUpdate: Option[LocalDateTime]) + extends GetListByTrialIdReply + case object NotFoundError extends GetListByTrialIdReply with DomainError.NotFoundError with DefaultNotFoundError + case object AuthorizationError + extends GetListByTrialIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + } + + sealed trait UpdateReply + object UpdateReply { + type Error = UpdateReply with DomainError + case class Updated(updated: TrialIssue) extends UpdateReply + case object AuthorizationError + extends UpdateReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case class CommonError(userMessage: String) extends UpdateReply with DomainError + } + + sealed trait DeleteReply + object DeleteReply { + type Error = DeleteReply with DomainError + case object Deleted extends DeleteReply + case object AuthorizationError + extends DeleteReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case object NotFoundError extends DeleteReply with DomainError.NotFoundError with DefaultNotFoundError + case class CommonError(userMessage: String) extends DeleteReply with DomainError + } +} + +trait TrialIssueService { + + import TrialIssueService._ + + def create(draft: TrialIssue)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] + + def getById(trialId: StringId[Trial], id: LongId[TrialIssue])( + implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + + def getListByTrialId(trialId: StringId[Trial], + filter: SearchFilterExpr = SearchFilterExpr.Empty, + sorting: Option[Sorting] = None, + pagination: Option[Pagination] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListByTrialIdReply] + + def update(orig: TrialIssue, draft: TrialIssue)( + implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + + def delete(trialId: StringId[Trial], id: LongId[TrialIssue])( + implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] + +} |