@Test public void testSeaAdministratorCanGetAccessToTeacherSectionAssociation() throws Exception { setContext(seaStaff, Arrays.asList(SecureRoleRightAccessImpl.SEA_ADMINISTRATOR)); Set<String> teacherSectionAssociations = new HashSet<String>(); teacherSectionAssociations.add(teacherSectionAssociation.getEntityId()); assertTrue(validator.validate(EntityNames.TEACHER_SECTION_ASSOCIATION, teacherSectionAssociations).equals(teacherSectionAssociations)); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SECTION_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSectionAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> sections = new HashMap<String, Set<String>>(); if (teacherSectionAssociations != null) { for (Entity teacherSectionAssociation : teacherSectionAssociations) { Map<String, Object> body = teacherSectionAssociation.getBody(); String section = (String) body.get(ParameterConstants.SECTION_ID); if (!sections.containsKey(section)) { sections.put(section, new HashSet<String>()); } sections.get(section).add(teacherSectionAssociation.getEntityId()); } } if (sections.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSections = validator.validate(EntityNames.SECTION, sections.keySet()); return getValidIds(validSections, sections); }
StaffToTeacherSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SECTION_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSectionAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> sections = new HashMap<String, Set<String>>(); if (teacherSectionAssociations != null) { for (Entity teacherSectionAssociation : teacherSectionAssociations) { Map<String, Object> body = teacherSectionAssociation.getBody(); String section = (String) body.get(ParameterConstants.SECTION_ID); if (!sections.containsKey(section)) { sections.put(section, new HashSet<String>()); } sections.get(section).add(teacherSectionAssociation.getEntityId()); } } if (sections.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSections = validator.validate(EntityNames.SECTION, sections.keySet()); return getValidIds(validSections, sections); } }
StaffToTeacherSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SECTION_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSectionAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> sections = new HashMap<String, Set<String>>(); if (teacherSectionAssociations != null) { for (Entity teacherSectionAssociation : teacherSectionAssociations) { Map<String, Object> body = teacherSectionAssociation.getBody(); String section = (String) body.get(ParameterConstants.SECTION_ID); if (!sections.containsKey(section)) { sections.put(section, new HashSet<String>()); } sections.get(section).add(teacherSectionAssociation.getEntityId()); } } if (sections.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSections = validator.validate(EntityNames.SECTION, sections.keySet()); return getValidIds(validSections, sections); }  }
StaffToTeacherSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SECTION_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSectionAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> sections = new HashMap<String, Set<String>>(); if (teacherSectionAssociations != null) { for (Entity teacherSectionAssociation : teacherSectionAssociations) { Map<String, Object> body = teacherSectionAssociation.getBody(); String section = (String) body.get(ParameterConstants.SECTION_ID); if (!sections.containsKey(section)) { sections.put(section, new HashSet<String>()); } sections.get(section).add(teacherSectionAssociation.getEntityId()); } } if (sections.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSections = validator.validate(EntityNames.SECTION, sections.keySet()); return getValidIds(validSections, sections); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
StaffToTeacherSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SECTION_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> teacherSectionAssociations = getRepo().findAll(entityType, query); Map<String, Set<String>> sections = new HashMap<String, Set<String>>(); if (teacherSectionAssociations != null) { for (Entity teacherSectionAssociation : teacherSectionAssociations) { Map<String, Object> body = teacherSectionAssociation.getBody(); String section = (String) body.get(ParameterConstants.SECTION_ID); if (!sections.containsKey(section)) { sections.put(section, new HashSet<String>()); } sections.get(section).add(teacherSectionAssociation.getEntityId()); } } if (sections.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validSections = validator.validate(EntityNames.SECTION, sections.keySet()); return getValidIds(validSections, sections); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }