diff options
author | vlad <vlad@driver.xyz> | 2017-06-13 16:12:20 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-06-13 16:12:20 -0700 |
commit | cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c (patch) | |
tree | 062e8dad1a1513e26b0fd08b1742d6ff2ee874f7 /src/main/scala/xyz/driver/pdsuidomain/entities/Criterion.scala | |
parent | 0000a65ab4479a2a40e2d6468036438e9705b4aa (diff) | |
download | rest-query-cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c.tar.gz rest-query-cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c.tar.bz2 rest-query-cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c.zip |
Adding domain entitiesv0.1.0
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities/Criterion.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/entities/Criterion.scala | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Criterion.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Criterion.scala new file mode 100644 index 0000000..0dfb33f --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Criterion.scala @@ -0,0 +1,55 @@ +package xyz.driver.pdsuidomain.entities + +import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import xyz.driver.pdsuicommon.logging._ +import xyz.driver.pdsuidomain.entities.Criterion.Meta.Evidence + +final case class Criterion(id: LongId[Criterion], + trialId: StringId[Trial], + text: Option[String], + isCompound: Boolean, + meta: String) { + + def isValid(): Boolean = text.nonEmpty && Option(meta).isDefined +} + +object Criterion { + + final case class Meta(evidence: Evidence) + + object Meta { + final case class Evidence(pageRatio: Double, start: TextLayerPosition, end: TextLayerPosition) + final case class TextLayerPosition(page: Integer, index: Integer, offset: Integer) + } + + implicit def toPhiString(x: Criterion): PhiString = { + import x._ + phi"Criterion(id=$id, trialId=$trialId, isCompound=$isCompound)" + } +} + +final case class CriterionArm(criterionId: LongId[Criterion], armId: LongId[Arm]) + +object CriterionArm { + + implicit def toPhiString(x: CriterionArm): PhiString = { + import x._ + phi"CriterionArm(criterionId=$criterionId, armId=$armId)" + } +} + +final case class CriterionLabel(id: LongId[CriterionLabel], + labelId: Option[LongId[Label]], + criterionId: LongId[Criterion], + categoryId: Option[LongId[Category]], + value: Option[Boolean], + isDefining: Boolean) + +object CriterionLabel { + + implicit def toPhiString(x: CriterionLabel): PhiString = { + import x._ + phi"CriterionLabel(id=$id, labelId=$labelId, criterionId=$criterionId, " + + phi"categoryId=$categoryId, value=$value, isDefining=$isDefining)" + } +} |