@Test public void testGetUserEdOrg() { this.testInstitutionalHierarchyManagerImpl = new UserEdOrgManagerImpl() { @Override public String getToken() { return ""; } @Override protected boolean isEducator() { return false; } }; this.testInstitutionalHierarchyManagerImpl.setApiClient(apiClient); EdOrgKey edOrgKey1 = this.testInstitutionalHierarchyManagerImpl.getUserEdOrg(Constants.STATE_EDUCATION_AGENCY); Assert.assertEquals("2012ny-09327920-e000-11e1-9f3b-3c07546832b4", edOrgKey1.getSliId()); EdOrgKey edOrgKey2 = this.testInstitutionalHierarchyManagerImpl.getUserEdOrg(Constants.LOCAL_EDUCATION_AGENCY); Assert.assertEquals("2012zj-0b0711a4-e000-11e1-9f3b-3c07546832b4", edOrgKey2.getSliId()); this.testInstitutionalHierarchyManagerImpl = new UserEdOrgManagerImpl() { @Override public String getToken() { return ""; } @Override protected boolean isEducator() { return true; } }; this.testInstitutionalHierarchyManagerImpl.setApiClient(apiClient); EdOrgKey edOrgKey3 = this.testInstitutionalHierarchyManagerImpl.getUserEdOrg("Teacher"); Assert.assertEquals("2012zj-0b0711a4-e000-11e1-9f3b-3c07546832b4", edOrgKey3.getSliId()); }
@Override @CacheableUserData public EdOrgKey getUserEdOrg(String token) { GenericEntity edOrg = null; if (!isEducator()) { String id = getApiClient().getId(token); GenericEntity staff = getApiClient().getStaffWithEducationOrganization(token, id, null); if (staff != null) { GenericEntity staffEdOrg = (GenericEntity) staff.get(Constants.ATTR_ED_ORG); if (staffEdOrg != null) { @SuppressWarnings("unchecked") List<String> edOrgCategories = (List<String>) staffEdOrg.get(Constants.ATTR_ORG_CATEGORIES); if (edOrgCategories != null && !edOrgCategories.isEmpty()) { for (String edOrgCategory : edOrgCategories) { if (edOrgCategory.equals(Constants.STATE_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } else if (edOrgCategory.equals(Constants.LOCAL_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } } } } } } if (edOrg == null) { List<GenericEntity> schools = getMySchools(token); if (schools != null && !schools.isEmpty()) { GenericEntity school = schools.get(0); edOrg = getParentEducationalOrganization(getToken(), school); if (edOrg == null) { throw new DashboardException( "No data is available for you to view. Please contact your IT administrator."); } } } if (edOrg != null) { return new EdOrgKey(edOrg.getId()); } return null; }
UserEdOrgManagerImpl extends ApiClientManager implements UserEdOrgManager { @Override @CacheableUserData public EdOrgKey getUserEdOrg(String token) { GenericEntity edOrg = null; if (!isEducator()) { String id = getApiClient().getId(token); GenericEntity staff = getApiClient().getStaffWithEducationOrganization(token, id, null); if (staff != null) { GenericEntity staffEdOrg = (GenericEntity) staff.get(Constants.ATTR_ED_ORG); if (staffEdOrg != null) { @SuppressWarnings("unchecked") List<String> edOrgCategories = (List<String>) staffEdOrg.get(Constants.ATTR_ORG_CATEGORIES); if (edOrgCategories != null && !edOrgCategories.isEmpty()) { for (String edOrgCategory : edOrgCategories) { if (edOrgCategory.equals(Constants.STATE_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } else if (edOrgCategory.equals(Constants.LOCAL_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } } } } } } if (edOrg == null) { List<GenericEntity> schools = getMySchools(token); if (schools != null && !schools.isEmpty()) { GenericEntity school = schools.get(0); edOrg = getParentEducationalOrganization(getToken(), school); if (edOrg == null) { throw new DashboardException( "No data is available for you to view. Please contact your IT administrator."); } } } if (edOrg != null) { return new EdOrgKey(edOrg.getId()); } return null; } }
UserEdOrgManagerImpl extends ApiClientManager implements UserEdOrgManager { @Override @CacheableUserData public EdOrgKey getUserEdOrg(String token) { GenericEntity edOrg = null; if (!isEducator()) { String id = getApiClient().getId(token); GenericEntity staff = getApiClient().getStaffWithEducationOrganization(token, id, null); if (staff != null) { GenericEntity staffEdOrg = (GenericEntity) staff.get(Constants.ATTR_ED_ORG); if (staffEdOrg != null) { @SuppressWarnings("unchecked") List<String> edOrgCategories = (List<String>) staffEdOrg.get(Constants.ATTR_ORG_CATEGORIES); if (edOrgCategories != null && !edOrgCategories.isEmpty()) { for (String edOrgCategory : edOrgCategories) { if (edOrgCategory.equals(Constants.STATE_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } else if (edOrgCategory.equals(Constants.LOCAL_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } } } } } } if (edOrg == null) { List<GenericEntity> schools = getMySchools(token); if (schools != null && !schools.isEmpty()) { GenericEntity school = schools.get(0); edOrg = getParentEducationalOrganization(getToken(), school); if (edOrg == null) { throw new DashboardException( "No data is available for you to view. Please contact your IT administrator."); } } } if (edOrg != null) { return new EdOrgKey(edOrg.getId()); } return null; }  }
UserEdOrgManagerImpl extends ApiClientManager implements UserEdOrgManager { @Override @CacheableUserData public EdOrgKey getUserEdOrg(String token) { GenericEntity edOrg = null; if (!isEducator()) { String id = getApiClient().getId(token); GenericEntity staff = getApiClient().getStaffWithEducationOrganization(token, id, null); if (staff != null) { GenericEntity staffEdOrg = (GenericEntity) staff.get(Constants.ATTR_ED_ORG); if (staffEdOrg != null) { @SuppressWarnings("unchecked") List<String> edOrgCategories = (List<String>) staffEdOrg.get(Constants.ATTR_ORG_CATEGORIES); if (edOrgCategories != null && !edOrgCategories.isEmpty()) { for (String edOrgCategory : edOrgCategories) { if (edOrgCategory.equals(Constants.STATE_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } else if (edOrgCategory.equals(Constants.LOCAL_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } } } } } } if (edOrg == null) { List<GenericEntity> schools = getMySchools(token); if (schools != null && !schools.isEmpty()) { GenericEntity school = schools.get(0); edOrg = getParentEducationalOrganization(getToken(), school); if (edOrg == null) { throw new DashboardException( "No data is available for you to view. Please contact your IT administrator."); } } } if (edOrg != null) { return new EdOrgKey(edOrg.getId()); } return null; }  @Override @CacheableUserData EdOrgKey getUserEdOrg(String token); @Override @CacheableUserData GenericEntity getUserInstHierarchy(String token, Object key, Data config); @Override GenericEntity getUserCoursesAndSections(String token, Object schoolIdObj, Data config); @Override @SuppressWarnings("unchecked") GenericEntity getUserSectionList(String token, Object schoolIdObj, Data config); @Override GenericEntity getStaffInfo(String token); @Override @SuppressWarnings("unchecked") GenericEntity getSchoolInfo(String token, Object schoolIdObj, Data config); }
UserEdOrgManagerImpl extends ApiClientManager implements UserEdOrgManager { @Override @CacheableUserData public EdOrgKey getUserEdOrg(String token) { GenericEntity edOrg = null; if (!isEducator()) { String id = getApiClient().getId(token); GenericEntity staff = getApiClient().getStaffWithEducationOrganization(token, id, null); if (staff != null) { GenericEntity staffEdOrg = (GenericEntity) staff.get(Constants.ATTR_ED_ORG); if (staffEdOrg != null) { @SuppressWarnings("unchecked") List<String> edOrgCategories = (List<String>) staffEdOrg.get(Constants.ATTR_ORG_CATEGORIES); if (edOrgCategories != null && !edOrgCategories.isEmpty()) { for (String edOrgCategory : edOrgCategories) { if (edOrgCategory.equals(Constants.STATE_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } else if (edOrgCategory.equals(Constants.LOCAL_EDUCATION_AGENCY)) { edOrg = staffEdOrg; break; } } } } } } if (edOrg == null) { List<GenericEntity> schools = getMySchools(token); if (schools != null && !schools.isEmpty()) { GenericEntity school = schools.get(0); edOrg = getParentEducationalOrganization(getToken(), school); if (edOrg == null) { throw new DashboardException( "No data is available for you to view. Please contact your IT administrator."); } } } if (edOrg != null) { return new EdOrgKey(edOrg.getId()); } return null; }  @Override @CacheableUserData EdOrgKey getUserEdOrg(String token); @Override @CacheableUserData GenericEntity getUserInstHierarchy(String token, Object key, Data config); @Override GenericEntity getUserCoursesAndSections(String token, Object schoolIdObj, Data config); @Override @SuppressWarnings("unchecked") GenericEntity getUserSectionList(String token, Object schoolIdObj, Data config); @Override GenericEntity getStaffInfo(String token); @Override @SuppressWarnings("unchecked") GenericEntity getSchoolInfo(String token, Object schoolIdObj, Data config);  }