public void setSentiment(ExternalAccount externalAccount, Sentiment sentiment) { if ((sentiment == Sentiment.LOVE) && !externalAccount.hasAccountInfo()) { throw new RuntimeException( "Trying to set a love sentiment on account with no valid account info"); } externalAccount.setSentiment(sentiment); notifier.onExternalAccountLovedAndEnabledMaybeChanged( externalAccount.getAccount().getOwner(), externalAccount); }
public ExternalAccount getOrCreateExternalAccount( UserViewpoint viewpoint, ExternalAccountType type) { Account a = viewpoint.getViewer().getAccount(); if (!em.contains(a)) throw new RuntimeException("detached account in getOrCreateExternalAccount"); ExternalAccount external = a.getExternalAccount(type); if (external == null) { external = new ExternalAccount(type); external.setAccount(a); em.persist(external); a.getExternalAccounts().add(external); notifier.onExternalAccountCreated(a.getOwner(), external); } return external; }
public void onAccountAdminDisabledToggled(Account account) { for (ExternalAccount external : account.getExternalAccounts()) { // this is why we have "maybe changed" since we really don't know. notifier.onExternalAccountLovedAndEnabledMaybeChanged(account.getOwner(), external); } }