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