/data/test/scala/52b2755b63e71e96da1a8aa671a25f1cebba917cLog.scala

https://github.com/aliostad/deep-learning-lang-detection · Scala · 94 lines · 58 code · 22 blank · 14 comment · 0 complexity · ea9a9909270aa9242c5a7d4b2d86549a MD5 · raw file

  1. package model
  2. import com.mongodb.casbah.Imports._
  3. import java.util.Date
  4. import com.novus.salat._
  5. import com.novus.salat.dao._
  6. import play.api.Play.current
  7. import se.radley.plugin.salat._
  8. import customContext._
  9. import com.mongodb.casbah.commons.MongoDBObject
  10. abstract class Log(
  11. val id: ObjectId = new ObjectId,
  12. val title: String,
  13. val content: String,
  14. val date: Date = new Date()
  15. )
  16. trait LogDAO extends ModelCompanion[Log, ObjectId] {
  17. def collection = mongoCollection("Logs")
  18. val dao = new SalatDAO[Log, ObjectId](collection) {}
  19. def findLatestLog(): List[Log] =
  20. Log.find(MongoDBObject()).sort(orderBy = MongoDBObject("_id" -> -1)).toList
  21. }
  22. trait LogFunc{
  23. def collection = mongoCollection("Logs")
  24. val dao = new SalatDAO[Log, ObjectId](collection) {}
  25. }
  26. object Log extends LogDAO
  27. case class ErrorLog(
  28. override val id: ObjectId = new ObjectId,
  29. override val title: String,
  30. override val content: String,
  31. override val date: Date = new Date()
  32. ) extends Log(id, title, content)
  33. trait ErrorLogDAO extends ModelCompanion[ErrorLog, ObjectId] {
  34. def collection = mongoCollection("Logs")
  35. val dao = new SalatDAO[ErrorLog, ObjectId](collection) {}
  36. def findLatestErrorLog(): List[Log] =
  37. Log.find(MongoDBObject()).sort(orderBy = MongoDBObject("_id" -> -1)).filter {
  38. case _: ErrorLog => true
  39. case _ => false
  40. }.toList
  41. }
  42. object ErrorLog extends ErrorLogDAO
  43. case class EventLog(
  44. override val id: ObjectId = new ObjectId,
  45. override val title: String,
  46. override val content: String,
  47. override val date: Date = new Date()
  48. ) extends Log(id, title, content)
  49. trait EventLogDAO extends ModelCompanion[EventLog, ObjectId] {
  50. def collection = mongoCollection("Logs")
  51. val dao = new SalatDAO[EventLog, ObjectId](collection) {}
  52. def findLatestEventLog(): List[Log] =
  53. Log.find(MongoDBObject()).sort(orderBy = MongoDBObject("_id" -> -1)).filter {
  54. case _: EventLog => true
  55. case _ => false
  56. }.toList
  57. }
  58. object EventLog extends EventLogDAO
  59. /*
  60. case class ManageLog(
  61. id: ObjectId = new ObjectId,
  62. logs: List[Log]
  63. )
  64. trait ManageLogDAO extends ModelCompanion[ManageLog, ObjectId] {
  65. def collection = mongoCollection("Logs")
  66. val dao = new SalatDAO[ManageLog, ObjectId](collection) {}
  67. }
  68. object ManageLog extends ManageLogDAO
  69. */