@Test public void testExpiredTeacher() { setupCurrentUser(staff1); helper.generateStaffEdorg(teacher1.getEntityId(), school1.getEntityId(), true); Set<String> teacher = new HashSet<String>(Arrays.asList(teacher1.getEntityId())); assertFalse(validator.validate(EntityNames.TEACHER, teacher).equals(teacher)); helper.generateStaffEdorg(teacher1.getEntityId(), school1.getEntityId(), false); teacher = new HashSet<String>(Arrays.asList(teacher1.getEntityId())); assertTrue(validator.validate(EntityNames.TEACHER, teacher).equals(teacher)); }
@Override public Set<String> validate(String entityName, Set<String> teacherIds) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityName, teacherIds)) { return Collections.EMPTY_SET; } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.CRITERIA_IN, teacherIds)); Iterable<Entity> schoolAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> teacherSchoolMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(teacherSchoolMap, schoolAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); Set<String> validTeacherIds = new HashSet<String>(); for (String teacher : teacherSchoolMap.keySet()) { Set<String> tmpSet = new HashSet<String>(teacherSchoolMap.get(teacher)); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validTeacherIds.add(teacher); } } return validTeacherIds; }
StaffToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> teacherIds) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityName, teacherIds)) { return Collections.EMPTY_SET; } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.CRITERIA_IN, teacherIds)); Iterable<Entity> schoolAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> teacherSchoolMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(teacherSchoolMap, schoolAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); Set<String> validTeacherIds = new HashSet<String>(); for (String teacher : teacherSchoolMap.keySet()) { Set<String> tmpSet = new HashSet<String>(teacherSchoolMap.get(teacher)); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validTeacherIds.add(teacher); } } return validTeacherIds; } }
StaffToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> teacherIds) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityName, teacherIds)) { return Collections.EMPTY_SET; } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.CRITERIA_IN, teacherIds)); Iterable<Entity> schoolAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> teacherSchoolMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(teacherSchoolMap, schoolAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); Set<String> validTeacherIds = new HashSet<String>(); for (String teacher : teacherSchoolMap.keySet()) { Set<String> tmpSet = new HashSet<String>(teacherSchoolMap.get(teacher)); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validTeacherIds.add(teacher); } } return validTeacherIds; }  }
StaffToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> teacherIds) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityName, teacherIds)) { return Collections.EMPTY_SET; } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.CRITERIA_IN, teacherIds)); Iterable<Entity> schoolAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> teacherSchoolMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(teacherSchoolMap, schoolAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); Set<String> validTeacherIds = new HashSet<String>(); for (String teacher : teacherSchoolMap.keySet()) { Set<String> tmpSet = new HashSet<String>(teacherSchoolMap.get(teacher)); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validTeacherIds.add(teacher); } } return validTeacherIds; }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> teacherIds); @Override SecurityUtil.UserContext getContext(); }
StaffToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> teacherIds) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityName, teacherIds)) { return Collections.EMPTY_SET; } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.CRITERIA_IN, teacherIds)); Iterable<Entity> schoolAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> teacherSchoolMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(teacherSchoolMap, schoolAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); Set<String> validTeacherIds = new HashSet<String>(); for (String teacher : teacherSchoolMap.keySet()) { Set<String> tmpSet = new HashSet<String>(teacherSchoolMap.get(teacher)); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validTeacherIds.add(teacher); } } return validTeacherIds; }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> teacherIds); @Override SecurityUtil.UserContext getContext();  }