/** Unsubscribing a certain population amount from a certain subscription */ void unsubscribe (TariffSubscription subscription, int customerCount) { subscription.unsubscribe(customerCount); log.info(this.toString() + " " + subscription.getTariff().getPowerType().toString() + ": " + customerCount + " were unsubscribed from tariff " + subscription.getTariff().getId()); } }
private void updateSubscriptions () { int check = 0; for (Tariff tariff : allocations.keySet()) { int count = allocations.get(tariff); check += count; if (count < 0) { //unsubscribe TariffSubscription sub = getTariffSubscriptionRepo().findSubscriptionForTariffAndCustomer (tariff, customerInfo); sub.unsubscribe(-count); log.info("customer " + customerInfo.getName() + " unsubscribes " + -count + " from tariff " + tariff.getId()); } else if (count > 0) { // subscribe getTariffMarket().subscribeToTariff(tariff, customerInfo, count); log.info("customer " + customerInfo.getName() + " subscribes " + count + " to tariff " + tariff.getId()); } } // sanity check if (check != 0) { log.error("Subscription updates do not add up for " + customerInfo.getName() + ": " + check); } }