Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. import java.sql.{Blob, Timestamp}
  2.  
  3. import slick.driver.MySQLDriver.api._
  4.  
  5. case class Anomaly1(id:Int, serviceName:String, serviceId: Int, timeUpdated: Timestamp, timeStamp: Timestamp,
  6. anomalyCategoryId: Int, userGroup: Int, riskValue: Float, activityTypeId: Int, destinationHost: String, userName: String)
  7.  
  8. case class Anomaly2(tenantId: Int, information:Blob, timeCreated: Timestamp, userId: Int, anomalyType:Int, anomalyValue: String, measure: Int, userAction: Int,
  9. uniqueIdentifier: String, similarCount: Int, trainingValue: String, state: Int, riskLevel: Int,
  10. userRiskLevel: Int, userRiskScore: Float, response: Int)
  11.  
  12. case class AnomalyRow(anomaly1: Anomaly1, anomaly2: Anomaly2)
  13.  
  14. class Anomaly(tag:Tag) extends Table[AnomalyRow](tag, "Anomaly") {
  15.  
  16. def id = column[Int]("id")
  17. def serviceName = column[String]("ServiceName")
  18. def serviceId = column[Int]("ServiceId")
  19. def timeUpdated = column[Timestamp]("TimeUpdated")
  20. def timestamp = column[Timestamp]("Timestamp")
  21. def anomalyCategoryId = column[Int]("AnomalyCategoryId")
  22. def userGroup = column[Int]("UserGroup")
  23. def riskValue = column[Float]("RiskValue")
  24. def activityTypeId = column[Int]("ActivityTypeId")
  25. def destinationHost = column[String]("DestinationHost")
  26. def userName = column[String]("UserName")
  27. def tenantId = column[Int]("TenantId")
  28. def information = column[Blob]("Information")
  29. def timeCreated = column[Timestamp]("TimeCreated")
  30. def userId = column[Int]("UserId")
  31. def anomalyType = column[Int]("AnomalyType")
  32. def anomalyValue = column[String]("AnomalyValue")
  33. def measure = column[Int]("Measure")
  34. def userAction = column[Int]("UserAction")
  35. def uniqueIdentifier = column[String]("UniqueIdentifier")
  36. def similarCount = column[Int]("SimilarCount")
  37. def trainingValue = column[String]("TrainingValue")
  38. def state = column[Int]("State")
  39. def riskLevel = column[Int]("RiskLevel")
  40. def userRiskLevel = column[Int]("UserRiskLevel")
  41. def userRiskScore = column[Float]("UserRiskScore")
  42. def response = column[Int]("Response")
  43.  
  44. private type Anomaly1TupleType = (Int, String, Int, Timestamp, Timestamp, Int, Int, Float, Int, String, String)
  45. private type Anomaly2TupleType = (Int, Blob, Timestamp, Int, Int, String, Int, Int, String, Int, String, Int, Int, Int, Float, Int)
  46. private type AnomalyRowTupleType = (Anomaly1TupleType, Anomaly2TupleType)
  47.  
  48. private val anomalyShapedValue = (
  49. (id, serviceName, serviceId, timeUpdated, timestamp, anomalyCategoryId, userGroup, riskValue, activityTypeId, destinationHost, userName),
  50. (tenantId, information, timeCreated, userId, anomalyType, anomalyValue, measure, userAction, uniqueIdentifier, similarCount, trainingValue, state, riskLevel, userRiskLevel, userRiskScore, response)
  51. ).shaped[AnomalyRowTupleType]
  52.  
  53. private val toAnomalyRow: (AnomalyRowTupleType => AnomalyRow) = { anomalyTuple =>
  54. AnomalyRow(anomaly1 = Anomaly1.tupled.apply(anomalyTuple._1), anomaly2 = Anomaly2.tupled.apply(anomalyTuple._2))
  55. }
  56.  
  57. private val toAnomalyTuple: (AnomalyRow => Option[AnomalyRowTupleType]) = { anomalyRow =>
  58. Some(Anomaly1.unapply(anomalyRow.anomaly1).get, Anomaly2.unapply(anomalyRow.anomaly2).get)
  59. }
  60.  
  61. def * = anomalyShapedValue <> (toAnomalyRow, toAnomalyTuple)
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement