@Test public void testHierarchicalEdOrgs() { securityContextInjector.setStaffContext(); Entity edorg1 = createEntity(EntityNames.SCHOOL, "edorg1", new HashMap<String, Object>()); Mockito.when(repo.findAll(Mockito.eq(EntityNames.EDUCATION_ORGANIZATION), Mockito.any(NeutralQuery.class))).thenReturn( Arrays.asList(edorg1)); Mockito.when(helper.getParentEdOrgs(edorg1)).thenReturn(Arrays.asList("edorg1Parent1", "edorg1Parent2")); Map<String, Object> attendanceBody = new HashMap<String, Object>(); attendanceBody.put(ParameterConstants.SCHOOL_ID, "edorg1"); Entity attendance = createEntity(EntityNames.ATTENDANCE, "attendance1", attendanceBody); Set<String> edorgIds = arbiter.determineHierarchicalEdorgs(Arrays.asList(attendance), EntityNames.ATTENDANCE); Assert.assertEquals(3, edorgIds.size()); Assert.assertTrue(edorgIds.contains("edorg1")); Assert.assertTrue(edorgIds.contains("edorg1Parent1")); Assert.assertTrue(edorgIds.contains("edorg1Parent2")); }
public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; } }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }  }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }  @SuppressWarnings("unused") @PostConstruct void init(); Set<String> determineEdorgs(Iterable<Entity> entities, String entityType); Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType); boolean isEntityOwnedByEdOrg(String entityType); }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }  @SuppressWarnings("unused") @PostConstruct void init(); Set<String> determineEdorgs(Iterable<Entity> entities, String entityType); Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType); boolean isEntityOwnedByEdOrg(String entityType);  }