Search in sources :

Example 1 with ViewRiksdagenPartyDocumentDailySummary

use of com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary in project cia by Hack23.

the class PartyDocumentChartDataManagerImpl method createDocumentHistoryPartyChart.

@Override
public void createDocumentHistoryPartyChart(final AbstractOrderedLayout content, final String org) {
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> allMap = getViewRiksdagenPartyDocumentDailySummaryMap();
    final List<ViewRiksdagenPartyDocumentDailySummary> itemList = allMap.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> map = itemList.parallelStream().filter(Objects::nonNull).collect(Collectors.groupingBy(t -> StringUtils.defaultIfBlank(t.getEmbeddedId().getDocumentType(), NO_INFO)));
        addDocumentHistoryByPartyData(dataSeries, series, map);
    }
    addChart(content, DOCUMENT_HISTORY_PARTY, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) StringUtils(org.apache.commons.lang.StringUtils) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) RiksdagenDocumentPartySummaryEmbeddedId(com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPartySummaryEmbeddedId) Collectors(java.util.stream.Collectors) PartyDocumentChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyDocumentChartDataManager) Objects(java.util.Objects) DCharts(org.dussan.vaadin.dcharts.DCharts) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) Map(java.util.Map) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) 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) ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts)

Example 2 with ViewRiksdagenPartyDocumentDailySummary

use of com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary in project cia by Hack23.

the class PartyDocumentChartDataManagerImpl method addDocumentHistoryByPartyData.

/**
 * Adds the document history by party data.
 *
 * @param dataSeries
 *            the data series
 * @param series
 *            the series
 * @param map
 *            the map
 */
private static void addDocumentHistoryByPartyData(final DataSeries dataSeries, final Series series, final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> map) {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    for (final Entry<String, List<ViewRiksdagenPartyDocumentDailySummary>> entry : map.entrySet()) {
        series.addSeries(new XYseries().setLabel(entry.getKey()));
        dataSeries.newSeries();
        if (entry.getValue() != null) {
            for (final ViewRiksdagenPartyDocumentDailySummary item : entry.getValue()) {
                if (item != null) {
                    dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getPublicDate()), item.getTotal());
                }
            }
        } else {
            LOGGER.info(LOG_MSG_MISSING_DATA_FOR_KEY, entry);
        }
    }
}
Also used : ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) List(java.util.List) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

ViewRiksdagenPartyDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary)2 SimpleDateFormat (java.text.SimpleDateFormat)2 List (java.util.List)2 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)2 RiksdagenDocumentPartySummaryEmbeddedId (com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPartySummaryEmbeddedId)1 DataContainer (com.hack23.cia.service.api.DataContainer)1 PartyDocumentChartDataManager (com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyDocumentChartDataManager)1 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)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 StringUtils (org.apache.commons.lang.StringUtils)1 DCharts (org.dussan.vaadin.dcharts.DCharts)1 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)1 Series (org.dussan.vaadin.dcharts.options.Series)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Service (org.springframework.stereotype.Service)1