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); } }