protected
def resolveEffectiveAlgorithmsAndPriceLists(alignedTimeslot: Timeslot,
agreement: DSLAgreement,
- clogM: Maybe[ContextualLogger] = NoVal): (Map[Timeslot, DSLAlgorithm], Map[Timeslot, DSLPriceList]) = {
+ clogOpt: Option[ContextualLogger] = None):
+ (Map[Timeslot, DSLAlgorithm], Map[Timeslot, DSLPriceList]) = {
- val clog = ContextualLogger.fromOther(clogM, logger, "resolveEffectiveAlgorithmsAndPriceLists()")
+ val clog = ContextualLogger.fromOther(clogOpt, logger, "resolveEffectiveAlgorithmsAndPriceLists()")
// Note that most of the code is taken from calcChangeChunks()
val alg = resolveEffectiveAlgorithmsForTimeslot(alignedTimeslot, agreement)
dslResource: DSLResource,
policiesByTimeslot: Map[Timeslot, DSLPolicy],
agreementNamesByTimeslot: Map[Timeslot, String],
- contextualLogger: Maybe[ContextualLogger] = NoVal): Maybe[List[Chargeslot]] = Maybe {
+ clogOpt: Option[ContextualLogger] = None): Maybe[List[Chargeslot]] = Maybe {
- val clog = ContextualLogger.fromOther(contextualLogger, logger, "computeInitialChargeslots()")
+ val clog = ContextualLogger.fromOther(clogOpt, logger, "computeInitialChargeslots()")
// clog.begin()
val policyTimeslots = policiesByTimeslot.keySet
// TODO: Factor this out, just like we did with:
// TODO: val alignedTimeslots = splitTimeslotByPoliciesAndAgreements
// Note that most of the code is already taken from calcChangeChunks()
- val r = resolveEffectiveAlgorithmsAndPriceLists(alignedTimeslot, agreement, Just(clog))
+ val r = resolveEffectiveAlgorithmsAndPriceLists(alignedTimeslot, agreement, Some(clog))
val algorithmByTimeslot: Map[Timeslot, DSLAlgorithm] = r._1
val pricelistByTimeslot: Map[Timeslot, DSLPriceList] = r._2
agreementNamesByTimeslot: Map[Timeslot, String],
algorithmCompiler: CostPolicyAlgorithmCompiler,
policyStore: PolicyStore,
- contextualLogger: Maybe[ContextualLogger] = NoVal): Maybe[(Timeslot, List[Chargeslot])] = Maybe {
+ clogOpt: Option[ContextualLogger] = None): Maybe[(Timeslot, List[Chargeslot])] = Maybe {
- val clog = ContextualLogger.fromOther(contextualLogger, logger, "computeFullChargeslots()")
+ val clog = ContextualLogger.fromOther(clogOpt, logger, "computeFullChargeslots()")
// clog.begin()
val occurredDate = currentResourceEvent.occurredDate
dslResource,
relevantPolicies,
agreementNamesByTimeslot,
- Just(clog)
+ Some(clog)
)
val fullChargeslotsM = initialChargeslotsM.map { chargeslots ⇒
accounting: Accounting,
algorithmCompiler: CostPolicyAlgorithmCompiler,
calculationReason: UserStateChangeReason,
- contextualLogger: Maybe[ContextualLogger] = NoVal): Maybe[UserState] = {
+ clogOpt: Option[ContextualLogger] = None): Maybe[UserState] = {
val clog = ContextualLogger.fromOther(
- contextualLogger,
+ clogOpt,
logger,
"findUserStateAtEndOfBillingMonth(%s)", billingMonthInfo)
clog.begin()
accounting,
algorithmCompiler,
calculationReason,
- Just(clog))
+ Some(clog))
}
val userStateStore = storeProvider.userStateStore
billingMonthInfo: BillingMonthInfo,
walletEntriesBuffer: mutable.Buffer[NewWalletEntry],
algorithmCompiler: CostPolicyAlgorithmCompiler,
- clogM: Maybe[ContextualLogger] = NoVal): UserState = {
+ clogOpt: Option[ContextualLogger] = None): UserState = {
- val clog = ContextualLogger.fromOther(clogM, logger, "walletEntriesForResourceEvent(%s)", currentResourceEvent.id)
+ val clog = ContextualLogger.fromOther(clogOpt, logger, "walletEntriesForResourceEvent(%s)", currentResourceEvent.id)
var _workingUserState = startingUserState
alltimeAgreements,
algorithmCompiler,
policyStore,
- Just(clog)
+ Some(clog)
)
// We have the chargeslots, let's associate them with the current event
billingMonthInfo: BillingMonthInfo,
walletEntriesBuffer: mutable.Buffer[NewWalletEntry],
algorithmCompiler: CostPolicyAlgorithmCompiler,
- clogM: Maybe[ContextualLogger] = NoVal): UserState = {
+ clogOpt: Option[ContextualLogger] = None): UserState = {
var _workingUserState = startingUserState
billingMonthInfo,
walletEntriesBuffer,
algorithmCompiler,
- clogM
+ clogOpt
)
}
accounting: Accounting,
algorithmCompiler: CostPolicyAlgorithmCompiler,
calculationReason: UserStateChangeReason = NoSpecificChangeReason,
- contextualLogger: Maybe[ContextualLogger] = NoVal): Maybe[UserState] = Maybe {
+ clogOpt: Option[ContextualLogger] = None): Maybe[UserState] = Maybe {
val clog = ContextualLogger.fromOther(
- contextualLogger,
+ clogOpt,
logger,
"doFullMonthlyBilling(%s)", billingMonthInfo)
clog.begin()
- val clogJ = Just(clog)
+ val clogSome = Some(clog)
val previousBillingMonthUserStateM = findUserStateAtEndOfBillingMonth(
userId,
accounting,
algorithmCompiler,
calculationReason.forPreviousBillingMonth,
- clogJ
+ clogSome
)
if(previousBillingMonthUserStateM.isNoVal) {
billingMonthInfo,
newWalletEntries,
algorithmCompiler,
- clogJ
+ clogSome
)
// Second, for the remaining events which must contribute an implicit OFF, we collect those OFFs
billingMonthInfo,
newWalletEntries,
algorithmCompiler,
- clogJ
+ clogSome
)
val lastUpdateTime = TimeHelpers.nowMillis()
}
}
- def fromOther(clogM: Maybe[ContextualLogger], logger: Logger, fmt: String, args: Any*): ContextualLogger = {
- clogM match {
- case Just(clog) ⇒
+ def fromOther(clogOpt: Option[ContextualLogger], logger: Logger, fmt: String, args: Any*): ContextualLogger = {
+ clogOpt match {
+ case Some(clog) ⇒
new ContextualLogger(clog.logger, fmt, args:_*).indentAs(clog)
- case _ ⇒
+
+ case None ⇒
new ContextualLogger(logger, fmt, args:_*)
}
}
DefaultAccounting,
DefaultCompiler,
MonthlyBillingCalculation(billingMonthInfo),
- Just(clog)
+ Some(clog)
)
}
@Ignore
@Test
def testFullOnOff: Unit = {
- val clog = ContextualLogger.fromOther(NoVal, logger, "testFullOnOff()")
+ val clog = ContextualLogger.fromOther(None, logger, "testFullOnOff()")
clog.begin()
ResourceEventStore.clearResourceEvents()
@Ignore
@Test
def testLonelyON: Unit = {
- val clog = ContextualLogger.fromOther(NoVal, logger, "testLonelyON()")
+ val clog = ContextualLogger.fromOther(None, logger, "testLonelyON()")
clog.begin()
ResourceEventStore.clearResourceEvents()
// @Ignore
@Test
def testOrphanOFF: Unit = {
- val clog = ContextualLogger.fromOther(NoVal, logger, "testOrphanOFF()")
+ val clog = ContextualLogger.fromOther(None, logger, "testOrphanOFF()")
clog.begin()
ResourceEventStore.clearResourceEvents()
@Ignore
@Test
def testOne: Unit = {
- val clog = ContextualLogger.fromOther(NoVal, logger, "testOne()")
+ val clog = ContextualLogger.fromOther(None, logger, "testOne()")
clog.begin()
// Let's create our dates of interest