target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testValidate() { Assert.assertEquals(Collections.emptySet(), validator.validate(null, null)); Assert.assertEquals(Collections.emptySet(), validator.validate(new String(), new HashSet<String>())); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { return Collections.emptySet(); }
|
StudentDenyAllValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { return Collections.emptySet(); } }
|
StudentDenyAllValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { return Collections.emptySet(); } }
|
StudentDenyAllValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { return Collections.emptySet(); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentDenyAllValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { return Collections.emptySet(); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testCanValidate() { Assert.assertTrue(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, false)); Assert.assertTrue(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, true)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STUDENT_PROGRAM_ASSOCIATION.equals(entityType) && isTeacher(); }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STUDENT_PROGRAM_ASSOCIATION.equals(entityType) && isTeacher(); } }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STUDENT_PROGRAM_ASSOCIATION.equals(entityType) && isTeacher(); } }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STUDENT_PROGRAM_ASSOCIATION.equals(entityType) && isTeacher(); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STUDENT_PROGRAM_ASSOCIATION.equals(entityType) && isTeacher(); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testValidAccessTeacher() { Set<String> ids = new HashSet<String>(Arrays.asList(studentProgramAssoc1.getEntityId())); Assert.assertTrue(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, ids).equals(ids)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testInvalidAccessTeacher1() { Set<String> ids = new HashSet<String>(Arrays.asList(studentProgramAssoc2.getEntityId())); Assert.assertFalse(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, ids).equals(ids)); ids = new HashSet<String>(Arrays.asList(studentProgramAssoc3.getEntityId())); Assert.assertFalse(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, ids).equals(ids)); ids = new HashSet<String>(Arrays.asList(studentProgramAssoc4.getEntityId())); Assert.assertFalse(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, ids).equals(ids)); ids = new HashSet<String>(Arrays.asList(studentProgramAssoc5.getEntityId())); Assert.assertFalse(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, ids).equals(ids)); ids = new HashSet<String>( Arrays.asList(studentProgramAssoc1.getEntityId(), studentProgramAssoc3.getEntityId())); Assert.assertFalse(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, ids).equals(ids)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_PROGRAM_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery( new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); query.setIncludeFields(Arrays.asList(ParameterConstants.PROGRAM_ID)); Map<String, Set<String>> programIdsToSPA = new HashMap<String, Set<String>>(); Iterable<Entity> spas = getRepo().findAll(EntityNames.STUDENT_PROGRAM_ASSOCIATION, query); for (Entity spa : spas) { String programId = (String) spa.getBody().get(ParameterConstants.PROGRAM_ID); if (!programIdsToSPA.containsKey(programId)) { programIdsToSPA.put(programId, new HashSet<String>()); } programIdsToSPA.get(programId).add(spa.getEntityId()); } String teacherId = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.PROGRAM_ID, NeutralCriteria.CRITERIA_IN, programIdsToSPA.keySet())); nq.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, teacherId)); nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); Iterable<Entity> entities = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); Set<String> validProgramIds = new HashSet<String>(); for (Entity entity : entities) { String expireDate = (String) entity.getBody().get(ParameterConstants.END_DATE); if (expireDate == null || isLhsBeforeRhs(getNowMinusGracePeriod(), getDateTime(expireDate))) { validProgramIds.add((String) entity.getBody().get(ParameterConstants.PROGRAM_ID)); } } return getValidIds(validProgramIds, programIdsToSPA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidate() { assertTrue(validator.canValidate(EntityNames.DISCIPLINE_INCIDENT, true)); assertTrue(validator.canValidate(EntityNames.DISCIPLINE_INCIDENT, false)); assertFalse(validator.canValidate(EntityNames.ATTENDANCE, false)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return isTeacher() && EntityNames.DISCIPLINE_INCIDENT.equals(entityType); }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isTeacher() && EntityNames.DISCIPLINE_INCIDENT.equals(entityType); } }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isTeacher() && EntityNames.DISCIPLINE_INCIDENT.equals(entityType); } }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isTeacher() && EntityNames.DISCIPLINE_INCIDENT.equals(entityType); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isTeacher() && EntityNames.DISCIPLINE_INCIDENT.equals(entityType); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testValidIncident() { Set<String> ids = list(disciplineIncident1.getEntityId()); assertTrue(validator.validate(EntityNames.DISCIPLINE_INCIDENT, ids).equals(ids)); ids = list(disciplineIncident2.getEntityId()); assertTrue(validator.validate(EntityNames.DISCIPLINE_INCIDENT, ids).equals(ids)); ids = list(disciplineIncident1.getEntityId(), disciplineIncident2.getEntityId()); assertTrue(validator.validate(EntityNames.DISCIPLINE_INCIDENT, ids).equals(ids)); ids = list(disciplineIncident4.getEntityId()); assertTrue(validator.validate(EntityNames.DISCIPLINE_INCIDENT, ids).equals(ids)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testInvalidIncident() { Set<String> ids = list(disciplineIncident3.getEntityId()); assertFalse(validator.validate(EntityNames.DISCIPLINE_INCIDENT, ids).equals(ids)); ids = list(disciplineIncident3.getEntityId(), disciplineIncident1.getEntityId()); assertFalse(validator.validate(EntityNames.DISCIPLINE_INCIDENT, ids).equals(ids)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToDisciplineIncidentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.DISCIPLINE_INCIDENT, entityType, ids)) { return Collections.EMPTY_SET; } Set<String> discIncidentIds = new HashSet<String>(ids); String myself = SecurityUtil.getSLIPrincipal().getEntity().getEntityId(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.addCriteria(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, myself)); Iterable<Entity> incidents = getRepo().findAll(EntityNames.DISCIPLINE_INCIDENT, query); for (Entity ent : incidents) { discIncidentIds.remove(ent.getEntityId()); } if (discIncidentIds.size() == 0) { return ids; } query = new NeutralQuery(new NeutralCriteria(ParameterConstants.DISCIPLINE_INCIDENT_ID, NeutralCriteria.CRITERIA_IN, discIncidentIds)); query.setIncludeFields(Arrays.asList(ParameterConstants.STUDENT_ID, ParameterConstants.DISCIPLINE_INCIDENT_ID)); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, query); Map<String, Set<String>> discIncToStudents = new HashMap<String, Set<String>>(); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); String discIncId = (String) assoc.getBody().get(ParameterConstants.DISCIPLINE_INCIDENT_ID); Set<String> studentList = discIncToStudents.get(discIncId); if (studentList == null) { studentList = new HashSet<String>(); discIncToStudents.put(discIncId, studentList); } studentList.add(studentId); } Set<String> validIncidents = new HashSet<String>(ids); validIncidents.removeAll(discIncidentIds); for (String discIncId : discIncToStudents.keySet()) { Set<String> validStudent = studentValidator.validate(EntityNames.STUDENT, discIncToStudents.get(discIncId)); if (validStudent.size() > 0) { validIncidents.add(discIncId); } } return validIncidents; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToReportCard() { assertTrue(validator.canValidate(EntityNames.REPORT_CARD, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testInvalidLz() throws Exception { File validLzPathFile = new File("/test/lz/inbound/TEST-LZ/testFile.zip"); String validLzPathname = validLzPathFile.getParent(); List<String> testLzPaths = new ArrayList<String>(); testLzPaths.add(validLzPathname); when(mockedTenantDA.getLzPaths()).thenReturn(testLzPaths); File inValidLzPathFile = new File("/test/lz/inbound/BAD-TEST-LZ/testFile.zip"); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); exchange.getIn().setHeader("filePath", inValidLzPathFile.getPath()); landingZoneProcessor.process(exchange); assertTrue("Header on exchange should indicate failure", exchange.getIn().getBody(WorkNote.class).hasErrors()); }
|
@Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } @Override void process(Exchange exchange); }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } @Override void process(Exchange exchange); static final BatchJobStageType LZ_STAGE; }
|
@Test public void testCanValidateStaffToAttendance() throws Exception { assertTrue(validator.canValidate(EntityNames.ATTENDANCE, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToDisciplineAction() throws Exception { assertTrue(validator.canValidate(EntityNames.DISCIPLINE_ACTION, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentAcademicRecord() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_ACADEMIC_RECORD, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentAssessment() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_ASSESSMENT, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentDisciplineIncident() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_DISCIPLINE_INCIDENT_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentGradebookEntry() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_GRADEBOOK_ENTRY, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentParentAssociation() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_PARENT_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentSchoolAssociation() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_SCHOOL_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentSectionAssociation() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotValidateOtherEntities() throws Exception { assertFalse(validator.canValidate(EntityNames.STUDENT, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudent(entityType); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testNonZipFileInLz() throws Exception { File unzippedLzPathFile = new File("/test/lz/inbound/TEST-LZ/testFile.ctl"); String validLzPathname = unzippedLzPathFile.getParent(); List<String> testLzPaths = new ArrayList<String>(); testLzPaths.add(validLzPathname); when(mockedTenantDA.getLzPaths()).thenReturn(testLzPaths); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); exchange.getIn().setHeader("filePath", unzippedLzPathFile.getPath()); landingZoneProcessor.process(exchange); assertTrue("Header on exchange should indicate failure", exchange.getIn().getBody(WorkNote.class).hasErrors()); }
|
@Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } @Override void process(Exchange exchange); }
|
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); } @Override void process(Exchange exchange); static final BatchJobStageType LZ_STAGE; }
|
@Test public void testCanGetAccessToReportCard() { Set<String> studentIds = new HashSet<String>(); Set<String> reportCards = new HashSet<String>(); Map<String, Object> reportCard1 = buildReportCard("student123"); Entity reportCardEntity = new MongoEntity("reportCard", reportCard1); reportCards.add(reportCardEntity.getEntityId()); studentIds.add("student123"); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.REPORT_CARD), Mockito.any(NeutralQuery.class))).thenReturn(Arrays.asList(reportCardEntity)); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.REPORT_CARD, reportCards).equals(reportCards)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessToAttendance() throws Exception { Set<String> studentIds = new HashSet<String>(); Set<String> attendances = new HashSet<String>(); Map<String, Object> attendance1 = buildAttendanceForStudent("student123", "school123"); Entity attendanceEntity1 = new MongoEntity("attendance", attendance1); attendances.add(attendanceEntity1.getEntityId()); studentIds.add("student123"); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.ATTENDANCE), Mockito.any(NeutralQuery.class))).thenReturn( Arrays.asList(attendanceEntity1)); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.ATTENDANCE, attendances).equals(attendances)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessToAttendance() throws Exception { Set<String> attendances = new HashSet<String>(); Map<String, Object> attendance1 = buildAttendanceForStudent("student123", "school123"); Entity attendanceEntity1 = new MongoEntity("attendance", attendance1); attendances.add(attendanceEntity1.getEntityId()); studentIds.add("student123"); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.ATTENDANCE), Mockito.any(NeutralQuery.class))).thenReturn( Arrays.asList(attendanceEntity1)); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(Collections.EMPTY_SET); assertFalse(validator.validate(EntityNames.ATTENDANCE, attendances).equals(attendances)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessToCurrentStudentSchoolAssociation() throws Exception { Map<String, Object> goodStudentSchoolAssociation = buildStudentSchoolAssociation("student123", "school123", new DateTime().plusHours(1)); Entity association = new MongoEntity(EntityNames.STUDENT_SCHOOL_ASSOCIATION, goodStudentSchoolAssociation); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SCHOOL_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(association)); Set<String> associations = new HashSet<String>(); associations.add(association.getEntityId()); studentIds.add("student123"); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.STUDENT_SCHOOL_ASSOCIATION, associations).equals(associations)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessToStudentSchoolAssociationWithoutExitWithdrawDate() throws Exception { Map<String, Object> goodStudentSchoolAssociation = buildStudentSchoolAssociation("student123", "school123"); Entity association = new MongoEntity(EntityNames.STUDENT_SCHOOL_ASSOCIATION, goodStudentSchoolAssociation); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SCHOOL_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(association)); Set<String> associations = new HashSet<String>(); associations.add(association.getEntityId()); studentIds.add("student123"); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.STUDENT_SCHOOL_ASSOCIATION, associations).equals(associations)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testDeniedAccessToExpiredStudentSchoolAssociation() throws Exception { Map<String, Object> badStudentSchoolAssociation = buildStudentSchoolAssociation("student123", "school123", new DateTime().minusDays(1)); Entity association = new MongoEntity(EntityNames.STUDENT_SCHOOL_ASSOCIATION, badStudentSchoolAssociation); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SCHOOL_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(association)); Set<String> associations = new HashSet<String>(); associations.add(association.getEntityId()); assertTrue(validator.validate(EntityNames.STUDENT_SCHOOL_ASSOCIATION, associations).isEmpty()); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessToCurrentStudentSectionAssociation() throws Exception { Map<String, Object> goodStudentSectionAssociation = buildStudentSectionAssociation("student123", "section123", new DateTime().plusDays(1)); Entity association = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, goodStudentSectionAssociation); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SECTION_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(association)); Set<String> associations = new HashSet<String>(); associations.add(association.getEntityId()); studentIds.add("student123"); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.STUDENT_SECTION_ASSOCIATION, associations).equals(associations)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessToStudentSectionAssociationWithoutEndDate() throws Exception { Map<String, Object> goodStudentSectionAssociation = buildStudentSectionAssociation("student123", "section123"); Entity association = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, goodStudentSectionAssociation); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SECTION_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(association)); Set<String> associations = new HashSet<String>(); associations.add(association.getEntityId()); studentIds.add("student123"); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.STUDENT_SECTION_ASSOCIATION, associations).equals(associations)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testDeniedAccessToExpiredStudentSectionAssociation() throws Exception { Map<String, Object> badStudentSectionAssociation = buildStudentSchoolAssociation("student123", "section123", new DateTime().minusDays(1)); Entity association = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, badStudentSectionAssociation); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SECTION_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(association)); Set<String> associations = new HashSet<String>(); associations.add(association.getEntityId()); assertTrue(validator.validate(EntityNames.STUDENT_SECTION_ASSOCIATION, associations).isEmpty()); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentEntityValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> students = new HashMap<String, Set<String>>(); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, new ArrayList<String>(ids))); Iterable<Entity> entities = getRepo().findAll(entityType, query); if (entities != null) { for (Entity entity : entities) { Map<String, Object> body = entity.getBody(); Object studentInfo = body.get(ParameterConstants.STUDENT_ID); if (studentInfo instanceof Collection) { students = putStudents((Collection<String>) studentInfo, entity.getEntityId(), students); } else if (studentInfo instanceof String) { students = putStudents(Arrays.asList((String) studentInfo), entity.getEntityId(), students); } } } Set<String> validStudents = validator.validate(EntityNames.STUDENT, students.keySet()); return getValidIds(validStudents, students); } @Override boolean canValidate(String entityType, boolean through); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidate() { assertTrue(validator.canValidate(EntityNames.STUDENT_COMPETENCY, true)); assertTrue(validator.canValidate(EntityNames.STUDENT_COMPETENCY, false)); assertFalse(validator.canValidate(EntityNames.GRADEBOOK_ENTRY, true)); assertFalse(validator.canValidate(EntityNames.PROGRAM, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_COMPETENCY_OBJECTIVE, true)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_COMPETENCY.equals(entityType); }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_COMPETENCY.equals(entityType); } }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_COMPETENCY.equals(entityType); } }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_COMPETENCY.equals(entityType); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_COMPETENCY.equals(entityType); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void shouldAcceptExchangeObjectReadExchangeControlFileAndSetExchangeBatchJob() throws Exception { Exchange preObject = new DefaultExchange(new DefaultCamelContext()); WorkNote workNote = Mockito.mock(WorkNote.class); String batchJobId = NewBatchJob.createId("InterchangeStudentCsv.ctl"); NewBatchJob mockedJob = Mockito.mock(NewBatchJob.class); Mockito.when(mockedJob.getBatchProperties()).thenReturn(new HashMap <String, String>()); Mockito.when(workNote.getBatchJobId()).thenReturn(batchJobId); Mockito.when(mockedBatchJobDAO.findBatchJobById(Matchers.eq(batchJobId))).thenReturn(mockedJob); preObject.getIn().setBody(workNote); processor.process(preObject); boolean hasErrors = (Boolean) preObject.getIn().getHeader("hasErrors"); assertNotNull("header [hasErrors] not set", hasErrors); }
|
@Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); MongoTrackingAspect.aspectOf().reset(); }
|
ControlFileProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); MongoTrackingAspect.aspectOf().reset(); } }
|
ControlFileProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); MongoTrackingAspect.aspectOf().reset(); } }
|
ControlFileProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); MongoTrackingAspect.aspectOf().reset(); } @Override void process(Exchange exchange); }
|
ControlFileProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); MongoTrackingAspect.aspectOf().reset(); } @Override void process(Exchange exchange); static final BatchJobStageType BATCH_JOB_STAGE; }
|
@Test public void testSingleValidate() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(competency1.getEntityId())); assertTrue(validator.validate(EntityNames.STUDENT_COMPETENCY, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testNegativeHeterogeneousValidate() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(competency1.getEntityId(),competency2.getEntityId())); assertFalse(validator.validate(EntityNames.STUDENT_COMPETENCY, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentCompetencyValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_COMPETENCY, entityType, ids)) { return Collections.emptySet(); } Map<String, Set<String>> ssaToSC = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (ssaToSC.isEmpty()) { return Collections.emptySet(); } Map<String, Set<String>> studentIdsToSSA = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(ssaToSC.keySet()), ParameterConstants.STUDENT_ID); if (studentIdsToSSA.isEmpty()) { return Collections.emptySet(); } Set<String> studentIds = studentIdsToSSA.keySet(); studentIds.retainAll(getDirectStudentIds()); Set<String> validSSAIds = getValidIds(studentIds, studentIdsToSSA); Set<String> validSCIds = getValidIds(validSSAIds, ssaToSC); return validSCIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testCanValidate() { assertTrue(validator.canValidate(EntityNames.STAFF_ED_ORG_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.STAFF_ED_ORG_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.ATTENDANCE, false)); assertFalse(validator.canValidate(EntityNames.ATTENDANCE, true)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STAFF_ED_ORG_ASSOCIATION.equals(entityType) && isTeacher() && !isTransitive; }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STAFF_ED_ORG_ASSOCIATION.equals(entityType) && isTeacher() && !isTransitive; } }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STAFF_ED_ORG_ASSOCIATION.equals(entityType) && isTeacher() && !isTransitive; } }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STAFF_ED_ORG_ASSOCIATION.equals(entityType) && isTeacher() && !isTransitive; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return EntityNames.STAFF_ED_ORG_ASSOCIATION.equals(entityType) && isTeacher() && !isTransitive; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateNonExpiredAssociation() { Set<String> edOrgAssociationIds = new HashSet<String>(); Entity assoc = helper.generateStaffEdorg(helper.STAFF_ID, helper.ED_ORG_ID, false); edOrgAssociationIds.add(assoc.getEntityId()); assertTrue(validator.validate(EntityNames.STAFF_ED_ORG_ASSOCIATION, edOrgAssociationIds).containsAll(edOrgAssociationIds)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.getEntityId()); } } validIds.retainAll(ids); return validIds; }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.getEntityId()); } } validIds.retainAll(ids); return validIds; } }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.getEntityId()); } } validIds.retainAll(ids); return validIds; } }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.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(); }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.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(); }
|
@Test public void testInvalidateExpiredAssociation() { Set<String> edOrgAssociationIds = new HashSet<String>(); Entity assoc = helper.generateStaffEdorg(helper.STAFF_ID, helper.ED_ORG_ID, true); edOrgAssociationIds.add(assoc.getEntityId()); assertFalse(validator.validate(EntityNames.STAFF_ED_ORG_ASSOCIATION, edOrgAssociationIds).containsAll(edOrgAssociationIds)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.getEntityId()); } } validIds.retainAll(ids); return validIds; }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.getEntityId()); } } validIds.retainAll(ids); return validIds; } }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.getEntityId()); } } validIds.retainAll(ids); return validIds; } }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.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(); }
|
TeacherToStaffEdOrgAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_ED_ORG_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_REFERENCE, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.principalId())); Iterable<Entity> entities = this.repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, query); Set<String> validIds = new HashSet<String>(); for (Entity entity : entities) { if (!dateHelper.isFieldExpired(entity.getBody(), ParameterConstants.END_DATE)) { validIds.add(entity.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(); }
|
@Test public void testCanValidate() { assertTrue(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.STUDENT_COHORT_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.STUDENT_COHORT_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_SCHOOL_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.PROGRAM, false)); assertFalse(validator.canValidate(EntityNames.ASSESSMENT, true)); assertFalse(validator.canValidate(EntityNames.GRADEBOOK_ENTRY, true)); assertFalse(validator.canValidate(EntityNames.COHORT, true)); assertFalse(validator.canValidate(EntityNames.STAFF_COHORT_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_SECTION_ASSOCIATION.equals(entityType) && !isTransitive; }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_SECTION_ASSOCIATION.equals(entityType) && !isTransitive; } }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_SECTION_ASSOCIATION.equals(entityType) && !isTransitive; } }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_SECTION_ASSOCIATION.equals(entityType) && !isTransitive; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudentOrParent() && EntityNames.STUDENT_SECTION_ASSOCIATION.equals(entityType) && !isTransitive; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testPositiveValidate() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(assoc1Current.getEntityId(), assoc1Past.getEntityId())); assertTrue(validator.validate(EntityNames.STUDENT_SECTION_ASSOCIATION, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testHeterogeneousValidate() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(assoc1Current.getEntityId(), assoc2.getEntityId())); assertFalse(validator.validate(EntityNames.STUDENT_SECTION_ASSOCIATION, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentSectionAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT_SECTION_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); for(Entity ssa : getRepo().findAll(EntityNames.STUDENT_SECTION_ASSOCIATION, query)) { Map<String, Object> body = ssa.getBody(); if (!getDirectStudentIds().contains(body.get(ParameterConstants.STUDENT_ID))) { return Collections.emptySet(); } } return ids; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testCanValidate() { assertTrue(validator.canValidate(EntityNames.STUDENT_COHORT_ASSOCIATION, false)); assertTrue(validator.canValidate(EntityNames.STUDENT_COHORT_ASSOCIATION, true)); assertTrue(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, false)); assertTrue(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.SECTION, true)); assertFalse(validator.canValidate(EntityNames.SECTION, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return STUDENT_ASSOCIATIONS.contains(entityType) && isStaff(); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return STUDENT_ASSOCIATIONS.contains(entityType) && isStaff(); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return STUDENT_ASSOCIATIONS.contains(entityType) && isStaff(); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return STUDENT_ASSOCIATIONS.contains(entityType) && isStaff(); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return STUDENT_ASSOCIATIONS.contains(entityType) && isStaff(); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateValidCohortAssociation() { Mockito.when(mockStudentValidator.validate(Mockito.eq(EntityNames.STUDENT), Mockito.any(Set.class))) .thenReturn(new HashSet<String>(Arrays.asList("Boop"))); for (int i = 0; i < 10; ++i) { cohortIds.add(helper.generateStudentCohort("Boop", "" + i, false).getEntityId()); } assertTrue(validator.validate(EntityNames.STUDENT_COHORT_ASSOCIATION, cohortIds).equals(cohortIds)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void shouldAddNewLz() throws Exception { List<String> testLzPaths = new ArrayList<String>(); testLzPaths.add("."); when(mockedTenantDA.getLzPaths()).thenReturn(testLzPaths); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); tenantProcessor.process(exchange); assertEquals("Header on exchange should indicate success", TenantProcessor.TENANT_POLL_SUCCESS, exchange .getIn().getHeader(TenantProcessor.TENANT_POLL_HEADER)); }
|
@Override public void process(Exchange exchange) throws Exception { try { createNewLandingZones(); exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_SUCCESS); doPreloads(); } catch (Exception e) { exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_FAILURE); LOG.error("Exception encountered adding tenant", e); } }
|
TenantProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { try { createNewLandingZones(); exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_SUCCESS); doPreloads(); } catch (Exception e) { exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_FAILURE); LOG.error("Exception encountered adding tenant", e); } } }
|
TenantProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { try { createNewLandingZones(); exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_SUCCESS); doPreloads(); } catch (Exception e) { exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_FAILURE); LOG.error("Exception encountered adding tenant", e); } } }
|
TenantProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { try { createNewLandingZones(); exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_SUCCESS); doPreloads(); } catch (Exception e) { exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_FAILURE); LOG.error("Exception encountered adding tenant", e); } } @Override void process(Exchange exchange); }
|
TenantProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { try { createNewLandingZones(); exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_SUCCESS); doPreloads(); } catch (Exception e) { exchange.getIn().setHeader(TENANT_POLL_HEADER, TENANT_POLL_FAILURE); LOG.error("Exception encountered adding tenant", e); } } @Override void process(Exchange exchange); static final String TENANT_POLL_HEADER; static final String TENANT_POLL_SUCCESS; static final String TENANT_POLL_FAILURE; }
|
@Test(expected = MissingConfigException.class) public void missingLocalDir() throws ParseException, MissingConfigException { String[] args = new String[] { "-u", "user", "-pass", "password", "-s", "server", "-port", "22" }; propUtils.getUploadProperties(args); }
|
public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); }
|
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } }
|
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } PropertyUtils(CommandLineParser parser); }
|
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } PropertyUtils(CommandLineParser parser); UploadProperties getUploadProperties(String[] args); }
|
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } PropertyUtils(CommandLineParser parser); UploadProperties getUploadProperties(String[] args); static final String KEY_USER; static final String KEY_PASSWORD; static final String KEY_SFTP_SERVER; static final String KEY_LOCAL_DIRECTORY; static final String KEY_PORT; final static Options OPTIONS; }
|
@Test public void testCanValidateValidProgramAssociation() { Mockito.when(mockStudentValidator.validate(Mockito.eq(EntityNames.STUDENT), Mockito.any(Set.class))) .thenReturn(new HashSet<String>(Arrays.asList("Boop"))); for (int i = 0; i < 10; ++i) { programIds.add(helper.generateStudentProgram("Boop", "" + i, false).getEntityId()); } assertTrue(validator.validate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, programIds).equals(programIds)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotValidExpiredAssociation() { Mockito.when(mockStudentValidator.validate(Mockito.eq(EntityNames.STUDENT), Mockito.any(Set.class))) .thenReturn(new HashSet<String>(Arrays.asList("Boop"))); cohortIds.add(helper.generateStudentCohort("Boop", "Beep", true).getEntityId()); assertFalse(validator.validate(EntityNames.STUDENT_COHORT_ASSOCIATION, cohortIds).equals(cohortIds)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotValidateAssociationWithoutStudentAccess() { Mockito.when(mockStudentValidator.validate(Mockito.eq(EntityNames.STUDENT), Mockito.any(Set.class))) .thenReturn(new HashSet<String>(Arrays.asList("dummy"))); for (int i = 0; i < 10; ++i) { cohortIds.add(helper.generateStudentCohort("Boop", "" + i, false).getEntityId()); } assertFalse(validator.validate(EntityNames.STUDENT_COHORT_ASSOCIATION, cohortIds).equals(cohortIds)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToStudentCohortProgramAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> associations = new HashMap<String, Set<String>>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> assocs = getRepo().findAll(entityType, basicQuery); for (Entity assoc : assocs) { String studentId = (String) assoc.getBody().get(ParameterConstants.STUDENT_ID); if (!isFieldExpired(assoc.getBody(), ParameterConstants.END_DATE, true)) { if (!associations.containsKey(studentId)) { associations.put(studentId, new HashSet<String>()); } associations.get(studentId).add(assoc.getEntityId()); } } Set<String> validStudents = studentValidator.validate(EntityNames.STUDENT, associations.keySet()); return getValidIds(validStudents, associations); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateTeacherToStaff() throws Exception { setupCurrentUser(staff1); assertTrue(validator.canValidate(EntityNames.STAFF, true)); assertFalse(validator.canValidate(EntityNames.STAFF, false)); assertFalse(validator.canValidate(EntityNames.SECTION, false)); assertFalse(validator.canValidate(EntityNames.SECTION, true)); }
|
@Override public boolean canValidate(String entityType, boolean transitive) { return transitive && EntityNames.STAFF.equals(entityType) && isStaff(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean transitive) { return transitive && EntityNames.STAFF.equals(entityType) && isStaff(); } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean transitive) { return transitive && EntityNames.STAFF.equals(entityType) && isStaff(); } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean transitive) { return transitive && EntityNames.STAFF.equals(entityType) && isStaff(); } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean transitive) { return transitive && EntityNames.STAFF.equals(entityType) && isStaff(); } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testValidStaffStaffAssociationNoEndDate() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff2.getEntityId())); assertTrue(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); assertTrue(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testValidStaffStaffAssociationWithEndDate() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff3.getEntityId())); assertTrue(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testExpiredStaffStaffAssociation() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff4.getEntityId())); assertFalse(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testStaffWithNoEdorgAssociation() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff2.getEntityId(), staff5.getEntityId())); assertFalse(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testSchoolStaffToLEAStaffAssociation() { setupCurrentUser(staff2); Set<String> staffId = new HashSet<String>(Arrays.asList(staff1.getEntityId())); assertFalse(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testMulti1() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff1.getEntityId(), staff2.getEntityId(), staff3.getEntityId(), staff4.getEntityId())); assertFalse(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testPreLoad() { File landingZone = Files.createTempDir(); try { assertTrue(tenantProcessor.preLoad(landingZone.getAbsolutePath(), Arrays.asList("small"))); assertTrue(landingZone.list(new WildcardFileFilter("preload-*.zip")).length == 1); } finally { landingZone.delete(); } }
|
boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } @Override void process(Exchange exchange); }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } @Override void process(Exchange exchange); static final String TENANT_POLL_HEADER; static final String TENANT_POLL_SUCCESS; static final String TENANT_POLL_FAILURE; }
|
@Test public void testMulti2() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff1.getEntityId(), staff4.getEntityId())); assertFalse(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testMulti3() { setupCurrentUser(staff1); Set<String> staffId = new HashSet<String>(Arrays.asList(staff2.getEntityId(), staff3.getEntityId())); assertTrue(validator.validate(EntityNames.STAFF, staffId).equals(staffId)); }
|
@SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveStaffToStaffValidator extends AbstractContextValidator { @SuppressWarnings("unchecked") @Override public Set<String> validate(String entityName, Set<String> staffIds) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF, entityName, staffIds)) { return Collections.EMPTY_SET; } Set<String> validIds = new HashSet<String>(); NeutralQuery basicQuery = new NeutralQuery(new NeutralCriteria("staffReference", NeutralCriteria.CRITERIA_IN, staffIds)); basicQuery.setIncludeFields(Arrays.asList("educationOrganizationReference", "staffReference")); LOG.info("Attempting to validate transitively from staff to staff with ids {}", staffIds); injectEndDateQuery(basicQuery); Iterable<Entity> edOrgAssoc = repo.findAll(EntityNames.STAFF_ED_ORG_ASSOCIATION, basicQuery); Map<String, Set<String>> staffEdorgMap = new HashMap<String, Set<String>>(); populateMapFromMongoResponse(staffEdorgMap, edOrgAssoc); Set<String> edOrgLineage = getStaffEdOrgLineage(); if (edOrgLineage.isEmpty() || staffEdorgMap.isEmpty()) { return Collections.EMPTY_SET; } for (Entry<String, Set<String>> entry : staffEdorgMap.entrySet()) { Set<String> tmpSet = new HashSet<String>(entry.getValue()); tmpSet.retainAll(edOrgLineage); if (tmpSet.size() != 0) { validIds.add(entry.getKey()); } } validIds.addAll(validateThrough(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId")); validIds.addAll(validateThrough(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId")); basicQuery = new NeutralQuery(new NeutralCriteria("_id", "in", edOrgLineage)); Iterable<Entity> edorgs = repo.findAll(EntityNames.EDUCATION_ORGANIZATION, basicQuery); List<String> programs = new ArrayList<String>(); for (Entity e : edorgs) { Object value = e.getBody().get("programReference"); if (value != null) { if (List.class.isAssignableFrom(value.getClass())) { programs.addAll((List<String>) value); } else if (String.class.isAssignableFrom(value.getClass())) { programs.add((String) value); } } } validIds.addAll(getIds(EntityNames.STAFF_PROGRAM_ASSOCIATION, "programId", programs)); basicQuery = new NeutralQuery(new NeutralCriteria("educationOrgId", "in", edOrgLineage)); List<String> cohorts = (List<String>) repo.findAllIds(EntityNames.COHORT, basicQuery); validIds.addAll(getIds(EntityNames.STAFF_COHORT_ASSOCIATION, "cohortId", cohorts)); validIds.retainAll(staffIds); return validIds; } @Override boolean canValidate(String entityType, boolean transitive); @SuppressWarnings("unchecked") @Override Set<String> validate(String entityName, Set<String> staffIds); @Override SecurityUtil.UserContext getContext(); }
|
@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_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testSuccessOne() { this.vth.generateTeacherSchool(USER_ID, SCHOOL_ID); Entity tsa = this.vth.generateTeacherSchool("Heru-er", SCHOOL_ID); Assert.assertTrue(val.validate(CORRECT_ENTITY_TYPE, Collections.singleton(tsa.getEntityId())).contains(tsa.getEntityId())); tsa = this.vth.generateTeacherSchool("Izida", SCHOOL_ID); Assert.assertTrue(val.validate(CORRECT_ENTITY_TYPE, Collections.singleton(tsa.getEntityId())).contains(tsa.getEntityId())); tsa = this.vth.generateTeacherSchool("Ptah", SCHOOL_ID); Assert.assertTrue(val.validate(CORRECT_ENTITY_TYPE, Collections.singleton(tsa.getEntityId())).contains(tsa.getEntityId())); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testSuccessMulti() { this.vth.generateTeacherSchool(USER_ID, SCHOOL_ID); Set<String> ids = new HashSet<String>(); for (int i = 0; i < 100; i++) { ids.add(this.vth.generateTeacherSchool("Thor" + i, SCHOOL_ID).getEntityId()); } Assert.assertTrue(val.validate(CORRECT_ENTITY_TYPE, ids).containsAll(ids)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testWrongId() { Set<String> idsToValidate = Collections.singleton("Hammerhands"); Assert.assertFalse(val.validate(CORRECT_ENTITY_TYPE, idsToValidate).containsAll(idsToValidate)); idsToValidate = Collections.singleton("Nagas"); Assert.assertFalse(val.validate(CORRECT_ENTITY_TYPE, idsToValidate).containsAll(idsToValidate)); idsToValidate = Collections.singleton("Phantom Warriors"); Assert.assertFalse(val.validate(CORRECT_ENTITY_TYPE, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testHeterogenousList() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(this.vth.generateTeacherSchool(USER_ID, SCHOOL_ID).getEntityId(), this.vth.generateTeacherSchool("Ssss'ra", "Arcanus").getEntityId(), this.vth.generateTeacherSchool("Kali", "Arcanus") .getEntityId())); Assert.assertFalse(val.validate(CORRECT_ENTITY_TYPE, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
TransitiveTeacherToTeacherSchoolAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.TEACHER_SCHOOL_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<Entity> tsa = getRepo().findAll(EntityNames.TEACHER_SCHOOL_ASSOCIATION, nq); Set<String> teachers = new HashSet<String>(); Map<String, Set<String>> teacherToTSA = new HashMap<String, Set<String>>(); for (Entity e : tsa) { String teacherId = (String) e.getBody().get(ParameterConstants.TEACHER_ID); teachers.add(teacherId); if(!teacherToTSA.containsKey(teacherId)) { teacherToTSA.put(teacherId, new HashSet<String>()); } teacherToTSA.get(teacherId).add(e.getEntityId()); } Set<String> validTeacherIds = val.validate(EntityNames.TEACHER, teachers); return getValidIds(validTeacherIds, teacherToTSA); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testFilterbellScheduleDataFromLEA() { setupStaff(staffLea, lea.getEntityId()); Set<String> expectedIds = new HashSet<String>(Arrays.asList(bellScheduleLea.getEntityId(), bellScheduleSchoolLea.getEntityId())); Set<String> actual = validator.validate(EntityNames.BELL_SCHEDULE, bellScheduleIds); Assert.assertEquals(expectedIds, actual); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testFilterClassPeriodDataFromSchool() { setupStaff(staffSchoolLea, schoolParentLea.getEntityId()); Set<String> expectedIds = new HashSet<String>(Arrays.asList(bellScheduleSchoolLea.getEntityId())); Set<String> actual = validator.validate(EntityNames.BELL_SCHEDULE, bellScheduleIds); Assert.assertEquals(expectedIds, actual); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testFilterClassPeriodDataFromSchool2() { setupStaff(staffSchoolNoParent, schoolNoParent.getEntityId()); Set<String> expectedIds = new HashSet<String>(Arrays.asList(bellScheduleSchoolNoParent.getEntityId())); Set<String> actual = validator.validate(EntityNames.BELL_SCHEDULE, bellScheduleIds); Assert.assertEquals(expectedIds, actual); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
GenericToGlobalBellScheduleWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.BELL_SCHEDULE, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery classPeriodsQuery = new NeutralQuery(); classPeriodsQuery.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); List<String> myClassPeriods = Lists.newArrayList(getRepo().findAllIds("classPeriod", classPeriodsQuery)); NeutralQuery bellSchedulesQuery = new NeutralQuery(); bellSchedulesQuery.addCriteria(new NeutralCriteria("meetingTime.classPeriodId", NeutralCriteria.CRITERIA_IN, myClassPeriods)); bellSchedulesQuery.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); Set<String> myBellSchedules = Sets.newHashSet(getRepo().findAllIds("bellSchedule", bellSchedulesQuery)); return myBellSchedules; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testPreLoadBadDataSet() { File landingZone = Files.createTempDir(); try { assertTrue(!tenantProcessor.preLoad(landingZone.getAbsolutePath(), Arrays.asList("smallish"))); } finally { landingZone.delete(); } }
|
boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } @Override void process(Exchange exchange); }
|
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } @Override void process(Exchange exchange); static final String TENANT_POLL_HEADER; static final String TENANT_POLL_SUCCESS; static final String TENANT_POLL_FAILURE; }
|
@Test public void testCanValidateTeacherToStudent() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotValidateOtherEntities() throws Exception { assertFalse(validator.canValidate(EntityNames.ATTENDANCE, false)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return EntityNames.STUDENT.equals(entityType) && isTeacher(); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessThroughSingleValidStudent() throws Exception { helper.generateTSA(TEACHER_ID, "3", false); helper.generateSSA("2", "3", false); studentIds.add("2"); Assert.assertEquals(validator.validate(EntityNames.STUDENT, studentIds), studentIds); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughInvalidStudent() throws Exception { helper.generateTSA(TEACHER_ID, "-1", false); helper.generateSSA("2", "3", false); studentIds.add("2"); Assert.assertFalse(validator.validate(EntityNames.STUDENT, studentIds).containsAll(studentIds)); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessThroughManyStudents() throws Exception { for (int i = 0; i < 100; ++i) { helper.generateTSA(TEACHER_ID, "" + i, false); } for (int i = 0; i < 100; ++i) { for (int j = -1; j > -31; --j) { helper.generateSSA(String.valueOf(j), "" + i, false); studentIds.add(String.valueOf(j)); } } Assert.assertEquals(validator.validate(EntityNames.STUDENT, studentIds).size(), studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCantGetAccessThroughManyStudents() throws Exception { for (int i = 0; i < 2; ++i) { helper.generateTSA(TEACHER_ID, String.valueOf(i), false); } for (int i = 0; i < 2; ++i) { for (int j = -1; j > -2; --j) { helper.generateSSA(String.valueOf(j), String.valueOf(i), false); studentIds.add(String.valueOf(j)); } } helper.generateSSA("100", "6", false); studentIds.add("100"); assertFalse(validator.validate(EntityNames.STUDENT, studentIds).containsAll(studentIds)); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessThroughStudentsWithManySections() throws Exception { helper.generateTSA(TEACHER_ID, "0", false); for (int i = 0; i < 10; ++i) { helper.generateSSA("2", String.valueOf(i), false); studentIds.add("2"); } Assert.assertEquals(validator.validate(EntityNames.STUDENT, studentIds).size(), studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughManyStudents() throws Exception { for (int i = 100; i < 200; ++i) { helper.generateTSA(TEACHER_ID, "" + i, false); } for (int i = 0; i < 100; ++i) { for (int j = -1; j > -31; --j) { helper.generateSSA("" + j, "" + i, false); studentIds.add("" + j); } } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughManyStudentsWithOneFailure() throws Exception { for (int i = 0; i < 100; ++i) { helper.generateTSA(TEACHER_ID, "" + i, false); } for (int i = 0; i < 100; ++i) { for (int j = -1; j > -31; --j) { helper.generateSSA("" + j, "" + i, false); studentIds.add("" + j); } } helper.generateSSA("-32", "101", false); studentIds.add("-32"); assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test @Ignore public void testCanGetAccessThroughValidCohort() throws Exception { helper.generateTeacherSchool(TEACHER_ID, ED_ORG_ID); String cohortId = helper.generateCohort(ED_ORG_ID).getEntityId(); helper.generateStaffCohort(TEACHER_ID, cohortId, false, true); for (int i = 0; i < 10; ++i) { helper.generateStudentCohort(i + "", cohortId, false); studentIds.add(i + ""); } Assert.assertEquals(validator.validate(EntityNames.STUDENT, studentIds).size(), studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testProcess() throws Exception { init(); Exchange exchange = createFileEntryExchange(); Resource xsd = Mockito.mock(Resource.class); Map<String, Resource> xsdList = new HashMap<String, Resource>(); FileEntryWorkNote workNote = (FileEntryWorkNote) exchange.getIn().getMandatoryBody(WorkNote.class); xsdList.put(workNote.getFileEntry().getFileType().getName(), xsd); xsdSelector.setXsdList(xsdList); processor.process(exchange); Mockito.verify(processor, Mockito.times(1)).parse(Mockito.any(InputStream.class), Mockito.any(Resource.class), Mockito.any(SimpleReportStats.class), Mockito.any(JobSource.class)); }
|
@Override protected void process(Exchange exchange, ProcessorArgs<FileEntryWorkNote> args) { prepareState(exchange, args.workNote); Source source = new FileSource(args.workNote.getFileEntry().getResourceId()); Metrics metrics = Metrics.newInstance(args.workNote.getFileEntry().getResourceId()); InputStream input = null; boolean validData = true; try { input = args.workNote.getFileEntry().getFileStream(); Resource xsdSchema = xsdSelector.provideXsdResource(args.workNote.getFileEntry()); parse(input, xsdSchema, args.reportStats, source); metrics.setValidationErrorCount(ignoredRecordCount.get()); } catch (IOException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0061); } catch (SAXException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0062); } catch (XmlParseException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0063); validData = false; } finally { IOUtils.closeQuietly(input); if (validData) { sendDataBatch(); } cleanUpState(); args.job = refreshjob(args.job.getId()); args.stage.addMetrics(metrics); } }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override protected void process(Exchange exchange, ProcessorArgs<FileEntryWorkNote> args) { prepareState(exchange, args.workNote); Source source = new FileSource(args.workNote.getFileEntry().getResourceId()); Metrics metrics = Metrics.newInstance(args.workNote.getFileEntry().getResourceId()); InputStream input = null; boolean validData = true; try { input = args.workNote.getFileEntry().getFileStream(); Resource xsdSchema = xsdSelector.provideXsdResource(args.workNote.getFileEntry()); parse(input, xsdSchema, args.reportStats, source); metrics.setValidationErrorCount(ignoredRecordCount.get()); } catch (IOException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0061); } catch (SAXException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0062); } catch (XmlParseException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0063); validData = false; } finally { IOUtils.closeQuietly(input); if (validData) { sendDataBatch(); } cleanUpState(); args.job = refreshjob(args.job.getId()); args.stage.addMetrics(metrics); } } }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override protected void process(Exchange exchange, ProcessorArgs<FileEntryWorkNote> args) { prepareState(exchange, args.workNote); Source source = new FileSource(args.workNote.getFileEntry().getResourceId()); Metrics metrics = Metrics.newInstance(args.workNote.getFileEntry().getResourceId()); InputStream input = null; boolean validData = true; try { input = args.workNote.getFileEntry().getFileStream(); Resource xsdSchema = xsdSelector.provideXsdResource(args.workNote.getFileEntry()); parse(input, xsdSchema, args.reportStats, source); metrics.setValidationErrorCount(ignoredRecordCount.get()); } catch (IOException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0061); } catch (SAXException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0062); } catch (XmlParseException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0063); validData = false; } finally { IOUtils.closeQuietly(input); if (validData) { sendDataBatch(); } cleanUpState(); args.job = refreshjob(args.job.getId()); args.stage.addMetrics(metrics); } } }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override protected void process(Exchange exchange, ProcessorArgs<FileEntryWorkNote> args) { prepareState(exchange, args.workNote); Source source = new FileSource(args.workNote.getFileEntry().getResourceId()); Metrics metrics = Metrics.newInstance(args.workNote.getFileEntry().getResourceId()); InputStream input = null; boolean validData = true; try { input = args.workNote.getFileEntry().getFileStream(); Resource xsdSchema = xsdSelector.provideXsdResource(args.workNote.getFileEntry()); parse(input, xsdSchema, args.reportStats, source); metrics.setValidationErrorCount(ignoredRecordCount.get()); } catch (IOException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0061); } catch (SAXException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0062); } catch (XmlParseException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0063); validData = false; } finally { IOUtils.closeQuietly(input); if (validData) { sendDataBatch(); } cleanUpState(); args.job = refreshjob(args.job.getId()); args.stage.addMetrics(metrics); } } @Override void visit(RecordMeta recordMeta, Map<String, Object> record); @Override void ignored(); void sendDataBatch(); @Override AbstractMessageReport getMessageReport(); @Override void setMessageReport(AbstractMessageReport messageReport); @Override String getStageDescription(); @Override BatchJobStageType getStage(); ProducerTemplate getProducer(); void setProducer(ProducerTemplate producer); TypeProvider getTypeProvider(); void setTypeProvider(TypeProvider typeProvider); XsdSelector getXsdSelector(); void setHelper( ReferenceHelper helper ); void setXsdSelector(XsdSelector xsdSelector); int getBatchSize(); void setBatchSize(int batchSize); void audit(SecurityEvent event); }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override protected void process(Exchange exchange, ProcessorArgs<FileEntryWorkNote> args) { prepareState(exchange, args.workNote); Source source = new FileSource(args.workNote.getFileEntry().getResourceId()); Metrics metrics = Metrics.newInstance(args.workNote.getFileEntry().getResourceId()); InputStream input = null; boolean validData = true; try { input = args.workNote.getFileEntry().getFileStream(); Resource xsdSchema = xsdSelector.provideXsdResource(args.workNote.getFileEntry()); parse(input, xsdSchema, args.reportStats, source); metrics.setValidationErrorCount(ignoredRecordCount.get()); } catch (IOException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0061); } catch (SAXException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0062); } catch (XmlParseException e) { getMessageReport().error(args.reportStats, source, CoreMessageCode.CORE_0063); validData = false; } finally { IOUtils.closeQuietly(input); if (validData) { sendDataBatch(); } cleanUpState(); args.job = refreshjob(args.job.getId()); args.stage.addMetrics(metrics); } } @Override void visit(RecordMeta recordMeta, Map<String, Object> record); @Override void ignored(); void sendDataBatch(); @Override AbstractMessageReport getMessageReport(); @Override void setMessageReport(AbstractMessageReport messageReport); @Override String getStageDescription(); @Override BatchJobStageType getStage(); ProducerTemplate getProducer(); void setProducer(ProducerTemplate producer); TypeProvider getTypeProvider(); void setTypeProvider(TypeProvider typeProvider); XsdSelector getXsdSelector(); void setHelper( ReferenceHelper helper ); void setXsdSelector(XsdSelector xsdSelector); int getBatchSize(); void setBatchSize(int batchSize); void audit(SecurityEvent event); }
|
@Test public void testCanNotGetAccessThroughExpiredCohort() throws Exception { assertTrue(validator.validate(EntityNames.STUDENT, studentIds).isEmpty()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughDeniedCohort() throws Exception { helper.generateTeacherSchool(TEACHER_ID, ED_ORG_ID); String cohortId = helper.generateCohort(ED_ORG_ID).getEntityId(); helper.generateStaffCohort(TEACHER_ID, cohortId, false, false); for (int i = 0; i < 10; ++i) { helper.generateStudentCohort(i + "", cohortId, false); studentIds.add(i + ""); } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughInvalidCohort() throws Exception { helper.generateTeacherSchool(TEACHER_ID, ED_ORG_ID); String cohortId = helper.generateCohort(ED_ORG_ID).getEntityId(); helper.generateStaffCohort(TEACHER_ID, cohortId, false, true); for (int i = 0; i < 10; ++i) { helper.generateStudentCohort(i + "", "" + i * -1, false); studentIds.add(i + ""); } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test @Ignore public void testCanNotGetAccessThroughCohortOutsideOfEdorg() throws Exception { helper.generateTeacherSchool(TEACHER_ID, ED_ORG_ID); String cohortId = helper.generateCohort("122").getEntityId(); helper.generateStaffCohort(TEACHER_ID, cohortId, false, true); for (int i = 0; i < 10; ++i) { helper.generateStudentCohort(i + "", cohortId, false); studentIds.add(i + ""); } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCohortAccessIntersectionRules() throws Exception { assertTrue(validator.validate(EntityNames.STUDENT, studentIds).isEmpty()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessThroughValidProgram() throws Exception { String edOrgId = helper.generateEdorgWithProgram(Arrays.asList(programId)).getEntityId(); helper.generateTeacherSchool(TEACHER_ID, edOrgId); helper.generateStaffProgram(TEACHER_ID, programId, false, true); for (int i = 0; i < 10; ++i) { helper.generateStudentProgram(i + "", programId, false); studentIds.add(i + ""); } Assert.assertEquals(validator.validate(EntityNames.STUDENT, studentIds).size(), studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanAccessStudentsThoughSectionAndProgramAssociations() throws Exception { String studentId1 = "STUDENT11"; String studentId2 = "STUDENT22"; helper.generateTSA(TEACHER_ID, SECTION_ID, false); helper.generateSSA(studentId1, SECTION_ID, false); studentIds.add(studentId1); String edOrgId = helper.generateEdorgWithProgram(Arrays.asList(programId)).getEntityId(); helper.generateTeacherSchool(TEACHER_ID, edOrgId); helper.generateStaffProgram(TEACHER_ID, programId, false, true); helper.generateStudentProgram(studentId2, programId, false); studentIds.add(studentId2); Assert.assertEquals(validator.validate(EntityNames.STUDENT, studentIds).size(), studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughExpiredProgram() throws Exception { assertTrue(validator.validate(EntityNames.STUDENT, studentIds).isEmpty()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughDeniedProgram() throws Exception { String edOrgId = helper.generateEdorgWithProgram(Arrays.asList(programId)).getEntityId(); helper.generateTeacherSchool(TEACHER_ID, edOrgId); helper.generateStaffProgram(TEACHER_ID, programId, false, false); for (int i = 0; i < 10; ++i) { helper.generateStudentProgram(i + "", programId, false); studentIds.add(i + ""); } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessThroughWithOneDeniedProgram() throws Exception { String edOrgId = helper.generateEdorgWithProgram(Arrays.asList(programId)).getEntityId(); helper.generateTeacherSchool(TEACHER_ID, edOrgId); helper.generateStaffProgram(TEACHER_ID, programId, false, true); for (int i = 0; i < 10; ++i) { helper.generateStudentProgram(i + "", programId, false); studentIds.add(i + ""); } helper.generateStudentProgram("-32", "101", false); studentIds.add("-32"); assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testVisitAndSend() throws Exception { init(); Exchange exchange = createFileEntryExchange(); processor.setUpState(exchange, exchange.getIn().getBody(FileEntryWorkNote.class)); RecordMetaImpl meta = new RecordMetaImpl("student", "student"); Location loc = Mockito.mock(Location.class); Mockito.when(loc.getLineNumber()).thenReturn(1); Mockito.when(loc.getColumnNumber()).thenReturn(1); meta.setSourceStartLocation(loc); meta.setSourceEndLocation(loc); Map<String, Object> body = new HashMap<String, Object>(); body.put("studentUniqueStateId", "studentId"); processor.visit(meta, body); ParserState state = processor.getState(); List<NeutralRecord> records = state.getDataBatch(); Assert.assertNotNull(records); Assert.assertEquals(1, records.size()); Assert.assertEquals("studentId", records.get(0).getAttributes().get("studentUniqueStateId")); Assert.assertEquals("student", records.get(0).getRecordType()); }
|
@Override public void visit(RecordMeta recordMeta, Map<String, Object> record) { state.get().addToBatch(recordMeta, record, typeProvider, helper); if (state.get().getDataBatch().size() >= batchSize) { sendDataBatch(); } }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override public void visit(RecordMeta recordMeta, Map<String, Object> record) { state.get().addToBatch(recordMeta, record, typeProvider, helper); if (state.get().getDataBatch().size() >= batchSize) { sendDataBatch(); } } }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override public void visit(RecordMeta recordMeta, Map<String, Object> record) { state.get().addToBatch(recordMeta, record, typeProvider, helper); if (state.get().getDataBatch().size() >= batchSize) { sendDataBatch(); } } }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override public void visit(RecordMeta recordMeta, Map<String, Object> record) { state.get().addToBatch(recordMeta, record, typeProvider, helper); if (state.get().getDataBatch().size() >= batchSize) { sendDataBatch(); } } @Override void visit(RecordMeta recordMeta, Map<String, Object> record); @Override void ignored(); void sendDataBatch(); @Override AbstractMessageReport getMessageReport(); @Override void setMessageReport(AbstractMessageReport messageReport); @Override String getStageDescription(); @Override BatchJobStageType getStage(); ProducerTemplate getProducer(); void setProducer(ProducerTemplate producer); TypeProvider getTypeProvider(); void setTypeProvider(TypeProvider typeProvider); XsdSelector getXsdSelector(); void setHelper( ReferenceHelper helper ); void setXsdSelector(XsdSelector xsdSelector); int getBatchSize(); void setBatchSize(int batchSize); void audit(SecurityEvent event); }
|
EdFiParserProcessor extends IngestionProcessor<FileEntryWorkNote, IngestionFileEntry> implements
RecordVisitor { @Override public void visit(RecordMeta recordMeta, Map<String, Object> record) { state.get().addToBatch(recordMeta, record, typeProvider, helper); if (state.get().getDataBatch().size() >= batchSize) { sendDataBatch(); } } @Override void visit(RecordMeta recordMeta, Map<String, Object> record); @Override void ignored(); void sendDataBatch(); @Override AbstractMessageReport getMessageReport(); @Override void setMessageReport(AbstractMessageReport messageReport); @Override String getStageDescription(); @Override BatchJobStageType getStage(); ProducerTemplate getProducer(); void setProducer(ProducerTemplate producer); TypeProvider getTypeProvider(); void setTypeProvider(TypeProvider typeProvider); XsdSelector getXsdSelector(); void setHelper( ReferenceHelper helper ); void setXsdSelector(XsdSelector xsdSelector); int getBatchSize(); void setBatchSize(int batchSize); void audit(SecurityEvent event); }
|
@Test public void testCanNotGetAccessThroughInvalidProgram() throws Exception { String edOrgId = helper.generateEdorgWithProgram(Arrays.asList(programId)).getEntityId(); helper.generateTeacherSchool(TEACHER_ID, edOrgId); helper.generateStaffProgram(TEACHER_ID, programId, false, true); for (int i = 0; i < 10; ++i) { helper.generateStudentProgram(i + "", "" + i * -1, false); studentIds.add(i + ""); } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testProgramAccessIntersectionRules() throws Exception { assertTrue(validator.validate(EntityNames.STUDENT, studentIds).isEmpty()); }
|
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToGrade() throws Exception { assertTrue(validator.canValidate(EntityNames.GRADE, false)); assertTrue(validator.canValidate(EntityNames.GRADE, true)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidateStaffToStudentCompetency() throws Exception { assertTrue(validator.canValidate(EntityNames.STUDENT_COMPETENCY, false)); assertTrue(validator.canValidate(EntityNames.STUDENT_COMPETENCY, true)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testDeniedStaffToOtherEntity() throws Exception { assertFalse(validator.canValidate(EntityNames.STUDENT, false)); assertFalse(validator.canValidate(EntityNames.STUDENT, true)); assertFalse(validator.canValidate(EntityNames.STUDENT_COMPETENCY_OBJECTIVE, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_COMPETENCY_OBJECTIVE, true)); }
|
@Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean through) { return isStaff() && isSubEntityOfStudentSectionAssociation(entityType); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanGetAccessToGrade() throws Exception { Set<String> grades = new HashSet<String>(); Map<String, Object> association = buildStudentSectionAssociation("student123", "section123", DateTime.now() .minusDays(3)); Entity studentSectionAssociation = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, "ssa123", association, null); Entity gradeEntity = helper.generateGrade(studentSectionAssociation.getEntityId()); grades.add(gradeEntity.getEntityId()); studentIds.add("student123"); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.GRADE), Mockito.any(NeutralQuery.class))).thenReturn( Arrays.asList(gradeEntity)); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SECTION_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(studentSectionAssociation)); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(studentIds); assertTrue(validator.validate(EntityNames.GRADE, grades).containsAll(grades)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessToGrade() throws Exception { Set<String> grades = new HashSet<String>(); Map<String, Object> association = buildStudentSectionAssociation("student123", "section123", DateTime.now() .minusDays(3)); Entity studentSectionAssociation = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, association); Entity gradeEntity = helper.generateGrade(studentSectionAssociation.getEntityId()); grades.add(gradeEntity.getEntityId()); studentIds.add("student123"); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.GRADE), Mockito.any(NeutralQuery.class))).thenReturn( Arrays.asList(gradeEntity)); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SECTION_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(Arrays.asList(studentSectionAssociation)); Mockito.when(staffToStudentValidator.validate(EntityNames.STUDENT, studentIds)).thenReturn(Collections.EMPTY_SET); assertFalse(validator.validate(EntityNames.GRADE, grades).equals(grades)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessToGradeDueToGradeLookup() throws Exception { Set<String> grades = new HashSet<String>(); Map<String, Object> association = buildStudentSectionAssociation("student123", "section123", DateTime.now() .minusDays(3)); Entity studentSectionAssociation = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, association); ; Entity gradeEntity = helper.generateGrade(studentSectionAssociation.getEntityId()); grades.add(gradeEntity.getEntityId()); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.GRADE), Mockito.any(NeutralQuery.class))).thenReturn( new ArrayList<Entity>()); assertFalse(validator.validate(EntityNames.GRADE, grades).equals(grades)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanNotGetAccessToGradeDueToStudentSectionAssociationLookup() throws Exception { Set<String> grades = new HashSet<String>(); Map<String, Object> association = buildStudentSectionAssociation("student123", "section123", DateTime.now() .minusDays(3)); Entity studentSectionAssociation = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, association); Entity gradeEntity = helper.generateGrade(studentSectionAssociation.getEntityId()); grades.add(gradeEntity.getEntityId()); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.GRADE), Mockito.any(NeutralQuery.class))).thenReturn( Arrays.asList(gradeEntity)); Mockito.when( mockRepo.findAll(Mockito.eq(EntityNames.STUDENT_SECTION_ASSOCIATION), Mockito.any(NeutralQuery.class))) .thenReturn(new ArrayList<Entity>()); assertFalse(validator.validate(EntityNames.GRADE, grades).equals(grades)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
|
@Test public void testCanValidate() { assertTrue(validator.canValidate(EntityNames.STUDENT_COHORT_ASSOCIATION, true)); assertTrue(validator.canValidate(EntityNames.STUDENT_COHORT_ASSOCIATION, false)); assertTrue(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, true)); assertTrue(validator.canValidate(EntityNames.STUDENT_PROGRAM_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.STUDENT_SECTION_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.STUDENT_SCHOOL_ASSOCIATION, true)); assertFalse(validator.canValidate(EntityNames.PROGRAM, false)); assertFalse(validator.canValidate(EntityNames.ASSESSMENT, true)); assertFalse(validator.canValidate(EntityNames.GRADEBOOK_ENTRY, true)); assertFalse(validator.canValidate(EntityNames.COHORT, true)); assertFalse(validator.canValidate(EntityNames.STAFF_COHORT_ASSOCIATION, false)); }
|
@Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudent() && STUDENT_ASSOCIATIONS.contains(entityType); }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudent() && STUDENT_ASSOCIATIONS.contains(entityType); } }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudent() && STUDENT_ASSOCIATIONS.contains(entityType); } }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudent() && STUDENT_ASSOCIATIONS.contains(entityType); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStudent() && STUDENT_ASSOCIATIONS.contains(entityType); } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testProcess() throws Exception { List<Stage> mockedStages = createFakeStages(); Map<String, String> mockedProperties = createFakeBatchProperties(); File testZip = IngestionTest.getFile("ctl_tmp/test.zip"); NewBatchJob job = new NewBatchJob(BATCHJOBID, testZip.getAbsolutePath(), "finished", 29, mockedProperties, mockedStages, null); job.setBatchProperties(mockedProperties); job.setTenantId(tenantId); ResourceEntry entry = new ResourceEntry(); entry.setResourceName(testZip.getAbsolutePath()); entry.setResourceFormat(FileFormat.ZIP_FILE.getCode()); job.addResourceEntry(entry); WorkNote workNote = Mockito.mock(WorkNote.class); Mockito.when(workNote.getBatchJobId()).thenReturn(BATCHJOBID); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); exchange.getIn().setBody(workNote); Mockito.when(mockedBatchJobDAO.findBatchJobById(Matchers.eq(BATCHJOBID))).thenReturn(job); controlFilePreProcessor.setBatchJobDAO(mockedBatchJobDAO); controlFilePreProcessor.setTenantDA(mockedTenantDA); controlFilePreProcessor.process(exchange); Assert.assertEquals(2, job.getResourceEntries().size()); Assert.assertEquals(29, job.getTotalFiles()); }
|
@Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); }
|
ControlFilePreProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); } }
|
ControlFilePreProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); } }
|
ControlFilePreProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); } @Override void process(Exchange exchange); Set<String> getShardCollections(); void setShardCollections(Set<String> shardCollections); void setBatchJobDAO(BatchJobDAO batchJobDAO); void setTenantDA(TenantDA tenantDA); }
|
ControlFilePreProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { processUsingNewBatchJob(exchange); } @Override void process(Exchange exchange); Set<String> getShardCollections(); void setShardCollections(Set<String> shardCollections); void setBatchJobDAO(BatchJobDAO batchJobDAO); void setTenantDA(TenantDA tenantDA); static final BatchJobStageType BATCH_JOB_STAGE; static final String INDEX_SCRIPT; }
|
@Test public void testPositiveValidate() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(assoc1Current.getEntityId(), assoc1Past.getEntityId())); assertTrue(validator.validate(EntityNames.STUDENT_COHORT_ASSOCIATION, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
@Test public void testHeterogeneousValidate() { Set<String> idsToValidate = new HashSet<String>(Arrays.asList(assoc1Current.getEntityId(), assoc2.getEntityId())); assertFalse(validator.validate(EntityNames.STUDENT_COHORT_ASSOCIATION, idsToValidate).containsAll(idsToValidate)); }
|
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
StudentToStudentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(STUDENT_ASSOCIATIONS, entityType, ids)) { return Collections.emptySet(); } Set<String> otherStudentIds = new HashSet<String>(); Set<String> toValidateIds = new HashSet<String>(ids); Entity self = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> associations = self.getEmbeddedData().get(entityType); for(Entity assoc : associations) { if (ids.contains(assoc.getEntityId())) { toValidateIds.remove(assoc.getEntityId()); } } if (toValidateIds.isEmpty()) { return ids; } NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, toValidateIds)); Map<String, Set<String>> studentIdsToAssoc = new HashMap<String, Set<String>>(); for(Entity association : getRepo().findAll(entityType, query)) { Map<String, Object>body = association.getBody(); if (!isFieldExpired(body, ParameterConstants.END_DATE, false)) { String studentId = (String) body.get(ParameterConstants.STUDENT_ID); otherStudentIds.add(studentId); if(!studentIdsToAssoc.containsKey(studentId)) { studentIdsToAssoc.put(studentId, new HashSet<String>()); } studentIdsToAssoc.get(studentId).add(association.getEntityId()); } else { return Collections.emptySet(); } } Set<String> validStudentIds = studentValidator.validate(EntityNames.STUDENT, otherStudentIds); toValidateIds.removeAll(getValidIds(validStudentIds, studentIdsToAssoc)); Set<String> validIds = new HashSet<String>(ids); validIds.removeAll(toValidateIds); return validIds; } @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.