use of com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual 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);
}
}
}
}
Aggregations