Commit cd2dd338 authored by bow's avatar bow
Browse files

Move hiddenAttributes to base trait

parent 877cb631
......@@ -25,7 +25,7 @@ import org.scalatra.json.JacksonJsonSupport
import org.scalatra.swagger.{ DataType, Model, SwaggerSupport }
import org.slf4j.LoggerFactory
import nl.lumc.sasc.sentinel.models.{ ApiMessage, RunRecord }
import nl.lumc.sasc.sentinel.models.{ ApiMessage, BaseRunRecord }
import nl.lumc.sasc.sentinel.utils.{ SentinelJsonFormats, separateObjectIds, splitParam }
/** Base servlet for all Sentinel controllers. */
......@@ -71,7 +71,7 @@ abstract class SentinelServlet extends ScalatraServlet
val newModel =
if (model.id == "RunRecord")
model.copy(properties = interceptedProp.filter {
case (propName, prop) => !RunRecord.hiddenAttributes.contains(propName)
case (propName, prop) => !BaseRunRecord.hiddenAttributes.contains(propName)
})
else
model.copy(properties = interceptedProp)
......
......@@ -49,6 +49,11 @@ import org.bson.types.ObjectId
def deletionTimeUtc: Option[Date]
}
object BaseRunRecord {
/** Attributes that is hidden when this object is serialized into JSON. */
val hiddenAttributes = Set("sampleIds", "libIds")
}
/**
* Simple implementation of a run record.
*
......@@ -69,8 +74,3 @@ case class RunRecord(
libIds: Seq[ObjectId] = Seq(),
refId: Option[ObjectId] = None,
annotIds: Option[Seq[ObjectId]] = None) extends BaseRunRecord
object RunRecord {
/** Attributes that is hidden when this object is serialized into JSON. */
val hiddenAttributes = Set("sampleIds", "libIds")
}
......@@ -28,7 +28,7 @@ import org.bson.types.ObjectId
import org.json4s._
import org.scalatra.servlet.FileItem
import nl.lumc.sasc.sentinel.models.RunRecord
import nl.lumc.sasc.sentinel.models.{ BaseRunRecord, RunRecord }
/** General utilities */
package object utils {
......@@ -138,7 +138,7 @@ package object utils {
/** Serializer for outgoing JSON payloads. */
val RunDocumentSerializer =
FieldSerializer[RunRecord]({ case (attr, _) if RunRecord.hiddenAttributes.contains(attr) => None },
FieldSerializer[BaseRunRecord]({ case (attr, _) if BaseRunRecord.hiddenAttributes.contains(attr) => None },
{ case field => field })
/** JSON format used across the entire package. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment