ResourceRepo mapping = repo.removeResource(resource); entityManager.remove(mapping);
/** * Unsubscribes the resource from a repo, if it exists. If it was already subscribed, the mapping that was * removed is returned; if not, <code>null</code> is returned. * * @param repo the repo to unsubscribe from * * @return the mapping that was removed or <code>null</code> if the resource was not subscribed to the repo */ public ResourceRepo removeRepo(Repo repo) { if ((this.resourceRepos == null) || (repo == null)) { return null; } ResourceRepo doomed = null; for (ResourceRepo rc : this.resourceRepos) { if (repo.equals(rc.getResourceRepoPK().getRepo())) { doomed = rc; repo.removeResource(this); break; } } if (doomed != null) { this.resourceRepos.remove(doomed); } if (this.resourceRepos.isEmpty()) { this.resourceRepos = null; } return doomed; }