@Test(expected = IllegalArgumentException.class) public void testValidateWrongType() { val.validate(EntityNames.ASSESSMENT, new HashSet<String>(Arrays.asList("Jomolungma"))); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "=", SecurityUtil .getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); List<String> schools = new ArrayList<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { schools.add((String) e.getBody().get(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE)); } } nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE, "in", schools)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "in", ids)); tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); Set<String> validIds = new HashSet<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { validIds.add(e.getBody().get(ParameterConstants.STAFF_REFERENCE).toString()); } } validIds.add(SecurityUtil.getSLIPrincipal().getEntity().getEntityId()); validIds.retainAll(ids); return validIds; }
TransitiveTeacherToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "=", SecurityUtil .getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); List<String> schools = new ArrayList<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { schools.add((String) e.getBody().get(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE)); } } nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE, "in", schools)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "in", ids)); tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); Set<String> validIds = new HashSet<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { validIds.add(e.getBody().get(ParameterConstants.STAFF_REFERENCE).toString()); } } validIds.add(SecurityUtil.getSLIPrincipal().getEntity().getEntityId()); validIds.retainAll(ids); return validIds; } }
TransitiveTeacherToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "=", SecurityUtil .getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); List<String> schools = new ArrayList<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { schools.add((String) e.getBody().get(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE)); } } nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE, "in", schools)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "in", ids)); tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); Set<String> validIds = new HashSet<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { validIds.add(e.getBody().get(ParameterConstants.STAFF_REFERENCE).toString()); } } validIds.add(SecurityUtil.getSLIPrincipal().getEntity().getEntityId()); validIds.retainAll(ids); return validIds; }  }
TransitiveTeacherToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "=", SecurityUtil .getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); List<String> schools = new ArrayList<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { schools.add((String) e.getBody().get(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE)); } } nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE, "in", schools)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "in", ids)); tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); Set<String> validIds = new HashSet<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { validIds.add(e.getBody().get(ParameterConstants.STAFF_REFERENCE).toString()); } } validIds.add(SecurityUtil.getSLIPrincipal().getEntity().getEntityId()); validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
TransitiveTeacherToTeacherValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "=", SecurityUtil .getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); List<String> schools = new ArrayList<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { schools.add((String) e.getBody().get(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE)); } } nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_REFERENCE, "in", schools)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, "in", ids)); tsa = getRepo().findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, nq); Set<String> validIds = new HashSet<String>(); for (Entity e : tsa) { if (!isFieldExpired(e.getBody(), ParameterConstants.END_DATE, false)) { validIds.add(e.getBody().get(ParameterConstants.STAFF_REFERENCE).toString()); } } validIds.add(SecurityUtil.getSLIPrincipal().getEntity().getEntityId()); validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }