use of com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary 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.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary 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);
}
use of com.hack23.cia.model.internal.application.data.impl.ViewWorldbankIndicatorDataCountrySummary 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);
}
Aggregations