@Test(expected = IllegalArgumentException.class) public void testValidateWrongType() { validator.validate(EntityNames.ASSESSMENT, new HashSet<String>(Arrays.asList("Jomolungma"))); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.COHORT, entityType, ids)) { return new HashSet<String>(); } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { basicQuery.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } Set<String> myCohortIds = new HashSet<String>(); Iterable<Entity> scas = getRepo().findAll(EntityNames.STAFF_COHORT_ASSOCIATION, basicQuery); for (Entity sca : scas) { Map<String, Object> body = sca.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, true)) { myCohortIds.add((String) body.get(ParameterConstants.COHORT_ID)); } } myCohortIds.retainAll(ids); return myCohortIds; }
GenericToCohortValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.COHORT, entityType, ids)) { return new HashSet<String>(); } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { basicQuery.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } Set<String> myCohortIds = new HashSet<String>(); Iterable<Entity> scas = getRepo().findAll(EntityNames.STAFF_COHORT_ASSOCIATION, basicQuery); for (Entity sca : scas) { Map<String, Object> body = sca.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, true)) { myCohortIds.add((String) body.get(ParameterConstants.COHORT_ID)); } } myCohortIds.retainAll(ids); return myCohortIds; } }
GenericToCohortValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.COHORT, entityType, ids)) { return new HashSet<String>(); } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { basicQuery.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } Set<String> myCohortIds = new HashSet<String>(); Iterable<Entity> scas = getRepo().findAll(EntityNames.STAFF_COHORT_ASSOCIATION, basicQuery); for (Entity sca : scas) { Map<String, Object> body = sca.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, true)) { myCohortIds.add((String) body.get(ParameterConstants.COHORT_ID)); } } myCohortIds.retainAll(ids); return myCohortIds; }  }
GenericToCohortValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.COHORT, entityType, ids)) { return new HashSet<String>(); } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { basicQuery.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } Set<String> myCohortIds = new HashSet<String>(); Iterable<Entity> scas = getRepo().findAll(EntityNames.STAFF_COHORT_ASSOCIATION, basicQuery); for (Entity sca : scas) { Map<String, Object> body = sca.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, true)) { myCohortIds.add((String) body.get(ParameterConstants.COHORT_ID)); } } myCohortIds.retainAll(ids); return myCohortIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
GenericToCohortValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.COHORT, entityType, ids)) { return new HashSet<String>(); } NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { basicQuery.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } Set<String> myCohortIds = new HashSet<String>(); Iterable<Entity> scas = getRepo().findAll(EntityNames.STAFF_COHORT_ASSOCIATION, basicQuery); for (Entity sca : scas) { Map<String, Object> body = sca.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, true)) { myCohortIds.add((String) body.get(ParameterConstants.COHORT_ID)); } } myCohortIds.retainAll(ids); return myCohortIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }