@Test public void testGetAllConfigByType() { configManager = new ConfigManagerImpl(); configManager.setApiClient(apiClient); configManager.setDriverConfigLocation("config"); configManager.setUserConfigLocation("custom"); Map<String, String> params = new HashMap<String, String>(); params.put("type", "PANEL"); String edOrgId = "2012de-df94acd2-e7cd-11e1-a937-68a86d3c2f82"; Map<String, Collection<Config>> mapConfigs = configManager.getAllConfigByType("token", new EdOrgKey(edOrgId), params); Assert.assertEquals(3, mapConfigs.size()); Collection<Config> defaultConfig = mapConfigs.get("default"); Assert.assertNotNull(defaultConfig); Assert.assertEquals(10, defaultConfig.size()); Collection<Config> sea = mapConfigs.get("State Education Agency"); Assert.assertNotNull(sea); Assert.assertEquals(1, sea.size()); Collection<Config> lea = mapConfigs.get("Local Education Agency"); Assert.assertNotNull(lea); Assert.assertEquals(1, lea.size()); }
@Override public Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey, Map<String, String> params) { Map<String, Collection<Config>> allConfigs = new HashMap<String, Collection<Config>>(); Set<String> configIdLookup = new HashSet<String>(); Map<String, String> attribute = new HashMap<String, String>(); String layoutName = params.get(LAYOUT_NAME); if (params.containsKey(TYPE)) { attribute.put(TYPE, params.get(TYPE)); } Collection<Config> driverConfigs = getConfigsByAttribute(token, edOrgKey, attribute, false); Iterator<Config> configIterator = driverConfigs.iterator(); while (configIterator.hasNext()) { Config driverConfig = configIterator.next(); if (doesBelongToLayout(driverConfig, layoutName)) { configIdLookup.add(driverConfig.getId()); } else { configIterator.remove(); } } allConfigs.put(DEFAULT, driverConfigs); APIClient apiClient = getApiClient(); EdOrgKey loopEdOrgKey = edOrgKey; while (loopEdOrgKey != null) { Collection<Config> customConfigByType = new LinkedList<Config>(); ConfigMap customConfigMap = getCustomConfig(token, loopEdOrgKey); if (customConfigMap != null) { Map<String, Config> configByMap = customConfigMap.getConfig(); if (configByMap != null) { Collection<Config> customConfigs = configByMap.values(); if (customConfigs != null) { for (Config customConfig : customConfigs) { String parentId = customConfig.getParentId(); if (parentId != null && configIdLookup.contains(parentId)) { if (doesBelongToLayout(customConfig, layoutName)) { customConfigByType.add(customConfig); } } } } } } GenericEntity edOrg = apiClient.getEducationalOrganization(token, loopEdOrgKey.getSliId()); List<String> organizationCategories = (List<String>) edOrg.get(Constants.ATTR_ORG_CATEGORIES); if (organizationCategories != null && !organizationCategories.isEmpty()) { for (String educationAgency : organizationCategories) { if (educationAgency != null) { allConfigs.put(educationAgency, customConfigByType); break; } } } loopEdOrgKey = null; edOrg = apiClient.getParentEducationalOrganization(token, edOrg); if (edOrg != null) { String id = edOrg.getId(); if (id != null && !id.isEmpty()) { loopEdOrgKey = new EdOrgKey(id); } } } return allConfigs; }
ConfigManagerImpl extends ApiClientManager implements ConfigManager { @Override public Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey, Map<String, String> params) { Map<String, Collection<Config>> allConfigs = new HashMap<String, Collection<Config>>(); Set<String> configIdLookup = new HashSet<String>(); Map<String, String> attribute = new HashMap<String, String>(); String layoutName = params.get(LAYOUT_NAME); if (params.containsKey(TYPE)) { attribute.put(TYPE, params.get(TYPE)); } Collection<Config> driverConfigs = getConfigsByAttribute(token, edOrgKey, attribute, false); Iterator<Config> configIterator = driverConfigs.iterator(); while (configIterator.hasNext()) { Config driverConfig = configIterator.next(); if (doesBelongToLayout(driverConfig, layoutName)) { configIdLookup.add(driverConfig.getId()); } else { configIterator.remove(); } } allConfigs.put(DEFAULT, driverConfigs); APIClient apiClient = getApiClient(); EdOrgKey loopEdOrgKey = edOrgKey; while (loopEdOrgKey != null) { Collection<Config> customConfigByType = new LinkedList<Config>(); ConfigMap customConfigMap = getCustomConfig(token, loopEdOrgKey); if (customConfigMap != null) { Map<String, Config> configByMap = customConfigMap.getConfig(); if (configByMap != null) { Collection<Config> customConfigs = configByMap.values(); if (customConfigs != null) { for (Config customConfig : customConfigs) { String parentId = customConfig.getParentId(); if (parentId != null && configIdLookup.contains(parentId)) { if (doesBelongToLayout(customConfig, layoutName)) { customConfigByType.add(customConfig); } } } } } } GenericEntity edOrg = apiClient.getEducationalOrganization(token, loopEdOrgKey.getSliId()); List<String> organizationCategories = (List<String>) edOrg.get(Constants.ATTR_ORG_CATEGORIES); if (organizationCategories != null && !organizationCategories.isEmpty()) { for (String educationAgency : organizationCategories) { if (educationAgency != null) { allConfigs.put(educationAgency, customConfigByType); break; } } } loopEdOrgKey = null; edOrg = apiClient.getParentEducationalOrganization(token, edOrg); if (edOrg != null) { String id = edOrg.getId(); if (id != null && !id.isEmpty()) { loopEdOrgKey = new EdOrgKey(id); } } } return allConfigs; } }
ConfigManagerImpl extends ApiClientManager implements ConfigManager { @Override public Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey, Map<String, String> params) { Map<String, Collection<Config>> allConfigs = new HashMap<String, Collection<Config>>(); Set<String> configIdLookup = new HashSet<String>(); Map<String, String> attribute = new HashMap<String, String>(); String layoutName = params.get(LAYOUT_NAME); if (params.containsKey(TYPE)) { attribute.put(TYPE, params.get(TYPE)); } Collection<Config> driverConfigs = getConfigsByAttribute(token, edOrgKey, attribute, false); Iterator<Config> configIterator = driverConfigs.iterator(); while (configIterator.hasNext()) { Config driverConfig = configIterator.next(); if (doesBelongToLayout(driverConfig, layoutName)) { configIdLookup.add(driverConfig.getId()); } else { configIterator.remove(); } } allConfigs.put(DEFAULT, driverConfigs); APIClient apiClient = getApiClient(); EdOrgKey loopEdOrgKey = edOrgKey; while (loopEdOrgKey != null) { Collection<Config> customConfigByType = new LinkedList<Config>(); ConfigMap customConfigMap = getCustomConfig(token, loopEdOrgKey); if (customConfigMap != null) { Map<String, Config> configByMap = customConfigMap.getConfig(); if (configByMap != null) { Collection<Config> customConfigs = configByMap.values(); if (customConfigs != null) { for (Config customConfig : customConfigs) { String parentId = customConfig.getParentId(); if (parentId != null && configIdLookup.contains(parentId)) { if (doesBelongToLayout(customConfig, layoutName)) { customConfigByType.add(customConfig); } } } } } } GenericEntity edOrg = apiClient.getEducationalOrganization(token, loopEdOrgKey.getSliId()); List<String> organizationCategories = (List<String>) edOrg.get(Constants.ATTR_ORG_CATEGORIES); if (organizationCategories != null && !organizationCategories.isEmpty()) { for (String educationAgency : organizationCategories) { if (educationAgency != null) { allConfigs.put(educationAgency, customConfigByType); break; } } } loopEdOrgKey = null; edOrg = apiClient.getParentEducationalOrganization(token, edOrg); if (edOrg != null) { String id = edOrg.getId(); if (id != null && !id.isEmpty()) { loopEdOrgKey = new EdOrgKey(id); } } } return allConfigs; } ConfigManagerImpl(); }
ConfigManagerImpl extends ApiClientManager implements ConfigManager { @Override public Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey, Map<String, String> params) { Map<String, Collection<Config>> allConfigs = new HashMap<String, Collection<Config>>(); Set<String> configIdLookup = new HashSet<String>(); Map<String, String> attribute = new HashMap<String, String>(); String layoutName = params.get(LAYOUT_NAME); if (params.containsKey(TYPE)) { attribute.put(TYPE, params.get(TYPE)); } Collection<Config> driverConfigs = getConfigsByAttribute(token, edOrgKey, attribute, false); Iterator<Config> configIterator = driverConfigs.iterator(); while (configIterator.hasNext()) { Config driverConfig = configIterator.next(); if (doesBelongToLayout(driverConfig, layoutName)) { configIdLookup.add(driverConfig.getId()); } else { configIterator.remove(); } } allConfigs.put(DEFAULT, driverConfigs); APIClient apiClient = getApiClient(); EdOrgKey loopEdOrgKey = edOrgKey; while (loopEdOrgKey != null) { Collection<Config> customConfigByType = new LinkedList<Config>(); ConfigMap customConfigMap = getCustomConfig(token, loopEdOrgKey); if (customConfigMap != null) { Map<String, Config> configByMap = customConfigMap.getConfig(); if (configByMap != null) { Collection<Config> customConfigs = configByMap.values(); if (customConfigs != null) { for (Config customConfig : customConfigs) { String parentId = customConfig.getParentId(); if (parentId != null && configIdLookup.contains(parentId)) { if (doesBelongToLayout(customConfig, layoutName)) { customConfigByType.add(customConfig); } } } } } } GenericEntity edOrg = apiClient.getEducationalOrganization(token, loopEdOrgKey.getSliId()); List<String> organizationCategories = (List<String>) edOrg.get(Constants.ATTR_ORG_CATEGORIES); if (organizationCategories != null && !organizationCategories.isEmpty()) { for (String educationAgency : organizationCategories) { if (educationAgency != null) { allConfigs.put(educationAgency, customConfigByType); break; } } } loopEdOrgKey = null; edOrg = apiClient.getParentEducationalOrganization(token, edOrg); if (edOrg != null) { String id = edOrg.getId(); if (id != null && !id.isEmpty()) { loopEdOrgKey = new EdOrgKey(id); } } } return allConfigs; } ConfigManagerImpl(); void setDriverConfigLocation(String configLocation); void setUserConfigLocation(String configLocation); String getComponentConfigLocation(String path, String componentId); String getDriverConfigLocation(String componentId); @Override @CacheableConfig Config getComponentConfig(String token, EdOrgKey edOrgKey, String componentId); @Override @Cacheable(value = Constants.CACHE_USER_WIDGET_CONFIG) Collection<Config> getWidgetConfigs(String token, EdOrgKey edOrgKey); @Override Collection<Config> getConfigsByAttribute(String token, EdOrgKey edOrgKey, Map<String, String> attrs); @Override Collection<Config> getConfigsByAttribute(String token, EdOrgKey edOrgKey, Map<String, String> attrs,
            boolean overwriteCustomConfig); @Override ConfigMap getCustomConfig(String token, EdOrgKey edOrgKey); @Override @CacheEvict(value = Constants.CACHE_USER_PANEL_CONFIG, allEntries = true) void putCustomConfig(String token, EdOrgKey edOrgKey, ConfigMap configMap); @Override @CacheEvict(value = Constants.CACHE_USER_PANEL_CONFIG, allEntries = true) void putCustomConfig(String token, EdOrgKey edOrgKey, Config config); @Override Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey,
            Map<String, String> params); }
ConfigManagerImpl extends ApiClientManager implements ConfigManager { @Override public Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey, Map<String, String> params) { Map<String, Collection<Config>> allConfigs = new HashMap<String, Collection<Config>>(); Set<String> configIdLookup = new HashSet<String>(); Map<String, String> attribute = new HashMap<String, String>(); String layoutName = params.get(LAYOUT_NAME); if (params.containsKey(TYPE)) { attribute.put(TYPE, params.get(TYPE)); } Collection<Config> driverConfigs = getConfigsByAttribute(token, edOrgKey, attribute, false); Iterator<Config> configIterator = driverConfigs.iterator(); while (configIterator.hasNext()) { Config driverConfig = configIterator.next(); if (doesBelongToLayout(driverConfig, layoutName)) { configIdLookup.add(driverConfig.getId()); } else { configIterator.remove(); } } allConfigs.put(DEFAULT, driverConfigs); APIClient apiClient = getApiClient(); EdOrgKey loopEdOrgKey = edOrgKey; while (loopEdOrgKey != null) { Collection<Config> customConfigByType = new LinkedList<Config>(); ConfigMap customConfigMap = getCustomConfig(token, loopEdOrgKey); if (customConfigMap != null) { Map<String, Config> configByMap = customConfigMap.getConfig(); if (configByMap != null) { Collection<Config> customConfigs = configByMap.values(); if (customConfigs != null) { for (Config customConfig : customConfigs) { String parentId = customConfig.getParentId(); if (parentId != null && configIdLookup.contains(parentId)) { if (doesBelongToLayout(customConfig, layoutName)) { customConfigByType.add(customConfig); } } } } } } GenericEntity edOrg = apiClient.getEducationalOrganization(token, loopEdOrgKey.getSliId()); List<String> organizationCategories = (List<String>) edOrg.get(Constants.ATTR_ORG_CATEGORIES); if (organizationCategories != null && !organizationCategories.isEmpty()) { for (String educationAgency : organizationCategories) { if (educationAgency != null) { allConfigs.put(educationAgency, customConfigByType); break; } } } loopEdOrgKey = null; edOrg = apiClient.getParentEducationalOrganization(token, edOrg); if (edOrg != null) { String id = edOrg.getId(); if (id != null && !id.isEmpty()) { loopEdOrgKey = new EdOrgKey(id); } } } return allConfigs; } ConfigManagerImpl(); void setDriverConfigLocation(String configLocation); void setUserConfigLocation(String configLocation); String getComponentConfigLocation(String path, String componentId); String getDriverConfigLocation(String componentId); @Override @CacheableConfig Config getComponentConfig(String token, EdOrgKey edOrgKey, String componentId); @Override @Cacheable(value = Constants.CACHE_USER_WIDGET_CONFIG) Collection<Config> getWidgetConfigs(String token, EdOrgKey edOrgKey); @Override Collection<Config> getConfigsByAttribute(String token, EdOrgKey edOrgKey, Map<String, String> attrs); @Override Collection<Config> getConfigsByAttribute(String token, EdOrgKey edOrgKey, Map<String, String> attrs,
            boolean overwriteCustomConfig); @Override ConfigMap getCustomConfig(String token, EdOrgKey edOrgKey); @Override @CacheEvict(value = Constants.CACHE_USER_PANEL_CONFIG, allEntries = true) void putCustomConfig(String token, EdOrgKey edOrgKey, ConfigMap configMap); @Override @CacheEvict(value = Constants.CACHE_USER_PANEL_CONFIG, allEntries = true) void putCustomConfig(String token, EdOrgKey edOrgKey, Config config); @Override Map<String, Collection<Config>> getAllConfigByType(String token, EdOrgKey edOrgKey,
            Map<String, String> params);  }