Hello,
I have two entities, User and Notice, each of which has a to-many relationship to Role called roles. The business rule here works as follows. Say Notice.roles contains two Roles, R1 and R2. If User.roles contains either R1 or R2, then the Notice is applicable to that User—that is, Notice.roles says that for each Role, the Notice applies to any User that has that Role.
I have a static method on Notice to return an NSArray<Notice> applicable to some supplied User. (There are other matching criteria, but this is the part I want to try and simplify.) At the moment, I’m doing this:
NSMutableArray<EOQualifier> roleQuals = new NSMutableArray<EOQualifier>(); for (Role r : user.roles()) { roleQuals.add(Notice.ROLES.containsObject(r)); } EOQualifier roleQual = ERXQ.or(roleQuals);
While this works, it seems awkward. Is there a way to create this qualifier (which is essentially looking for any match between User.roles and Notice.roles) in one step?
|