* or implied, of GRNET S.A.
*/
-package gr.grnet.aquarium
-package event
+package gr.grnet.aquarium.event.model
import java.util.Date
-import converter.{JsonTextFormat, StdConverters}
-import util.json.JsonSupport
+import gr.grnet.aquarium.converter.{JsonTextFormat, StdConverters}
/**
* A WalletEntry is a derived entity. Its data represent money/credits and are calculated based on
* @author Christos KK Loverdos <loverdos@gmail.com>
*/
case class WalletEntry(
- id: String, // The id at the client side (the sender) TODO: Rename to remoteId or something...
- occurredMillis: Long, // The time of oldest matching resource event
- receivedMillis: Long, // The time the cost calculation was done
- sourceEventIDs: List[String], // The events that triggered this WalletEntry
- value: Double,
- reason: String,
- userId: String,
- resource: String,
- instanceId: String,
- finalized: Boolean,
- eventVersion: String = "1.0",
- userID: String = "",
- details: Map[String, String] = Map()
-) extends ExternalEventModel {
+ id: String, // The id at the client side (the sender) TODO: Rename to remoteId or something...
+ occurredMillis: Long, // The time of oldest matching resource event
+ receivedMillis: Long, // The time the cost calculation was done
+ sourceEventIDs: List[String], // The events that triggered this WalletEntry
+ value: Double,
+ reason: String,
+ userId: String,
+ resource: String,
+ instanceId: String,
+ finalized: Boolean,
+ eventVersion: String = "1.0",
+ userID: String = "",
+ details: Map[String, String] = Map()
+ ) extends ExternalEventModel {
assert(occurredMillis > 0)
assert(!userId.isEmpty)
def validate = true
-
+
def fromResourceEvent(rceId: String): Boolean = {
sourceEventIDs contains rceId
}
this.copy(details = newDetails, occurredMillis = newOccurredMillis)
def occurredDate = new Date(occurredMillis)
+
def receivedDate = new Date(receivedMillis)
}
StdConverters.AllConverters.convertEx[WalletEntry](JsonTextFormat(json))
}
- def zero = WalletEntry("", 1L, 1L, Nil,1,"","foo", "bar", "0", false)
+ def zero = WalletEntry("", 1L, 1L, Nil, 1, "", "foo", "bar", "0", false)
object JsonNames {
final val _id = "_id"
final val instanceId = "instanceId"
final val finalized = "finalized"
}
+
}
\ No newline at end of file