import gr.grnet.aquarium.converter.{JsonTextFormat, StdConverters}
import gr.grnet.aquarium.AquariumException
import gr.grnet.aquarium.event.im.IMEventModel
+import org.bson.types.ObjectId
/**
* This is communicated to Aquarium from the `IM` system.
*
*
- * @param userId
+ * @param userID
* The user ID. $communicatedByIM
* @param userCreationMillis
* When the user was created.
* @author Christos KK Loverdos <loverdos@gmail.com>
*/
case class UserState(
- userId: String,
+ userID: String,
userCreationMillis: Long,
// The user state we used to compute this one. Normally the (cached)
// state at the beginning of the billing period.
parentUserStateId: Option[String] = None,
- id: String = ""
+ _id: ObjectId = new ObjectId()
) extends JsonSupport {
private[this] def _allSnapshots: List[Long] = {
def newestSnapshotTime: Long = _allSnapshots max
- def _id = id
def idOpt: Option[String] = _id match {
case null ⇒ None
- case "" ⇒ None
- case _id ⇒ Some(_id)
+ case _id ⇒ Some(_id.toString)
}
// def userCreationDate = new Date(userCreationMillis)
case snapshot @ AgreementSnapshot(data, _) ⇒
snapshot.getAgreement(at)
case _ ⇒
- Failed(new AquariumException("No agreement snapshot found for user %s".format(userId)))
+ Failed(new AquariumException("No agreement snapshot found for user %s".format(userID)))
}
}
object JsonNames {
final val _id = "_id"
- final val userId = "userId"
+ final val userID = "userID"
}
}