Search in sources :

Example 1 with ViewRiksdagenVoteDataBallotPartySummaryDaily

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

the class AdminChartDataManagerImpl method createApplicationActionEventPageDailySummaryChart.

@Override
public void createApplicationActionEventPageDailySummaryChart(final AbstractOrderedLayout content) {
    final Map<String, List<ViewApplicationActionEventPageDailySummary>> map = getApplicationActionEventPageDailySummaryMap();
    final DataSeries dataSeries = new DataSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final Series series = new Series();
    for (final Entry<String, List<ViewApplicationActionEventPageDailySummary>> entry : map.entrySet()) {
        if (entry.getKey() != null) {
            series.addSeries(new XYseries().setLabel(entry.getKey()));
            dataSeries.newSeries();
            final List<ViewApplicationActionEventPageDailySummary> list = entry.getValue();
            for (final ViewApplicationActionEventPageDailySummary viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
                if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                    dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getCreatedDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getHits());
                }
            }
        }
    }
    addChart(content, "Application Action Events daily Summary", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) ViewApplicationActionEventPageDailySummary(com.hack23.cia.model.internal.application.data.impl.ViewApplicationActionEventPageDailySummary) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with ViewRiksdagenVoteDataBallotPartySummaryDaily

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

the class PartyChartDataManagerImpl method createPartyLineChart.

@Override
public void createPartyLineChart(final AbstractOrderedLayout content, final String partyId) {
    final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = getViewRiksdagenVoteDataBallotPartySummaryDaily(partyId);
    final Series series = new Series().addSeries(new XYseries().setLabel(PARTY_WON)).addSeries(new XYseries().setLabel(PARTY_ABSENT));
    final DataSeries dataSeries = new DataSeries().newSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    if (list != null) {
        for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
            if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyWonPercentage());
            }
        }
        dataSeries.newSeries();
        for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
            if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyPercentageAbsent());
            }
        }
    }
    addChart(content, "Party result by", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsPartyLineChart(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenVoteDataBallotPartySummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily) 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 3 with ViewRiksdagenVoteDataBallotPartySummaryDaily

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

the class PartyChartDataManagerImpl method createPartyBallotChart.

/**
 * Creates the party ballot chart.
 *
 * @param dataValueCalculator
 *            the data value calculator
 * @return the d charts
 */
private void createPartyBallotChart(final AbstractOrderedLayout content, final DataValueCalculator dataValueCalculator) {
    final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> map = getPartyMap();
    final DataSeries dataSeries = new DataSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final Series series = new Series();
    for (final Entry<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> entry : map.entrySet()) {
        if (!"-".equals(entry.getKey())) {
            series.addSeries(new XYseries().setLabel(getPartyName(entry.getKey())));
            dataSeries.newSeries();
            final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = entry.getValue();
            for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
                if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                    dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), dataValueCalculator.getDataValue(viewRiksdagenVoteDataBallotPartySummaryDaily));
                }
            }
        }
    }
    addChart(content, "Party ballot chart", 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) ViewRiksdagenVoteDataBallotPartySummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily) ArrayList(java.util.ArrayList) 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 4 with ViewRiksdagenVoteDataBallotPartySummaryDaily

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

the class PartyChartDataManagerImpl method createPartyWinnerChart.

@Override
public void createPartyWinnerChart(final AbstractOrderedLayout content) {
    final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> map = getPartyMap();
    final DataSeries dataSeries = new DataSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final Series series = new Series();
    for (final Entry<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> entry : map.entrySet()) {
        series.addSeries(new XYseries().setLabel(getPartyName(entry.getKey())));
        dataSeries.newSeries();
        final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = entry.getValue();
        for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
            if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyWonPercentage());
            }
        }
    }
    series.addSeries(new XYseries().setLabel(NUMBER_BALLOTS));
    dataSeries.newSeries();
    final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = getMaxSizeViewRiksdagenVoteDataBallotPartySummaryDaily();
    for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getNumberBallots());
        }
    }
    addChart(content, "Party winner by daily ballot average", 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) ViewRiksdagenVoteDataBallotPartySummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily) ArrayList(java.util.ArrayList) 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 5 with ViewRiksdagenVoteDataBallotPartySummaryDaily

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

the class RulesEngineImpl method insertParties.

/**
 * Insert parties.
 *
 * @param ksession
 *            the ksession
 * @param list
 *            the list
 */
private void insertParties(final KieSession ksession, final List<ViewRiksdagenPartySummary> list) {
    final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> politicanBallotSummaryAnnualMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPartySummaryDaily.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getParty()));
    final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryMonthly>> politicanBallotSummaryMontlyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPartySummaryMonthly.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getParty()));
    final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryAnnual>> politicanBallotSummaryDailyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPartySummaryAnnual.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getParty()));
    for (final ViewRiksdagenPartySummary partyData : list) {
        if (partyData != null) {
            final List<ViewRiksdagenVoteDataBallotPartySummaryAnnual> dailyList = politicanBallotSummaryDailyMap.get(partyData.getParty());
            final List<ViewRiksdagenVoteDataBallotPartySummaryMonthly> monthlyList = politicanBallotSummaryMontlyMap.get(partyData.getParty());
            final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> annualList = politicanBallotSummaryAnnualMap.get(partyData.getParty());
            if (partyData.isActiveParliament() && dailyList != null && monthlyList != null && annualList != null) {
                Collections.sort(dailyList, (e1, e2) -> e1.getEmbeddedId().getVoteDate().compareTo(e2.getEmbeddedId().getVoteDate()));
                Collections.sort(monthlyList, (e1, e2) -> e1.getEmbeddedId().getVoteDate().compareTo(e2.getEmbeddedId().getVoteDate()));
                Collections.sort(annualList, (e1, e2) -> e1.getEmbeddedId().getVoteDate().compareTo(e2.getEmbeddedId().getVoteDate()));
                final PartyComplianceCheckImpl politicianComplianceCheckImpl = new PartyComplianceCheckImpl(partyData, Iterables.getFirst(dailyList, null), Iterables.getFirst(monthlyList, null), Iterables.getFirst(annualList, null));
                ksession.insert(politicianComplianceCheckImpl);
            } else {
                final PartyComplianceCheckImpl politicianComplianceCheckImpl = new PartyComplianceCheckImpl(partyData, null, null, null);
                ksession.insert(politicianComplianceCheckImpl);
            }
        }
    }
}
Also used : Iterables(com.google.common.collect.Iterables) ViewRiksdagenVoteDataBallotPartySummaryMonthly(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryMonthly) ViewRiksdagenVoteDataBallotPoliticianSummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily) Cacheable(org.springframework.cache.annotation.Cacheable) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ViewRiksdagenVoteDataBallotPartySummaryAnnual(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryAnnual) ComplianceCheck(com.hack23.cia.service.api.action.kpi.ComplianceCheck) ArrayList(java.util.ArrayList) ViewRiksdagenPolitician(com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician) ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly) Propagation(org.springframework.transaction.annotation.Propagation) Service(org.springframework.stereotype.Service) Map(java.util.Map) AfterMatchFiredEvent(org.kie.api.event.rule.AfterMatchFiredEvent) Qualifier(org.springframework.beans.factory.annotation.Qualifier) DefaultAgendaEventListener(org.kie.api.event.rule.DefaultAgendaEventListener) KieSession(org.kie.api.runtime.KieSession) ViewRiksdagenVoteDataBallotPartySummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily) ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual) KieContainer(org.kie.api.runtime.KieContainer) Collectors(java.util.stream.Collectors) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) List(java.util.List) Collections(java.util.Collections) DataViewer(com.hack23.cia.service.data.api.DataViewer) Transactional(org.springframework.transaction.annotation.Transactional) ViewRiksdagenPartySummary(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary) ViewRiksdagenVoteDataBallotPartySummaryMonthly(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryMonthly) ViewRiksdagenVoteDataBallotPartySummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily) ViewRiksdagenPartySummary(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary) ViewRiksdagenVoteDataBallotPartySummaryAnnual(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryAnnual) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ViewRiksdagenVoteDataBallotPartySummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily)4 SimpleDateFormat (java.text.SimpleDateFormat)4 List (java.util.List)4 DCharts (org.dussan.vaadin.dcharts.DCharts)4 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)4 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)4 Series (org.dussan.vaadin.dcharts.options.Series)4 ArrayList (java.util.ArrayList)3 Iterables (com.google.common.collect.Iterables)1 ViewRiksdagenVoteDataBallotPartySummaryAnnual (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryAnnual)1 ViewRiksdagenVoteDataBallotPartySummaryMonthly (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryMonthly)1 ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual)1 ViewRiksdagenVoteDataBallotPoliticianSummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)1 ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly)1 ViewApplicationActionEventPageDailySummary (com.hack23.cia.model.internal.application.data.impl.ViewApplicationActionEventPageDailySummary)1 ViewRiksdagenPartySummary (com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary)1 ViewRiksdagenPolitician (com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician)1 ComplianceCheck (com.hack23.cia.service.api.action.kpi.ComplianceCheck)1 DataViewer (com.hack23.cia.service.data.api.DataViewer)1 Collections (java.util.Collections)1