Search in sources :

Example 1 with Country

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;
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) CountryElement(com.hack23.cia.model.external.worldbank.countries.impl.CountryElement) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with Country

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);
            }
        }
    }
}
Also used : ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) IndicatorElement(com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)

Example 3 with 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");
        }
    }
}
Also used : PageMode(com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode) Arrays(java.util.Arrays) MenuItem(com.vaadin.ui.MenuBar.MenuItem) WorldbankIndicatorDataCountrySummaryEmbeddedId_(com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId_) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) Autowired(org.springframework.beans.factory.annotation.Autowired) ViewWorldbankIndicatorDataCountrySummary_(com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary_) LinkedHashMap(java.util.LinkedHashMap) PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) Service(org.springframework.stereotype.Service) Map(java.util.Map) ViewWorldbankIndicatorDataCountrySummary(com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary) VaadinIcons(com.vaadin.icons.VaadinIcons) SimpleEntry(java.util.AbstractMap.SimpleEntry) ContentRatio(com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio) MenuBar(com.vaadin.ui.MenuBar) UserViews(com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews) Collectors(java.util.stream.Collectors) ApplicationManager(com.hack23.cia.service.api.ApplicationManager) CountryMenuItemFactory(com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.CountryMenuItemFactory) DataContainer(com.hack23.cia.service.api.DataContainer) AbstractMap(java.util.AbstractMap) List(java.util.List) ApplicationMenuItemFactory(com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory) WorldbankIndicatorDataCountrySummaryEmbeddedId(com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId) Entry(java.util.Map.Entry) PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) ViewWorldbankIndicatorDataCountrySummary(com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary) List(java.util.List) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap)

Example 4 with Country

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, ""));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) Test(org.junit.Test)

Example 5 with Country

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"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) Test(org.junit.Test)

Aggregations

PageModeMenuCommand (com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand)4 Test (org.junit.Test)3 WebDriver (org.openqa.selenium.WebDriver)3 VerticalLayout (com.vaadin.ui.VerticalLayout)2 List (java.util.List)2 CountryElement (com.hack23.cia.model.external.worldbank.countries.impl.CountryElement)1 Country (com.hack23.cia.model.external.worldbank.data.impl.Country)1 WorldBankData (com.hack23.cia.model.external.worldbank.data.impl.WorldBankData)1 IndicatorElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)1 ViewWorldbankIndicatorDataCountrySummary (com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary)1 ViewWorldbankIndicatorDataCountrySummary_ (com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary_)1 WorldbankIndicatorDataCountrySummaryEmbeddedId (com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId)1 WorldbankIndicatorDataCountrySummaryEmbeddedId_ (com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId_)1 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)1 ApplicationManager (com.hack23.cia.service.api.ApplicationManager)1 DataContainer (com.hack23.cia.service.api.DataContainer)1 ApplicationMenuItemFactory (com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory)1 CountryMenuItemFactory (com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.CountryMenuItemFactory)1 ContentRatio (com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio)1 PageMode (com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode)1