Capture timestamp semantics with a better name.
authorChristos KK Loverdos <loverdos@gmail.com>
Thu, 29 Dec 2011 09:04:14 +0000 (11:04 +0200)
committerChristos KK Loverdos <loverdos@gmail.com>
Thu, 29 Dec 2011 13:13:10 +0000 (15:13 +0200)
src/main/scala/gr/grnet/aquarium/logic/events/AquariumEvent.scala
src/main/scala/gr/grnet/aquarium/logic/events/ResourceEvent.scala
src/main/scala/gr/grnet/aquarium/logic/events/UserEvent.scala
src/main/scala/gr/grnet/aquarium/logic/events/WalletEntry.scala
src/main/scala/gr/grnet/aquarium/store/mongodb/MongoDBStore.scala

index ce4a5b7..6e50e78 100644 (file)
@@ -48,7 +48,7 @@ import util.{Loggable, shortClassNameOf}
  * @author Christos KK Loverdos <loverdos@gmail.com>
  */
 
-abstract class AquariumEvent(val id: String, val timestamp: Long)
+abstract class AquariumEvent(val id: String, val occurredMillis: Long)
   extends JsonSupport with XmlSupport with Loggable {
 
   def validate: Boolean
index cf6a163..5555133 100644 (file)
@@ -50,12 +50,12 @@ case class ResourceEvent(
   userId: String,
   clientId: String,
   resource: String,
-  override val timestamp: Long,
+  override val occurredMillis: Long,
   eventVersion: String,
   value: Float,
   var aqTimestamp: Long = 0,
   details: Map[String, String]
-) extends AquariumEvent(id, timestamp) {
+) extends AquariumEvent(id, occurredMillis) {
 
   def validate() : Boolean = {
 
index 850f8ab..2c475c1 100644 (file)
@@ -12,7 +12,7 @@ import com.ckkloverdos.maybe.{Failed, NoVal, Just}
  */
 case class UserEvent(
   override val id: String,
-  override val timestamp: Long,
+  override val occurredMillis: Long,
   var aqTimestamp: Long = 0,
   userId: String,
   eventVersion: Short,
@@ -21,7 +21,7 @@ case class UserEvent(
   idp: String,
   tenant: String,
   roles: Array[String]
-  ) extends AquariumEvent(id, timestamp) {
+  ) extends AquariumEvent(id, occurredMillis) {
 
   assert(eventType == 1 || eventType == 2)
   assert(state.equalsIgnoreCase("ACTIVE") ||
index bad3968..a5c84fd 100644 (file)
@@ -6,17 +6,18 @@ import net.liftweb.json._
 /**
  *
  * @author Georgios Gousios <gousiosg@gmail.com>
+ * @author Christos KK Loverdos <loverdos@gmail.com>
  */
 case class WalletEntry(override val id: String,
-                       override val timestamp: Long,
-                       related: Array[String],
+                       override val occurredMillis: Long,
+                       sourceEventIDs: Array[String], // The events that triggered this WalletEntry
                        value: Float,
                        reason: String,
                        userId: String,
                        finalized: Boolean)
-  extends AquariumEvent(id, timestamp) {
+  extends AquariumEvent(id, occurredMillis) {
 
-  assert(timestamp > 0)
+  assert(occurredMillis > 0)
   assert(value > 0F)
   assert(!userId.isEmpty)
 
index b6eec47..d3150d8 100644 (file)
@@ -184,14 +184,14 @@ class MongoDBStore(
   }
 
   private[this] def _sortByTimestampAsc[A <: AquariumEvent](one: A, two: A): Boolean = {
-    if (one.timestamp > two.timestamp) false
-    else if (one.timestamp < two.timestamp) true
+    if (one.occurredMillis > two.occurredMillis) false
+    else if (one.occurredMillis < two.occurredMillis) true
     else true
   }
 
   private[this] def _sortByTimestampDesc[A <: AquariumEvent](one: A, two: A): Boolean = {
-    if (one.timestamp < two.timestamp) false
-    else if (one.timestamp > two.timestamp) true
+    if (one.occurredMillis < two.occurredMillis) false
+    else if (one.occurredMillis > two.occurredMillis) true
     else true
   }