public boolean canBeActive(Long campaignId, User user) { final Campaign activeCampaign = getActiveCampaign(user); if (activeCampaign != null && !activeCampaign.getId().equals(campaignId)) { return false; } else { return true; } }
public void delete(long id) { final EntityManager em = emProvider.get(); final Campaign campaign = em.find(Campaign.class, id); em.getTransaction().begin(); if (campaign != null) { campaign.getOwner().getCampaigns().remove(campaign); em.merge(campaign.getOwner()); em.remove(campaign); } em.getTransaction().commit(); }