Search in sources :

Example 1 with ViewRiksdagenOrgDocumentDailySummary

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

the class OrgDocumentChartDataManagerImpl method addNewDataSerie.

private static void addNewDataSerie(final DataSeries dataSeries, final Series series, final SimpleDateFormat simpleDateFormat, final SimpleDateFormat parseIncomingDateFormat, final Entry<String, List<ViewRiksdagenOrgDocumentDailySummary>> entry) {
    series.addSeries(new XYseries().setLabel(entry.getKey()));
    dataSeries.newSeries();
    if (entry.getValue() != null) {
        for (final ViewRiksdagenOrgDocumentDailySummary item : entry.getValue()) {
            if (item != null && item.getEmbeddedId().getPublicDate().length() > 0) {
                try {
                    dataSeries.add(simpleDateFormat.format(parseIncomingDateFormat.parse(item.getEmbeddedId().getPublicDate())), item.getTotal());
                } catch (final ParseException e) {
                    LOGGER.warn("Problem parsing date:{}", item.getEmbeddedId().getPublicDate());
                }
            }
        }
    } else {
        LOGGER.info(LOG_MSG_MISSING_DATA_FOR_KEY, entry);
    }
}
Also used : ViewRiksdagenOrgDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary) ParseException(java.text.ParseException) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Example 2 with ViewRiksdagenOrgDocumentDailySummary

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

the class OrgDocumentChartDataManagerImpl method createDocumentHistoryChartByOrg.

@Override
public void createDocumentHistoryChartByOrg(final AbstractOrderedLayout content, final String org) {
    final String searchOrg = org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).replace(MINUS_SIGN, EMPTY_STRING).trim();
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenOrgDocumentDailySummary>> allMap = getViewRiksdagenOrgDocumentDailySummaryMap();
    final List<ViewRiksdagenOrgDocumentDailySummary> itemList = allMap.get(searchOrg);
    if (itemList != null) {
        addDocumentHistoryByOrgData(dataSeries, series, itemList);
    }
    addChart(content, DOCUMENT_HISTORY_BY_ORG, 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) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts) ViewRiksdagenOrgDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary)

Example 3 with ViewRiksdagenOrgDocumentDailySummary

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

the class OrgDocumentChartDataManagerImpl method addDocumentHistoryByOrgData.

/**
 * Adds the document history by org data.
 *
 * @param dataSeries
 *            the data series
 * @param series
 *            the series
 * @param itemList
 *            the item list
 */
private static void addDocumentHistoryByOrgData(final DataSeries dataSeries, final Series series, final List<ViewRiksdagenOrgDocumentDailySummary> itemList) {
    final Map<String, List<ViewRiksdagenOrgDocumentDailySummary>> map = itemList.parallelStream().filter(Objects::nonNull).collect(Collectors.groupingBy(t -> StringUtils.defaultIfBlank(t.getDocumentType(), NO_INFO)));
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final SimpleDateFormat parseIncomingDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
    for (final Entry<String, List<ViewRiksdagenOrgDocumentDailySummary>> entry : map.entrySet()) {
        addNewDataSerie(dataSeries, series, simpleDateFormat, parseIncomingDateFormat, entry);
    }
}
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) OrgDocumentChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.OrgDocumentChartDataManager) ViewRiksdagenOrgDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary) Collectors(java.util.stream.Collectors) 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) StringEscapeUtils(org.apache.commons.lang3.StringEscapeUtils) ParseException(java.text.ParseException) RiksdagenDocumentOrgSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentOrgSummaryEmbeddedId) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) List(java.util.List) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

ViewRiksdagenOrgDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary)3 ParseException (java.text.ParseException)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 RiksdagenDocumentOrgSummaryEmbeddedId (com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentOrgSummaryEmbeddedId)1 DataContainer (com.hack23.cia.service.api.DataContainer)1 OrgDocumentChartDataManager (com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.OrgDocumentChartDataManager)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 StringEscapeUtils (org.apache.commons.lang3.StringEscapeUtils)1 Logger (org.slf4j.Logger)1