aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuicommon
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2017-10-02 18:37:52 +0700
committerKseniya Tomskikh <ktomskih@datamonsters.co>2017-10-02 18:37:52 +0700
commitd0e3c6f37347142a3ef5eab871dde47ea70af304 (patch)
treea87d24b1b5d6489576f00fe446f05b5110d62cc0 /src/main/scala/xyz/driver/pdsuicommon
parent283ca02360949143ffe7ee8ad87d51902426b450 (diff)
parent1913870abec9e31d080f6858d0fc296445852cc6 (diff)
downloadrest-query-d0e3c6f37347142a3ef5eab871dde47ea70af304.tar.gz
rest-query-d0e3c6f37347142a3ef5eab871dde47ea70af304.tar.bz2
rest-query-d0e3c6f37347142a3ef5eab871dde47ea70af304.zip
Merge branch 'master' into synch-refactor
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuicommon')
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/db/SlickPostgresQueryBuilder.scala3
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/db/SlickQueryBuilder.scala3
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParser.scala23
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala80
4 files changed, 93 insertions, 16 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/db/SlickPostgresQueryBuilder.scala b/src/main/scala/xyz/driver/pdsuicommon/db/SlickPostgresQueryBuilder.scala
index f882441..a56ab9a 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/db/SlickPostgresQueryBuilder.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/db/SlickPostgresQueryBuilder.scala
@@ -2,8 +2,7 @@ package xyz.driver.pdsuicommon.db
import java.time.{LocalDateTime, ZoneOffset}
-import slick.driver.JdbcProfile
-import slick.jdbc.GetResult
+import slick.jdbc.{JdbcProfile, GetResult}
import xyz.driver.core.database.SlickDal
import xyz.driver.pdsuicommon.logging._
diff --git a/src/main/scala/xyz/driver/pdsuicommon/db/SlickQueryBuilder.scala b/src/main/scala/xyz/driver/pdsuicommon/db/SlickQueryBuilder.scala
index ab2757b..0daa84d 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/db/SlickQueryBuilder.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/db/SlickQueryBuilder.scala
@@ -3,8 +3,7 @@ package xyz.driver.pdsuicommon.db
import java.sql.PreparedStatement
import java.time.LocalDateTime
-import slick.driver.JdbcProfile
-import slick.jdbc.{PositionedParameters, SQLActionBuilder, SetParameter}
+import slick.jdbc.{JdbcProfile, PositionedParameters, SQLActionBuilder, SetParameter}
import xyz.driver.pdsuicommon.db.Sorting.{Dimension, Sequential}
import xyz.driver.pdsuicommon.db.SortingOrder.{Ascending, Descending}
diff --git a/src/main/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParser.scala b/src/main/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParser.scala
index e0adeb8..e46e11c 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParser.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParser.scala
@@ -15,10 +15,7 @@ object SearchFilterParser {
private object BinaryAtomFromTuple {
def unapply(input: (SearchFilterExpr.Dimension, (String, Any))): Option[SearchFilterExpr.Atom.Binary] = {
val (dimensionName, (strOperation, value)) = input
- val updatedValue = value match {
- case s: String => s.safeTrim
- case a => a
- }
+ val updatedValue = trimIfString(value)
parseOperation(strOperation.toLowerCase).map { op =>
SearchFilterExpr.Atom.Binary(dimensionName, op, updatedValue.asInstanceOf[AnyRef])
@@ -30,15 +27,24 @@ object SearchFilterParser {
// Compiler warning: unchecked since it is eliminated by erasure, if we user Seq[String]
def unapply(input: (SearchFilterExpr.Dimension, (String, Seq[_]))): Option[SearchFilterExpr.Atom.NAry] = {
val (dimensionName, (strOperation, xs)) = input
+ val updatedValues = xs.map(trimIfString)
+
if (strOperation.toLowerCase == "in") {
- val values = xs.asInstanceOf[Seq[String]].map(_.safeTrim)
- Some(SearchFilterExpr.Atom.NAry(dimensionName, SearchFilterNAryOperation.In, values))
+ Some(
+ SearchFilterExpr.Atom
+ .NAry(dimensionName, SearchFilterNAryOperation.In, updatedValues.map(_.asInstanceOf[AnyRef])))
} else {
None
}
}
}
+ private def trimIfString(value: Any) =
+ value match {
+ case s: String => s.safeTrim
+ case a => a
+ }
+
private val operationsMapping = {
import xyz.driver.pdsuicommon.db.SearchFilterBinaryOperation._
@@ -96,7 +102,7 @@ object SearchFilterParser {
private val nAryValueParser: Parser[String] = P(CharPred(_ != ',').rep(min = 1).!)
- private val longParser: Parser[Long] = P(CharIn('0' to '9').rep(1).!.map(_.toLong))
+ private val longParser: Parser[Long] = P(CharIn('0' to '9').rep(min = 1).!.map(_.toLong))
private val binaryAtomParser: Parser[SearchFilterExpr.Atom.Binary] = P(
dimensionParser ~ whitespaceParser ~ (
@@ -109,7 +115,8 @@ object SearchFilterParser {
private val nAryAtomParser: Parser[SearchFilterExpr.Atom.NAry] = P(
dimensionParser ~ whitespaceParser ~ (
- naryOperatorParser ~/ whitespaceParser ~/ nAryValueParser.!.rep(min = 1, sep = ",")
+ naryOperatorParser ~ whitespaceParser ~
+ (longParser.rep(min = 1, sep = ",") | nAryValueParser.!.rep(min = 1, sep = ","))
) ~ End
).map {
case NAryAtomFromTuple(atom) => atom
diff --git a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
index 6c87858..83c4e6f 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
@@ -4,7 +4,7 @@ import java.time.{LocalDate, LocalDateTime}
import io.swagger.models.properties.Property
import spray.json.JsValue
-import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, TextJson, UuidId}
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.formats.json.sprayformats.arm._
import xyz.driver.pdsuidomain.formats.json.sprayformats.criterion._
@@ -15,25 +15,29 @@ import xyz.driver.pdsuidomain.formats.json.sprayformats.trial._
import xyz.driver.pdsuidomain.formats.json.sprayformats.trialhistory._
import xyz.driver.pdsuidomain.formats.json.sprayformats.trialissue._
import xyz.driver.core.swagger.CustomSwaggerJsonConverter._
+import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion
+import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
+
+import scala.collection.immutable
object CustomSwaggerJsonFormats {
- val customCommonProperties = Map[Class[_], Property](
+ val customCommonProperties = immutable.Map[Class[_], Property](
classOf[LocalDateTime] -> stringProperty(example = Some("2010-12-31'T'18:59:59Z")),
classOf[LocalDate] -> stringProperty(example = Some("2010-12-31")),
classOf[UuidId[_]] -> stringProperty(example = Some("370b0450-35cb-4aab-ba74-0145be75add5")),
classOf[StringId[_]] -> stringProperty(),
classOf[LongId[_]] -> stringProperty()
)
- val customTrialCurationProperties = Map[Class[_], Property](
+ val customTrialCurationProperties = immutable.Map[Class[_], Property](
classOf[Trial.Status] -> stringProperty(),
classOf[Trial.Condition] -> stringProperty(),
classOf[TrialHistory.Action] -> stringProperty(),
classOf[TrialHistory.State] -> stringProperty()
) ++ customCommonProperties
- val customTrialCurationObjectsExamples = Map[Class[_], JsValue](
+ val customTrialCurationObjectsExamples = immutable.Map[Class[_], JsValue](
classOf[Trial] -> trialWriter.write(xyz.driver.pdsuidomain.fakes.entities.trialcuration.nextTrial()),
classOf[Arm] -> armFormat.write(xyz.driver.pdsuidomain.fakes.entities.trialcuration.nextArm()),
classOf[TrialHistory] -> trialHistoryFormat.write(
@@ -52,4 +56,72 @@ object CustomSwaggerJsonFormats {
xyz.driver.pdsuidomain.fakes.entities.trialcuration.nextStudyDesign())
)
+ // records-processing-service
+ object Rep {
+ import xyz.driver.pdsuidomain.fakes.entities.rep
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.document
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.documentissue
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.documenthistory
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.record
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.recordissue
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.recordhistory
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.bridgeuploadqueue
+ import xyz.driver.pdsuidomain.formats.json.sprayformats.extracteddata
+
+ val customRepObjectsExamples = immutable.Map[Class[_], JsValue](
+ classOf[Document] ->
+ document.documentFormat.write(rep.DocumentGen.nextDocument()),
+ classOf[Document.Meta] ->
+ document.documentMetaFormat.write(rep.DocumentGen.nextDocumentMeta()),
+ classOf[TextJson[Document.Meta]] ->
+ document.fullDocumentMetaFormat.write(rep.DocumentGen.nextDocumentMetaJson()),
+ classOf[Document.RequiredType] ->
+ document.requiredTypeFormat.write(rep.DocumentGen.nextDocumentRequiredType()),
+ classOf[Document.Status] ->
+ document.documentStatusFormat.write(rep.DocumentGen.nextDocumentStatus()),
+ classOf[DocumentIssue] ->
+ documentissue.documentIssueFormat.write(rep.DocumentGen.nextDocumentIssue()),
+ classOf[DocumentHistory] ->
+ documenthistory.documentHistoryFormat.write(rep.DocumentGen.nextDocumentHistory()),
+ classOf[DocumentHistory.Action] ->
+ documenthistory.documentActionFormat.write(rep.DocumentGen.nextDocumentHistoryAction()),
+ classOf[DocumentHistory.State] ->
+ documenthistory.documentStateFormat.write(rep.DocumentGen.nextDocumentHistoryState()),
+ classOf[ProviderType] ->
+ record.providerTypeFormat.write(rep.MedicalRecordGen.nextProviderType()),
+ classOf[TextJson[List[MedicalRecord.Meta]]] ->
+ record.recordMetaFormat.write(rep.MedicalRecordGen.nextMedicalRecordMetasJson()),
+ classOf[MedicalRecord] ->
+ record.recordFormat.write(rep.MedicalRecordGen.nextMedicalRecord()),
+ classOf[MedicalRecord.Meta] ->
+ record.recordMetaTypeFormat.write(rep.MedicalRecordGen.nextMedicalRecordMeta()),
+ classOf[MedicalRecord.Status] ->
+ record.recordStatusFormat.write(rep.MedicalRecordGen.nextMedicalRecordStatus()),
+ classOf[MedicalRecordIssue] ->
+ recordissue.recordIssueFormat.write(rep.MedicalRecordGen.nextMedicalRecordIssue()),
+ classOf[MedicalRecordHistory] ->
+ recordhistory.recordHistoryFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistory()),
+ classOf[MedicalRecordHistory.Action] ->
+ recordhistory.recordActionFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistoryAction()),
+ classOf[MedicalRecordHistory.State] ->
+ recordhistory.recordStateFormat.write(rep.MedicalRecordGen.nextMedicalRecordHistoryState()),
+ classOf[BridgeUploadQueue.Item] ->
+ bridgeuploadqueue.queueUploadItemFormat.write(rep.BridgeUploadQueueGen.nextBridgeUploadQueueItem()),
+ classOf[ExtractedData.Meta] ->
+ extracteddata.extractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMeta()),
+ classOf[ExtractedData.Meta.Evidence] ->
+ extracteddata.metaEvidenceFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaEvidence()),
+ classOf[ExtractedData.Meta.Keyword] ->
+ extracteddata.metaKeywordFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaKeyword()),
+ classOf[ExtractedData.Meta.TextLayerPosition] ->
+ extracteddata.metaTextLayerPositionFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaTextLayerPosition()),
+ classOf[TextJson[ExtractedData.Meta]] ->
+ extracteddata.fullExtractedDataMetaFormat.write(rep.ExtractedDataGen.nextExtractedDataMetaJson()),
+ classOf[RichExtractedData] ->
+ extracteddata.extractedDataFormat.write(rep.ExtractedDataGen.nextRichExtractedData()),
+ classOf[ExtractedDataLabel] ->
+ extracteddata.extractedDataLabelWriter.write(rep.ExtractedDataGen.nextExtractedDataLabel())
+ )
+ }
+
}