Search in sources :

Example 1 with Indicator

use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.

the class PoliticianDataManagerImpl method addPoliticianIndicatorData.

/**
 * Adds the politician indicator data.
 *
 * @param list
 *            the list
 * @param dataSeries
 *            the data series
 * @param simpleDateFormat
 *            the simple date format
 */
private static void addPoliticianIndicatorData(final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> list, final DataSeries dataSeries, final SimpleDateFormat simpleDateFormat) {
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getWonPercentage());
        }
    }
    dataSeries.newSeries();
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getRebelPercentage());
        }
    }
    dataSeries.newSeries();
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getPoliticianPercentageAbsent());
        }
    }
    dataSeries.newSeries();
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getNumberBallots());
        }
    }
}
Also used : ViewRiksdagenVoteDataBallotPoliticianSummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)

Example 2 with Indicator

use of com.hack23.cia.model.external.worldbank.data.impl.Indicator 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 Indicator

use of com.hack23.cia.model.external.worldbank.data.impl.Indicator 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 Indicator

use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.

the class UserRoleSystemTest method sitePoliticanIndicatorTest.

/**
 * Site politican indicator test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void sitePoliticanIndicatorTest() 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.POLITICIAN_VIEW_NAME, PageMode.INDICATORS.toString(), "0980681611418"));
}
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 Indicator

use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.

the class WorldIndicatorsPageModContentFactoryImpl method createDataIndicatorSummaryChartPanel.

/**
 * Creates the data indicator summary chart panel.
 *
 * @param verticalLayout
 *            the vertical layout
 * @param indicator
 *            the indicator
 */
private void createDataIndicatorSummaryChartPanel(final VerticalLayout verticalLayout, final String indicator) {
    final DataContainer<ViewWorldbankIndicatorDataCountrySummary, WorldbankIndicatorDataCountrySummaryEmbeddedId> indicatorDataCountrSummaryDailyDataContainer = getApplicationManager().getDataContainer(ViewWorldbankIndicatorDataCountrySummary.class);
    final Optional<ViewWorldbankIndicatorDataCountrySummary> indicatorSummary = indicatorDataCountrSummaryDailyDataContainer.getAll().parallelStream().filter(t -> t != null && t.getEmbeddedId().getIndicatorId().equals(indicator)).findFirst();
    ViewWorldbankIndicatorDataCountrySummary indicatorSummaryValue = null;
    if (indicatorSummary.isPresent()) {
        indicatorSummaryValue = indicatorSummary.get();
        getFormFactory().addFormPanelTextFields(verticalLayout, indicatorSummaryValue, ViewWorldbankIndicatorDataCountrySummary.class, AS_LIST);
    }
    final DataContainer<WorldBankData, Serializable> dataContainer = getApplicationManager().getDataContainer(WorldBankData.class);
    final List<WorldBankData> dataList = dataContainer.findListByEmbeddedProperty(WorldBankData.class, WorldBankData_.indicator, Indicator.class, Indicator_.id, indicator);
    chartDataManager.createIndicatorChart(verticalLayout, dataList, indicatorSummaryValue);
}
Also used : PageMode(com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode) Panel(com.vaadin.ui.Panel) Arrays(java.util.Arrays) MenuBar(com.vaadin.ui.MenuBar) ApplicationEventGroup(com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup) VerticalLayout(com.vaadin.ui.VerticalLayout) WorldBankData_(com.hack23.cia.model.external.worldbank.data.impl.WorldBankData_) Autowired(org.springframework.beans.factory.annotation.Autowired) Indicator_(com.hack23.cia.model.external.worldbank.data.impl.Indicator_) Serializable(java.io.Serializable) Secured(org.springframework.security.access.annotation.Secured) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Component(org.springframework.stereotype.Component) WorldBankData(com.hack23.cia.model.external.worldbank.data.impl.WorldBankData) Layout(com.vaadin.ui.Layout) ViewAction(com.hack23.cia.web.impl.ui.application.action.ViewAction) Indicator(com.hack23.cia.model.external.worldbank.data.impl.Indicator) WorldbankIndicatorDataCountrySummaryEmbeddedId(com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId) ViewWorldbankIndicatorDataCountrySummary(com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary) Optional(java.util.Optional) WorldIndicatorChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.WorldIndicatorChartDataManager) WorldbankIndicatorDataCountrySummaryEmbeddedId(com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId) ViewWorldbankIndicatorDataCountrySummary(com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary) Serializable(java.io.Serializable) WorldBankData(com.hack23.cia.model.external.worldbank.data.impl.WorldBankData)

Aggregations

ViewWorldbankIndicatorDataCountrySummary (com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary)2 WorldbankIndicatorDataCountrySummaryEmbeddedId (com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId)2 DataContainer (com.hack23.cia.service.api.DataContainer)2 PageModeMenuCommand (com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand)2 PageMode (com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode)2 MenuBar (com.vaadin.ui.MenuBar)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Indicator (com.hack23.cia.model.external.worldbank.data.impl.Indicator)1 Indicator_ (com.hack23.cia.model.external.worldbank.data.impl.Indicator_)1 WorldBankData (com.hack23.cia.model.external.worldbank.data.impl.WorldBankData)1 WorldBankData_ (com.hack23.cia.model.external.worldbank.data.impl.WorldBankData_)1 IndicatorElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)1 ViewRiksdagenVoteDataBallotPoliticianSummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)1 ViewWorldbankIndicatorDataCountrySummary_ (com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary_)1 WorldbankIndicatorDataCountrySummaryEmbeddedId_ (com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId_)1 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)1 ApplicationEventGroup (com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup)1