use of com.hack23.cia.model.external.worldbank.data.impl.Country in project cia by Hack23.
the class AdminCountryPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout content = createPanelContent();
final String pageId = getPageId(parameters);
final int pageNr = getPageNr(parameters);
getMenuItemFactory().createMainPageMenuBar(menuBar);
LabelFactory.createHeader2Label(content, ADMIN_COUNTRY);
final DataContainer<CountryElement, Long> dataContainer = getApplicationManager().getDataContainer(CountryElement.class);
final List<CountryElement> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, CountryElement_.countryName);
createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
getGridFactory().createBasicBeanItemNestedPropertiesGrid(content, CountryElement.class, pageOrderBy, COUNTRY2, null, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
if (pageId != null && !pageId.isEmpty()) {
final CountryElement country = dataContainer.load(Long.valueOf(pageId));
if (country != null) {
getFormFactory().addFormPanelTextFields(content, country, CountryElement.class, AS_LIST);
}
}
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_COUNTRY_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
return content;
}
use of com.hack23.cia.model.external.worldbank.data.impl.Country in project cia by Hack23.
the class WorldBankDataWorkGeneratorImpl method generateWorkOrders.
@Override
public void generateWorkOrders() {
final ApplicationConfiguration importDataForCountries = applicationConfigurationService.checkValueOrLoadDefault("Countries to import data from worldbank (isocode) alt comma separated list", "Load worldbank data for countries", ConfigurationGroup.AGENT, WorldBankCountryWorkGeneratorImpl.class.getSimpleName(), "Worldbank country data loading", "Responsible import worldlbank country data", "agent.worldbank.country.data.loadCountries", "SE,NO,DK,FI,GB,US");
final List<IndicatorElement> indicatorlist = getImportService().getAllIndicators();
final Map<String, String> currentSaved = getImportService().getWorldBankDataMap();
for (final String country : getImportService().getWorldBankCountryMap().keySet()) {
if (StringUtils.containsIgnoreCase(importDataForCountries.getPropertyValue(), country)) {
for (final IndicatorElement indicator : indicatorlist) {
sendCountryIndicatorWorkOrder(currentSaved, indicator, country);
}
}
}
}
use of com.hack23.cia.model.external.worldbank.data.impl.Country in project cia by Hack23.
the class CountryMenuItemFactoryImpl method addSourcesAndIndicatorsToMenu.
/**
* Adds the sources and indicators to menu.
*
* @param countryIndicators
* the country indicators
* @param sourceIndicatorMap
* the source indicator map
*/
private static void addSourcesAndIndicatorsToMenu(final MenuItem countryIndicators, final Map<String, List<ViewWorldbankIndicatorDataCountrySummary>> sourceIndicatorMap) {
final Map<String, List<ViewWorldbankIndicatorDataCountrySummary>> sortedIndicatorMap = sourceIndicatorMap.entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
for (final Entry<String, List<ViewWorldbankIndicatorDataCountrySummary>> entry : sortedIndicatorMap.entrySet()) {
final MenuItem sourceItems = countryIndicators.addItem(entry.getKey(), null, null);
final List<ViewWorldbankIndicatorDataCountrySummary> sortedEntries = entry.getValue().stream().sorted((e1, e2) -> e1.getIndicatorName().compareTo(e2.getIndicatorName())).collect(Collectors.toList());
for (final ViewWorldbankIndicatorDataCountrySummary indciatorSummary : sortedEntries) {
MenuItem addItem = sourceItems.addItem(indciatorSummary.getIndicatorName(), new PageModeMenuCommand(UserViews.COUNTRY_RANKING_VIEW_NAME, PageMode.INDICATORS, indciatorSummary.getEmbeddedId().getIndicatorId()));
addItem.setStyleName("RestrictedHeader");
}
}
}
use of com.hack23.cia.model.external.worldbank.data.impl.Country in project cia by Hack23.
the class AdminRoleSystemTest method siteAdminCountryTest.
/**
* Site admin country test.
*
* @throws Exception
* the exception
*/
@Test
public void siteAdminCountryTest() throws Exception {
final WebDriver driver = getWebDriver();
assertNotNull(NO_WEBDRIVER_EXIST_FOR_BROWSER + browser, driver);
final UserPageVisit userPageVisit = new UserPageVisit(driver, browser);
loginAsAdmin(userPageVisit);
userPageVisit.visitDirectPage(new PageModeMenuCommand(AdminViews.ADMIN_COUNTRY_VIEW_NAME, ""));
assertTrue("Expect content", userPageVisit.checkHtmlBodyContainsText("Country"));
clickFirstRowInGrid(userPageVisit);
userPageVisit.validatePage(new PageModeMenuCommand(AdminViews.ADMIN_COUNTRY_VIEW_NAME, ""));
}
use of com.hack23.cia.model.external.worldbank.data.impl.Country in project cia by Hack23.
the class UserRoleSystemTest method siteCountryRankingViewIndicatorsTest.
/**
* Site country ranking view indicators test.
*
* @throws Exception
* the exception
*/
@Test
public void siteCountryRankingViewIndicatorsTest() throws Exception {
final WebDriver driver = getWebDriver();
assertNotNull(NO_WEBDRIVER_EXIST_FOR_BROWSER + browser, driver);
final UserPageVisit userPageVisit = new UserPageVisit(driver, browser);
userPageVisit.visitDirectPage(new PageModeMenuCommand(UserViews.COUNTRY_RANKING_VIEW_NAME, PageMode.INDICATORS, "UIS.TEP.5.A"));
}
Aggregations