Search in sources :

Example 1 with ViewRiksdagenPoliticianDocumentDailySummary

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

the class PersonDocumentChartDataManagerImpl method addDocumentHistoryByPersonData.

/**
 * Adds the document history by person data.
 *
 * @param simpleDateFormat
 *            the simple date format
 * @param dataSeries
 *            the data series
 * @param series
 *            the series
 * @param map
 *            the map
 */
private static void addDocumentHistoryByPersonData(final SimpleDateFormat simpleDateFormat, final DataSeries dataSeries, final Series series, final Map<String, List<ViewRiksdagenPoliticianDocumentDailySummary>> map) {
    for (final Entry<String, List<ViewRiksdagenPoliticianDocumentDailySummary>> entry : map.entrySet()) {
        series.addSeries(new XYseries().setLabel(entry.getKey()));
        dataSeries.newSeries();
        if (entry.getValue() != null) {
            for (final ViewRiksdagenPoliticianDocumentDailySummary 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 : List(java.util.List) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) ViewRiksdagenPoliticianDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPoliticianDocumentDailySummary)

Example 2 with ViewRiksdagenPoliticianDocumentDailySummary

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

the class PersonDocumentChartDataManagerImpl method createPersonDocumentHistoryChart.

@Override
public void createPersonDocumentHistoryChart(final AbstractOrderedLayout content, final String personId) {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenPoliticianDocumentDailySummary>> allMap = getViewRiksdagenPoliticianDocumentDailySummaryMap();
    final List<ViewRiksdagenPoliticianDocumentDailySummary> itemList = allMap.get(personId.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenPoliticianDocumentDailySummary>> map = itemList.parallelStream().filter(Objects::nonNull).collect(Collectors.groupingBy(t -> StringUtils.defaultIfBlank(t.getEmbeddedId().getDocumentType(), NO_INFO)));
        addDocumentHistoryByPersonData(simpleDateFormat, dataSeries, series, map);
    }
    addChart(content, DOCUMENT_HISTORY, 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) PersonDocumentChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PersonDocumentChartDataManager) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) ViewRiksdagenPoliticianDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPoliticianDocumentDailySummary) Collectors(java.util.stream.Collectors) RiksdagenDocumentPersonSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPersonSummaryEmbeddedId) 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) 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) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts) SimpleDateFormat(java.text.SimpleDateFormat) ViewRiksdagenPoliticianDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPoliticianDocumentDailySummary)

Aggregations

ViewRiksdagenPoliticianDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPoliticianDocumentDailySummary)2 List (java.util.List)2 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)2 RiksdagenDocumentPersonSummaryEmbeddedId (com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPersonSummaryEmbeddedId)1 DataContainer (com.hack23.cia.service.api.DataContainer)1 PersonDocumentChartDataManager (com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PersonDocumentChartDataManager)1 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)1 SimpleDateFormat (java.text.SimpleDateFormat)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