Search in sources :

Example 1 with ViewRiksdagenCommitteeDecisionTypeOrgDailySummary

use of com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary in project cia by Hack23.

the class DecisionChartDataManagerImpl method createDecisionTypeChart.

@Override
public void createDecisionTypeChart(final AbstractOrderedLayout content, final String org) {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> allMap = getCommitteeDecisionTypeOrgMap();
    final List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary> itemList = allMap.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> map = itemList.parallelStream().filter(t -> t != null && t.getEmbeddedId().getDecisionDate() != null).collect(Collectors.groupingBy(t -> t.getEmbeddedId().getDecisionType()));
        addDecisionTypeByOrgData(simpleDateFormat, dataSeries, series, map);
    }
    addChart(content, "Org Decision type daily summary", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) Collectors(java.util.stream.Collectors) DecisionChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionChartDataManager) ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) Objects(java.util.Objects) RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId) DCharts(org.dussan.vaadin.dcharts.DCharts) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Calendar(java.util.Calendar) ViewRiksdagenCommitteeDecisionTypeDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary) RiksdagenCommitteeDecisionTypeSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeSummaryEmbeddedId) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) Map(java.util.Map) Series(org.dussan.vaadin.dcharts.options.Series) Entry(java.util.Map.Entry) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with ViewRiksdagenCommitteeDecisionTypeOrgDailySummary

use of com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary in project cia by Hack23.

the class DecisionChartDataManagerImpl method addDecisionTypeByOrgData.

/**
 * Adds the decision type by org data.
 *
 * @param simpleDateFormat
 *            the simple date format
 * @param dataSeries
 *            the data series
 * @param series
 *            the series
 * @param map
 *            the map
 */
private static void addDecisionTypeByOrgData(final SimpleDateFormat simpleDateFormat, final DataSeries dataSeries, final Series series, final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> map) {
    for (final Entry<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> entry : map.entrySet()) {
        if (!EMPTY_STRING.equals(entry.getKey())) {
            final XYseries label = new XYseries();
            label.setLabel(entry.getKey());
            series.addSeries(label);
            dataSeries.newSeries();
            for (final ViewRiksdagenCommitteeDecisionTypeOrgDailySummary item : entry.getValue()) {
                if (item != null) {
                    dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getDecisionDate()), item.getTotal());
                }
            }
        }
    }
}
Also used : ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) List(java.util.List) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Aggregations

ViewRiksdagenCommitteeDecisionTypeOrgDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary)2 List (java.util.List)2 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)2 RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId (com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId)1 RiksdagenCommitteeDecisionTypeSummaryEmbeddedId (com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeSummaryEmbeddedId)1 ViewRiksdagenCommitteeDecisionTypeDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary)1 DataContainer (com.hack23.cia.service.api.DataContainer)1 DecisionChartDataManager (com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionChartDataManager)1 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 DCharts (org.dussan.vaadin.dcharts.DCharts)1 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)1