@Test public void testCanValidateMultiple() { helper.generateTeacherSchool(ValidatorTestHelper.STAFF_ID, ValidatorTestHelper.ED_ORG_ID); for (int i = 0; i < 10; ++i) { Entity section = helper.generateSection(ValidatorTestHelper.ED_ORG_ID); helper.generateTSA(ValidatorTestHelper.STAFF_ID, section.getEntityId(), false); sectionIds.add(section.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> sectionIds = new HashSet<String>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.SECTION_ID, NeutralCriteria.CRITERIA_IN, ids)); query.addCriteria(new NeutralCriteria(ParameterConstants.TEACHER_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> associations = getRepo().findAll(EntityNames.TEACHER_SECTION_ASSOCIATION, query); if (associations != null) { for (Entity association : associations) { if (!dateHelper.isFieldExpired(association.getBody(), ParameterConstants.END_DATE)) { sectionIds.add((String) association.getBody().get(ParameterConstants.SECTION_ID)); } } } return sectionIds; }
TeacherToSectionValidator 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> sectionIds = new HashSet<String>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.SECTION_ID, NeutralCriteria.CRITERIA_IN, ids)); query.addCriteria(new NeutralCriteria(ParameterConstants.TEACHER_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> associations = getRepo().findAll(EntityNames.TEACHER_SECTION_ASSOCIATION, query); if (associations != null) { for (Entity association : associations) { if (!dateHelper.isFieldExpired(association.getBody(), ParameterConstants.END_DATE)) { sectionIds.add((String) association.getBody().get(ParameterConstants.SECTION_ID)); } } } return sectionIds; } }
TeacherToSectionValidator 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> sectionIds = new HashSet<String>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.SECTION_ID, NeutralCriteria.CRITERIA_IN, ids)); query.addCriteria(new NeutralCriteria(ParameterConstants.TEACHER_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> associations = getRepo().findAll(EntityNames.TEACHER_SECTION_ASSOCIATION, query); if (associations != null) { for (Entity association : associations) { if (!dateHelper.isFieldExpired(association.getBody(), ParameterConstants.END_DATE)) { sectionIds.add((String) association.getBody().get(ParameterConstants.SECTION_ID)); } } } return sectionIds; }  }
TeacherToSectionValidator 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> sectionIds = new HashSet<String>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.SECTION_ID, NeutralCriteria.CRITERIA_IN, ids)); query.addCriteria(new NeutralCriteria(ParameterConstants.TEACHER_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> associations = getRepo().findAll(EntityNames.TEACHER_SECTION_ASSOCIATION, query); if (associations != null) { for (Entity association : associations) { if (!dateHelper.isFieldExpired(association.getBody(), ParameterConstants.END_DATE)) { sectionIds.add((String) association.getBody().get(ParameterConstants.SECTION_ID)); } } } return sectionIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
TeacherToSectionValidator 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> sectionIds = new HashSet<String>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.SECTION_ID, NeutralCriteria.CRITERIA_IN, ids)); query.addCriteria(new NeutralCriteria(ParameterConstants.TEACHER_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); Iterable<Entity> associations = getRepo().findAll(EntityNames.TEACHER_SECTION_ASSOCIATION, query); if (associations != null) { for (Entity association : associations) { if (!dateHelper.isFieldExpired(association.getBody(), ParameterConstants.END_DATE)) { sectionIds.add((String) association.getBody().get(ParameterConstants.SECTION_ID)); } } } return sectionIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }