Search in sources :

Example 1 with ViewRiksdagenVoteDataBallotPoliticianSummaryDaily

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

the class PoliticianDataManagerImpl method addPoliticianIndicatorData.

/**
 * Adds the politician indicator data.
 *
 * @param list
 *            the list
 * @param dataSeries
 *            the data series
 * @param simpleDateFormat
 *            the simple date format
 */
private static void addPoliticianIndicatorData(final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> list, final DataSeries dataSeries, final SimpleDateFormat simpleDateFormat) {
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getWonPercentage());
        }
    }
    dataSeries.newSeries();
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getRebelPercentage());
        }
    }
    dataSeries.newSeries();
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getPoliticianPercentageAbsent());
        }
    }
    dataSeries.newSeries();
    for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getNumberBallots());
        }
    }
}
Also used : ViewRiksdagenVoteDataBallotPoliticianSummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)

Example 2 with ViewRiksdagenVoteDataBallotPoliticianSummaryDaily

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

the class PoliticianDataManagerImpl method createPersonLineChart.

@Override
public void createPersonLineChart(final AbstractOrderedLayout content, final String personId) {
    final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> list = dataChartManager.findByValue(personId);
    final Series series = new Series().addSeries(new XYseries().setLabel(WON)).addSeries(new XYseries().setLabel(PARTY_REBEL)).addSeries(new XYseries().setLabel(ABSENT)).addSeries(new XYseries().setLabel(NUMBER_BALLOTS));
    final DataSeries dataSeries = new DataSeries().newSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    if (list != null) {
        addPoliticianIndicatorData(list, dataSeries, simpleDateFormat);
    }
    addChart(content, "Ballot indicators", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsPersonLineChart(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) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) ViewRiksdagenVoteDataBallotPoliticianSummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with ViewRiksdagenVoteDataBallotPoliticianSummaryDaily

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

the class RulesEngineImpl method insertPoliticians.

/**
 * Insert politicians.
 *
 * @param ksession
 *            the ksession
 * @param list
 *            the list
 */
private void insertPoliticians(final KieSession ksession, final List<ViewRiksdagenPolitician> list) {
    final Map<String, List<ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual>> politicanBallotSummaryAnnualMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getIntressentId()));
    final Map<String, List<ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly>> politicanBallotSummaryMontlyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getIntressentId()));
    final Map<String, List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily>> politicanBallotSummaryDailyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPoliticianSummaryDaily.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getIntressentId()));
    for (final ViewRiksdagenPolitician politicianData : list) {
        if (politicianData != null) {
            final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> dailyList = politicanBallotSummaryDailyMap.get(politicianData.getPersonId());
            final List<ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly> monthlyList = politicanBallotSummaryMontlyMap.get(politicianData.getPersonId());
            final List<ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual> annualList = politicanBallotSummaryAnnualMap.get(politicianData.getPersonId());
            if (politicianData.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 PoliticianComplianceCheckImpl politicianComplianceCheckImpl = new PoliticianComplianceCheckImpl(politicianData, Iterables.getFirst(dailyList, null), Iterables.getFirst(monthlyList, null), Iterables.getFirst(annualList, null));
                ksession.insert(politicianComplianceCheckImpl);
            } else {
                final PoliticianComplianceCheckImpl politicianComplianceCheckImpl = new PoliticianComplianceCheckImpl(politicianData, 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) ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly) ArrayList(java.util.ArrayList) List(java.util.List) ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual) ViewRiksdagenVoteDataBallotPoliticianSummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily) ViewRiksdagenPolitician(com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician)

Aggregations

ViewRiksdagenVoteDataBallotPoliticianSummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)3 Iterables (com.google.common.collect.Iterables)1 ViewRiksdagenVoteDataBallotPartySummaryAnnual (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryAnnual)1 ViewRiksdagenVoteDataBallotPartySummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily)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 ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly)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 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)1 DCharts (org.dussan.vaadin.dcharts.DCharts)1