/** * Remove set listener from all userroles (and parent) collections * * @param listener the set change listener to remove */ public static void removeUserrolesSetChangeListeners(Listener<SetChangeEventParams> listener) { User.getAllUsers() .stream() .forEach( (user) -> { ((User) user).removeUserroleSetChangeListener(listener); }); UserRoot.removeUsersSetChangeListeners(listener); }
/** * Add set listener to all userpermissions (and parent) collections * * @param listener the set change listener to add */ public static void addUserpermissionsSetChangeListeners(Listener<SetChangeEventParams> listener) { User.getAllUsers() .stream() .forEach( (user) -> { ((User) user).addUserpermissionSetChangeListener(listener); }); UserRoot.addUsersSetChangeListeners(listener); }
/** * Constructor - User. * * @param id the unique id for this entity * @param em - the entity manager for this entity type */ public User(int id, User.EM em) { super("User[" + Integer.toString(id) + "]", "user", em); this.id = id; root = UserRoot.get(); addRule(usernameRules, new UsernameMinRule()); addRule(usernameRules, new UsernameMaxRule()); addRule(usernameRules, new UsernameUniqueRule()); addRule(encodedpasswordRules, new EncodedpasswordMinRule()); addRule(encodedpasswordRules, new EncodedpasswordMaxRule()); addRule(usercodeRules, new UsercodeMinRule()); addRule(usercodeRules, new UsercodeMaxRule()); addRule(usercodeRules, new UsercodeUniqueRule()); userpermissions = new EntityReferenceFilterSet<>( instanceDescription() + ">Userpermissions", "user", getId(), Userpermission.EM.class); userpermissions.load(); userroles = new EntityReferenceFilterSet<>( instanceDescription() + ">Userroles", "user", getId(), Userrole.EM.class); userroles.load(); checkRulesAtLoad(new StringBuilder()); }
/** * Get the set of all Users. * * @return the set of all Users */ public static List<User> getAllUsers() { List<User> list = new ArrayList<>(); list.addAll(UserRoot.get().getUsers()); return list; }
@Override protected final void link2parent(User e, UserRoot parent) { parent.addUser(e); }