Search in sources :

Example 1 with ViewRiksdagenCommitteeDecisionTypeDailySummary

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

the class DecisionChartDataManagerImpl method createDecisionTypeChart.

@Override
public void createDecisionTypeChart(final AbstractOrderedLayout content) {
    final Map<String, List<ViewRiksdagenCommitteeDecisionTypeDailySummary>> map = getCommitteeDecisionTypeMap();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    for (final Entry<String, List<ViewRiksdagenCommitteeDecisionTypeDailySummary>> entry : map.entrySet()) {
        if (entry.getKey() != null) {
            series.addSeries(new XYseries().setLabel(entry.getKey()));
            dataSeries.newSeries();
            final List<ViewRiksdagenCommitteeDecisionTypeDailySummary> list = entry.getValue();
            for (final ViewRiksdagenCommitteeDecisionTypeDailySummary item : list) {
                if (item != null) {
                    dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getDecisionDate()), item.getTotal());
                }
            }
        }
    }
    addChart(content, "Decision type daily summary", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenCommitteeDecisionTypeDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary) 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) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with ViewRiksdagenCommitteeDecisionTypeDailySummary

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

the class DecisionChartDataManagerImpl method getCommitteeDecisionTypeMap.

/**
 * Gets the committee decision type map.
 *
 * @return the committee decision type map
 */
private Map<String, List<ViewRiksdagenCommitteeDecisionTypeDailySummary>> getCommitteeDecisionTypeMap() {
    final DataContainer<ViewRiksdagenCommitteeDecisionTypeDailySummary, RiksdagenCommitteeDecisionTypeSummaryEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager().getDataContainer(ViewRiksdagenCommitteeDecisionTypeDailySummary.class);
    final Date now = new Date();
    final Date notBefore = new GregorianCalendar(2000, Calendar.JANUARY, 1).getTime();
    return committeeBallotDecisionPartyDataContainer.getAll().parallelStream().filter(t -> t != null && !t.getEmbeddedId().getDecisionDate().after(now) && !notBefore.after(t.getEmbeddedId().getDecisionDate())).collect(Collectors.groupingBy(t -> t.getEmbeddedId().getDecisionType()));
}
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) RiksdagenCommitteeDecisionTypeSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeSummaryEmbeddedId) ViewRiksdagenCommitteeDecisionTypeDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Aggregations

ViewRiksdagenCommitteeDecisionTypeDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary)2 SimpleDateFormat (java.text.SimpleDateFormat)2 List (java.util.List)2 DCharts (org.dussan.vaadin.dcharts.DCharts)2 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)2 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)2 Series (org.dussan.vaadin.dcharts.options.Series)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 ViewRiksdagenCommitteeDecisionTypeOrgDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary)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 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