diff options
author | vlad <vlad@driver.xyz> | 2017-07-01 04:50:38 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-07-01 04:50:38 -0700 |
commit | 05543fd8a5a4fb9a63843bde9ec124d623f1c094 (patch) | |
tree | fd70fe49053d91592e05f63a7664166e4dad063f /src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala | |
parent | 6a198a9da5a4fbdc94b008b743246c1b0ab2c3dc (diff) | |
download | rest-query-05543fd8a5a4fb9a63843bde9ec124d623f1c094.tar.gz rest-query-05543fd8a5a4fb9a63843bde9ec124d623f1c094.tar.bz2 rest-query-05543fd8a5a4fb9a63843bde9ec124d623f1c094.zip |
Moving storages back and adding ListResponse herev0.1.17
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala b/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala deleted file mode 100644 index 6aa49a1..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala +++ /dev/null @@ -1,48 +0,0 @@ -package xyz.driver.pdsuidomain.storage - -import xyz.driver.pdsuicommon.domain.{LongId, UuidId} -import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{Arm, Patient} - -import scala.collection.concurrent.TrieMap - -object RequestStorage { - type Key = (UuidId[Patient], String) - type Value = Set[LongId[Arm]] -} - -class RequestStorage extends PhiLogging { - import RequestStorage._ - - private val storage = new TrieMap[Key, Value]() - - def put(patientId: UuidId[Patient], disease: String, ineligibleArms: Set[LongId[Arm]]): Unit = { - logger.debug(phi"put($patientId, ${Unsafe(disease)}, $ineligibleArms") - val key = (patientId, disease.toLowerCase) - get(patientId, disease.toLowerCase) match { - case Some(oldValue) => - logger.trace(phi"Requested ineligible arms=$oldValue, replace it") - storage.replace(key, oldValue, ineligibleArms) - case None => - logger.trace(phi"Put request into storage") - storage.put(key, ineligibleArms) - } - } - - def get(patientId: UuidId[Patient], disease: String): Option[Value] = { - logger.debug(phi"get($patientId, ${Unsafe(disease)}") - val key = (patientId, disease.toLowerCase) - storage.get(key) - } - - def contains(patientId: UuidId[Patient], disease: String, value: Set[LongId[Arm]]): Boolean = { - logger.debug(phi"contains(key=($patientId,${Unsafe(disease)}), value=$value") - get(patientId, disease.toLowerCase).contains(value) - } - - def remove(patientId: UuidId[Patient], disease: String): Unit = { - logger.debug(phi"remove($patientId,${Unsafe(disease)}") - val key = (patientId, disease.toLowerCase) - storage.remove(key) - } -} |