/*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
package gr.grnet.aquarium.store
-import com.ckkloverdos.maybe.Maybe
-import gr.grnet.aquarium.logic.events.ResourceEvent
+import gr.grnet.aquarium.AquariumException
+import gr.grnet.aquarium.event.model.resource.ResourceEventModel
/**
* An abstraction for Aquarium `ResourceEvent` stores.
* @author Georgios Gousios <gousiosg@gmail.com>.
*/
trait ResourceEventStore {
- def storeResourceEvent(event: ResourceEvent): Maybe[RecordID]
+ type ResourceEvent <: ResourceEventModel
- def findResourceEventById(id: String): Maybe[ResourceEvent]
+ def createResourceEventFromOther(event: ResourceEventModel): ResourceEvent
+
+ def clearResourceEvents(): Unit = {
+ throw new AquariumException("Unsupported operation")
+ }
+
+ def pingResourceEventStore(): Unit
+
+ def insertResourceEvent(event: ResourceEventModel): ResourceEvent
+
+ def findResourceEventById(id: String): Option[ResourceEvent]
def findResourceEventsByUserId(userId: String)(sortWith: Option[(ResourceEvent, ResourceEvent) => Boolean]): List[ResourceEvent]
instid: Option[String], upTo: Long) : List[ResourceEvent]
def findResourceEventsForReceivedPeriod(userId: String, startTimeMillis: Long, stopTimeMillis: Long): List[ResourceEvent]
+
+ /**
+ * Count and return the number of "out of sync" events for a billing month.
+ */
+ def countOutOfSyncEventsForBillingPeriod(userId: String, startMillis: Long, stopMillis: Long): Long
+
+ /**
+ * Finds all relevant resource events for the billing period.
+ * The relevant events are those:
+ * a) whose `occurredMillis` is within the given billing period or
+ * b) whose `receivedMillis` is within the given billing period.
+ *
+ * Order them by `occurredMillis`
+ * FIXME: implement
+ */
+ def findAllRelevantResourceEventsForBillingPeriod(userId: String,
+ startMillis: Long,
+ stopMillis: Long): List[ResourceEvent]
}
\ No newline at end of file