private TariffSubscription findSubscriptionForCustomer (List<TariffSubscription> subs, CustomerInfo customer) { if (subs == null) return null; for (TariffSubscription sub : subs) { if (sub.getCustomer() == customer) return sub; } return null; }
tariffSubscriptionRepo.findActiveSubscriptionsForBroker(broker); for (TariffSubscription sub: subs) { if (CustomerClass.LARGE == sub.getCustomer().getCustomerClass()) { nLarge += sub.getCustomersCommitted();
/** * Returns the subscription, if any, for the specified tariff and customer. * Does not create a subscription in case it cannot be found in the repo. */ public TariffSubscription findSubscriptionForTariffAndCustomer (Tariff tariff, CustomerInfo customer) { List<TariffSubscription> subs = findSubscriptionsForTariff(tariff); if (subs == null) return null; for (TariffSubscription sub : subs) { if (sub.getCustomer() == customer) return sub; } return null; }
/** * Removes all subscriptions for the given tariff. Presumably this is done * when the tariff has been revoked and all revocation processing is complete. */ public void removeSubscriptionsForTariff (Tariff tariff) { List<TariffSubscription> subs = tariffMap.get(tariff); if (null == subs) return; // first, remove the subscriptions from the customer map and broker map for (TariffSubscription sub : subs) { customerMap.get(sub.getCustomer()).remove(sub); } for (TariffSubscription sub : subs) { brokerMap.get(sub.getTariff().getBroker()).remove(sub); } // then clear out the tariff entry tariffMap.remove(tariff); }
/** Adds an existing subscription to the repo. */ public TariffSubscription add (TariffSubscription subscription) { storeSubscription(subscription, subscription.getCustomer(), subscription.getTariff()); return subscription; }
/** * Removes customerCount customers (at most) from this subscription, * posts early-withdrawal fees if appropriate. */ public void unsubscribe (int customerCount) { getTariffMarket().subscribeToTariff(getTariff(), getCustomer(), -customerCount); pendingUnsubscribeCount += customerCount; }
regulationAccumulator.getDownRegulationCapacity() * customersCommitted; if (0 == pendingUnsubscribeCount) { log.info("regulation capacity for " + getCustomer().getName() + ":" + this.getTariff().getId() + " (" + up + ", " + down + ")"); / customersCommitted; log.info("remaining regulation capacity for " + getCustomer().getName() + ":" + this.getTariff().getId() + " reduced by " + ratio + " to (" + up * ratio + ", " + down * ratio + ")");
private ProfileRecommendation getProfileRecommendationPerSub (CapacityOriginator capacityOriginator, CapacityBundle bundle, ForecastRecord forecastRecord, Map<CapacityOriginator, Map<TariffSubscription, List<CapacityProfile>>> permsPerSub, TariffSubscription sub) { logRecommendationDetails("getProfileRecommendationPerSub(" + sub.getCustomer().getName() + ", " + sub.getTariff().getId() + ") Forecast " + forecastRecord.capacityProfile + " usage charge = " + forecastRecord.usageCharge); ProfileRecommendation rec = new ProfileRecommendation(); for (CapacityProfile perm : permsPerSub.get(capacityOriginator).get(sub)) { double usageCharge = computeProfileUsageChargePerSub(perm, sub, capacityOriginator); if (isPermutationAcceptable(capacityOriginator, bundle.getOptimizerStructure(), usageCharge, forecastRecord.usageCharge)) { Opinion opinion = rec.new Opinion(); // avoid duplication opinion.usageCharge = usageCharge; opinion.profileChange = forecastRecord.capacityProfile.distanceTo(perm); rec.setOpinion(perm, opinion); } } if (!rec.isEmpty()) { computeDerivedValues(rec, bundle.getOptimizerStructure()); } return rec; }