private static void insertPolitician ( final KieSession ksession , final ViewRiksdagenPolitician politicianData , final List < ViewRiksdagenVoteDataBallotPoliticianSummaryDaily > dailyList , final List < ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly > monthlyList , final List < ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual > annualList , final List < ViewRiksdagenCommitteeBallotDecisionPoliticianSummary > decisionList ) { if ( politicianData . isActiveParliament ( ) && dailyList != null && monthlyList != null && annualList != null ) { Collections . sort ( dailyList , ( e1 , e2 ) -> e1 . getEmbeddedId ( ) . getVoteDate ( ) . compareTo ( e2 . getEmbeddedId ( ) . getVoteDate ( ) ) ) ; final Optional < ViewRiksdagenVoteDataBallotPoliticianSummaryDaily > dailyListFirst = dailyList . stream ( ) . findFirst ( ) ; Collections . sort ( monthlyList , ( e1 , e2 ) -> e1 . getEmbeddedId ( ) . getVoteDate ( ) . compareTo ( e2 . getEmbeddedId ( ) . getVoteDate ( ) ) ) ; final Optional < ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly > monthlyListFirst = monthlyList . stream ( ) . findFirst ( ) ; Collections . sort ( annualList , ( e1 , e2 ) -> e1 . getEmbeddedId ( ) . getVoteDate ( ) . compareTo ( e2 . getEmbeddedId ( ) . getVoteDate ( ) ) ) ; final Optional < ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual > annualListFirst = annualList . stream ( ) . findFirst ( ) ; if ( annualListFirst . isPresent ( ) && monthlyListFirst . isPresent ( ) && dailyListFirst . isPresent ( ) ) { final PoliticianComplianceCheckImpl politicianComplianceCheckImpl = new PoliticianComplianceCheckImpl ( politicianData , dailyListFirst . get ( ) , monthlyListFirst . get ( ) , annualListFirst . get ( ) , decisionList ) ; ksession . insert ( politicianComplianceCheckImpl ) ; } } else { final PoliticianComplianceCheckImpl politicianComplianceCheckImpl = new PoliticianComplianceCheckImpl ( politicianData , null , null , null , new ArrayList <> ( ) ) ; ksession . insert ( politicianComplianceCheckImpl ) ; } }
Insert politician .