@Override public void addRequiredAction(RequiredAction action) { for (UserRequiredActionEntity attr : user.getRequiredActions()) { if (attr.getAction().equals(action)) { return; } } UserRequiredActionEntity attr = new UserRequiredActionEntity(); attr.setAction(action); attr.setUser(user); em.persist(attr); user.getRequiredActions().add(attr); }
@Override public Set<RequiredAction> getRequiredActions() { Set<RequiredAction> result = new HashSet<RequiredAction>(); for (UserRequiredActionEntity attr : user.getRequiredActions()) { result.add(attr.getAction()); } return result; }
@Override public void removeRequiredAction(RequiredAction action) { Iterator<UserRequiredActionEntity> it = user.getRequiredActions().iterator(); while (it.hasNext()) { UserRequiredActionEntity attr = it.next(); if (attr.getAction().equals(action)) { it.remove(); em.remove(attr); } } }