Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.{Blob, Timestamp}
- import slick.driver.MySQLDriver.api._
- case class Anomaly1(id:Int, serviceName:String, serviceId: Int, timeUpdated: Timestamp, timeStamp: Timestamp,
- anomalyCategoryId: Int, userGroup: Int, riskValue: Float, activityTypeId: Int, destinationHost: String, userName: String)
- case class Anomaly2(tenantId: Int, information:Blob, timeCreated: Timestamp, userId: Int, anomalyType:Int, anomalyValue: String, measure: Int, userAction: Int,
- uniqueIdentifier: String, similarCount: Int, trainingValue: String, state: Int, riskLevel: Int,
- userRiskLevel: Int, userRiskScore: Float, response: Int)
- case class AnomalyRow(anomaly1: Anomaly1, anomaly2: Anomaly2)
- class Anomaly(tag:Tag) extends Table[AnomalyRow](tag, "Anomaly") {
- def id = column[Int]("id")
- def serviceName = column[String]("ServiceName")
- def serviceId = column[Int]("ServiceId")
- def timeUpdated = column[Timestamp]("TimeUpdated")
- def timestamp = column[Timestamp]("Timestamp")
- def anomalyCategoryId = column[Int]("AnomalyCategoryId")
- def userGroup = column[Int]("UserGroup")
- def riskValue = column[Float]("RiskValue")
- def activityTypeId = column[Int]("ActivityTypeId")
- def destinationHost = column[String]("DestinationHost")
- def userName = column[String]("UserName")
- def tenantId = column[Int]("TenantId")
- def information = column[Blob]("Information")
- def timeCreated = column[Timestamp]("TimeCreated")
- def userId = column[Int]("UserId")
- def anomalyType = column[Int]("AnomalyType")
- def anomalyValue = column[String]("AnomalyValue")
- def measure = column[Int]("Measure")
- def userAction = column[Int]("UserAction")
- def uniqueIdentifier = column[String]("UniqueIdentifier")
- def similarCount = column[Int]("SimilarCount")
- def trainingValue = column[String]("TrainingValue")
- def state = column[Int]("State")
- def riskLevel = column[Int]("RiskLevel")
- def userRiskLevel = column[Int]("UserRiskLevel")
- def userRiskScore = column[Float]("UserRiskScore")
- def response = column[Int]("Response")
- private type Anomaly1TupleType = (Int, String, Int, Timestamp, Timestamp, Int, Int, Float, Int, String, String)
- private type Anomaly2TupleType = (Int, Blob, Timestamp, Int, Int, String, Int, Int, String, Int, String, Int, Int, Int, Float, Int)
- private type AnomalyRowTupleType = (Anomaly1TupleType, Anomaly2TupleType)
- private val anomalyShapedValue = (
- (id, serviceName, serviceId, timeUpdated, timestamp, anomalyCategoryId, userGroup, riskValue, activityTypeId, destinationHost, userName),
- (tenantId, information, timeCreated, userId, anomalyType, anomalyValue, measure, userAction, uniqueIdentifier, similarCount, trainingValue, state, riskLevel, userRiskLevel, userRiskScore, response)
- ).shaped[AnomalyRowTupleType]
- private val toAnomalyRow: (AnomalyRowTupleType => AnomalyRow) = { anomalyTuple =>
- AnomalyRow(anomaly1 = Anomaly1.tupled.apply(anomalyTuple._1), anomaly2 = Anomaly2.tupled.apply(anomalyTuple._2))
- }
- private val toAnomalyTuple: (AnomalyRow => Option[AnomalyRowTupleType]) = { anomalyRow =>
- Some(Anomaly1.unapply(anomalyRow.anomaly1).get, Anomaly2.unapply(anomalyRow.anomaly2).get)
- }
- def * = anomalyShapedValue <> (toAnomalyRow, toAnomalyTuple)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement