@Test public void testEducatorCanSeeSectionAtSchool() { setContext(educator1, Arrays.asList(SecureRoleRightAccessImpl.EDUCATOR)); Set<String> sectionIds = new HashSet<String>(); sectionIds.add(section1.getEntityId()); assertTrue(validator.validate(EntityNames.SECTION, sectionIds).equals(sectionIds)); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); query.addCriteria(new NeutralCriteria(ParameterConstants.SCHOOL_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); Set<String> validSections = new HashSet<String>(); if (ids.size() != getRepo().count(entityType, query)) { Iterable<String> sections = getRepo().findAllIds(entityType, query); validSections = Sets.newHashSet(sections); } else { validSections = ids; } return validSections; }
StaffToGlobalSectionValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); query.addCriteria(new NeutralCriteria(ParameterConstants.SCHOOL_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); Set<String> validSections = new HashSet<String>(); if (ids.size() != getRepo().count(entityType, query)) { Iterable<String> sections = getRepo().findAllIds(entityType, query); validSections = Sets.newHashSet(sections); } else { validSections = ids; } return validSections; } }
StaffToGlobalSectionValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); query.addCriteria(new NeutralCriteria(ParameterConstants.SCHOOL_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); Set<String> validSections = new HashSet<String>(); if (ids.size() != getRepo().count(entityType, query)) { Iterable<String> sections = getRepo().findAllIds(entityType, query); validSections = Sets.newHashSet(sections); } else { validSections = ids; } return validSections; }  }
StaffToGlobalSectionValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); query.addCriteria(new NeutralCriteria(ParameterConstants.SCHOOL_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); Set<String> validSections = new HashSet<String>(); if (ids.size() != getRepo().count(entityType, query)) { Iterable<String> sections = getRepo().findAllIds(entityType, query); validSections = Sets.newHashSet(sections); } else { validSections = ids; } return validSections; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
StaffToGlobalSectionValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); query.addCriteria(new NeutralCriteria(ParameterConstants.SCHOOL_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); Set<String> validSections = new HashSet<String>(); if (ids.size() != getRepo().count(entityType, query)) { Iterable<String> sections = getRepo().findAllIds(entityType, query); validSections = Sets.newHashSet(sections); } else { validSections = ids; } return validSections; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }