Implement Once behavior with the new scheme. Refactor in the process
[aquarium] / src / main / scala / gr / grnet / aquarium / charging / state / WorkingAgreementHistory.scala
index 2039a25..80aeff5 100644 (file)
@@ -38,6 +38,7 @@ package gr.grnet.aquarium.charging.state
 import scala.collection.immutable
 import gr.grnet.aquarium.policy.{PolicyDefinedFullPriceTableRef, StdUserAgreement, UserAgreementModel}
 import gr.grnet.aquarium.util.json.JsonSupport
+import gr.grnet.aquarium.logic.accounting.dsl.Timeslot
 
 /**
  *
@@ -46,9 +47,11 @@ import gr.grnet.aquarium.util.json.JsonSupport
 
 final case class WorkingAgreementHistory(
     var agreements: immutable.SortedSet[UserAgreementModel] = immutable.SortedSet[UserAgreementModel]()
-) extends JsonSupport {
+) extends AgreementHistoryModel with JsonSupport {
 
-  def size = agreements.size
+  def agreementByTimeslot: immutable.SortedMap[Timeslot, UserAgreementModel] = {
+    immutable.TreeMap(agreements.map(ag ⇒ (ag.timeslot, ag)).toSeq: _*)
+  }
 
   def setFrom(that: WorkingAgreementHistory): this.type = {
     this.agreements = that.agreements