@Test public void testNullTeacherSchoolAssociation() throws Exception { assertTrue(validator.validate(EntityNames.TEACHER_SCHOOL_ASSOCIATION, null).isEmpty()); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSchoolAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> schools = new HashMap<String, Set<String>>(); if (teacherSchoolAssociations != null) { for (Entity teacherSchoolAssociation : teacherSchoolAssociations) { Map<String, Object> body = teacherSchoolAssociation.getBody(); String school = (String) body.get("schoolId"); if (!schools.containsKey(school)) { schools.put(school, new HashSet<String>()); } schools.get(school).add(teacherSchoolAssociation.getEntityId()); } } if (schools.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSchools = validator.validate(EntityNames.EDUCATION_ORGANIZATION, schools.keySet()); return getValidIds(validSchools, schools); }
StaffToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSchoolAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> schools = new HashMap<String, Set<String>>(); if (teacherSchoolAssociations != null) { for (Entity teacherSchoolAssociation : teacherSchoolAssociations) { Map<String, Object> body = teacherSchoolAssociation.getBody(); String school = (String) body.get("schoolId"); if (!schools.containsKey(school)) { schools.put(school, new HashSet<String>()); } schools.get(school).add(teacherSchoolAssociation.getEntityId()); } } if (schools.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSchools = validator.validate(EntityNames.EDUCATION_ORGANIZATION, schools.keySet()); return getValidIds(validSchools, schools); } }
StaffToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSchoolAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> schools = new HashMap<String, Set<String>>(); if (teacherSchoolAssociations != null) { for (Entity teacherSchoolAssociation : teacherSchoolAssociations) { Map<String, Object> body = teacherSchoolAssociation.getBody(); String school = (String) body.get("schoolId"); if (!schools.containsKey(school)) { schools.put(school, new HashSet<String>()); } schools.get(school).add(teacherSchoolAssociation.getEntityId()); } } if (schools.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSchools = validator.validate(EntityNames.EDUCATION_ORGANIZATION, schools.keySet()); return getValidIds(validSchools, schools); }  }
StaffToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSchoolAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> schools = new HashMap<String, Set<String>>(); if (teacherSchoolAssociations != null) { for (Entity teacherSchoolAssociation : teacherSchoolAssociations) { Map<String, Object> body = teacherSchoolAssociation.getBody(); String school = (String) body.get("schoolId"); if (!schools.containsKey(school)) { schools.put(school, new HashSet<String>()); } schools.get(school).add(teacherSchoolAssociation.getEntityId()); } } if (schools.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSchools = validator.validate(EntityNames.EDUCATION_ORGANIZATION, schools.keySet()); return getValidIds(validSchools, schools); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
StaffToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSchoolAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> schools = new HashMap<String, Set<String>>(); if (teacherSchoolAssociations != null) { for (Entity teacherSchoolAssociation : teacherSchoolAssociations) { Map<String, Object> body = teacherSchoolAssociation.getBody(); String school = (String) body.get("schoolId"); if (!schools.containsKey(school)) { schools.put(school, new HashSet<String>()); } schools.get(school).add(teacherSchoolAssociation.getEntityId()); } } if (schools.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSchools = validator.validate(EntityNames.EDUCATION_ORGANIZATION, schools.keySet()); return getValidIds(validSchools, schools); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }