Search in sources :

Example 1 with WorldBankData

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

the class WorldIndicatorChartDataManagerImpl method createIndicatorChart.

@Override
public void createIndicatorChart(final AbstractOrderedLayout content, final List<WorldBankData> list, final ViewWorldbankIndicatorDataCountrySummary summary) {
    final Map<Country, List<WorldBankData>> countryIndicatorsMap = list.stream().collect(Collectors.groupingBy(WorldBankData::getCountry, Collectors.toList()));
    final Series series = new Series();
    final DataSeries dataSeries = new DataSeries();
    for (final Entry<Country, List<WorldBankData>> entry : countryIndicatorsMap.entrySet()) {
        series.addSeries(new XYseries().setLabel(entry.getKey().getValue()));
        dataSeries.newSeries();
        for (final WorldBankData item : entry.getValue()) {
            if (item != null && item.getYearDate() != null && item.getDataValue() != null && !item.getDataValue().isEmpty()) {
                dataSeries.add(item.getYearDate() + "-01-01", Float.valueOf(item.getDataValue()));
            }
        }
    }
    addChart(content, summary.getIndicatorName(), new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsCountryLineChart(series)).show(), false);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) WorldBankData(com.hack23.cia.model.external.worldbank.data.impl.WorldBankData) Country(com.hack23.cia.model.external.worldbank.data.impl.Country) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Example 2 with WorldBankData

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

WorldBankData (com.hack23.cia.model.external.worldbank.data.impl.WorldBankData)2 List (java.util.List)2 Country (com.hack23.cia.model.external.worldbank.data.impl.Country)1 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 ViewWorldbankIndicatorDataCountrySummary (com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary)1 WorldbankIndicatorDataCountrySummaryEmbeddedId (com.hack23.cia.model.internal.application.data.impl.WorldbankIndicatorDataCountrySummaryEmbeddedId)1 ApplicationEventGroup (com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup)1 DataContainer (com.hack23.cia.service.api.DataContainer)1 ViewAction (com.hack23.cia.web.impl.ui.application.action.ViewAction)1 WorldIndicatorChartDataManager (com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.WorldIndicatorChartDataManager)1 PageMode (com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode)1 Layout (com.vaadin.ui.Layout)1 MenuBar (com.vaadin.ui.MenuBar)1 Panel (com.vaadin.ui.Panel)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Serializable (java.io.Serializable)1 Arrays (java.util.Arrays)1 Optional (java.util.Optional)1