public PartOfScoringPerformed(Object source, String applicationNumber, PersonId personId) { super(source); this.applicationNumber = new ApplicationNumber(applicationNumber); this.personId = personId; }
@Override public FinancialSituationResultProjection retrieve(ApplicationNumber applicationNumber) { return dao.findByApplicationNumber(applicationNumber.toString()); }
@Override public ApplicantResultProjection retrieve(ApplicationNumber applicationNumber) { return dao.findByApplicationNumber(applicationNumber.toString()); }
public void scoreAgencyResult(String firstName, String lastName, String street, String postcode, String city, int agencyPoints ) { AgencyResultAggregate.AgencyResultBuilder agencyResultBuilder = new AgencyResultAggregate.AgencyResultBuilder() .forPerson(firstName, lastName, street, postcode, city) .withPoints(agencyPoints); AgencyResultAggregate agencyResultAggregate = agencyResultBuilder.build(); agencyResultRepository.save(agencyResultAggregate); ApplicantResultProjection applicantResultProjection = applicantResultRepository.retrieve(agencyResultAggregate.getPersonId()); applicationEventPublisher.publishEvent(new PartOfScoringPerformed(this, new ApplicationNumber(applicantResultProjection.getApplicationNumber()))); }
@Override public void save(ScoringResultAggregate scoringResultAggregate) { DetailedScoringResults detailedScoringResults = new DetailedScoringResults(scoringResultAggregate.rootEntity.scoringCalculationResults); ScoringResultEntity scoringResultEntity = new ScoringResultEntity(scoringResultAggregate.rootEntity.applicationNumber.toString(), scoringResultAggregate.getScorePoints(), scoringResultAggregate.getScoreColor(), detailedScoringResults); this.scoringResultDAO.save(scoringResultEntity); }
@StreamListener(ApplicationProcessChannels.APPLICATION_SUBMITTED) public void receiveApplicationSubmission(@Payload ApplicationSubmittedEvent applicationSubmittedEvent) { Applicant firstApplicant = applicationSubmittedEvent.getFirstApplicant(); MonthlyExpenses monthlyExpenses = applicationSubmittedEvent.getHousehold().getMonthlyExpenses(); EarningCapacity earningCapacity = applicationSubmittedEvent.getHousehold().getEarningCapacity(); CreditApplication creditApplication = new CreditApplication.CreditApplicationBuilder(new ApplicationNumber(applicationSubmittedEvent.getApplicationNumber())) .withApplicant(firstApplicant.getFirstName(), firstApplicant.getLastName(), firstApplicant.getAddress().getStreet(), firstApplicant.getAddress().getPostCode(), firstApplicant.getAddress().getCity()) .withFinancialSituation(new Money(monthlyExpenses.getCostOfLiving()), new Money(earningCapacity.getFurtherIncome()), new Money(monthlyExpenses.getRent()), new Money(earningCapacity.getSalaryFirstApplicant())) .build(); scoringApplicationService.scoreApplication(creditApplication); }
@Override public void save(FinancialSituationAggregate financialSituationAggregate) { FinancialSituationResultProjection projection = new FinancialSituationResultProjection(); projection.setApplicationNumber(financialSituationAggregate.rootEntity.applicationNumber.toString()); projection.setPoints(financialSituationAggregate.calculateScoringPoints()); dao.save(projection); }
public void performFinalScoring(ApplicationNumber applicationNumber) { FinancialSituationResultProjection financialSituationResultProjection = financialSituationResultRepository.retrieve(applicationNumber); ApplicantResultProjection applicantResultProjection = applicantResultRepository.retrieve(applicationNumber); AgencyResultProjection agencyResultProjection = agencyResultRepository.retrieve(new PersonId(applicantResultProjection.getPersonId())); if(financialSituationResultProjection != null && applicantResultProjection !=null && agencyResultProjection != null) { log.info("everything is complete for " + applicationNumber.toString()); ScoringResultAggregate scoringResultAggregate = new ScoringResultAggregate.Builder(applicationNumber) .noGoCriteria(agencyResultProjection.isNoGoPresent()) .agencyScoring(agencyResultProjection.getPoints()) .financialSituationScoring(financialSituationResultProjection.getPoints()) .applicantScoring(applicantResultProjection.getPoints()) .build(); scoringResultRepository.save(scoringResultAggregate); } else { log.info("NOT everything is complete for " + applicationNumber.toString()); } }
@Override public void save(ApplicantAggregate applicantAggregate) { ApplicantResultProjection projection = new ApplicantResultProjection(); projection.setApplicationNumber(applicantAggregate.applicantRootEntity.applicationNumber.toString()); projection.setPersonId(applicantAggregate.applicantRootEntity.personId.toString()); projection.setPoints(applicantAggregate.calculateScoringPoints()); this.dao.save(projection); }
@Override public ScoringResultAggregate findByApplicationNumber(ApplicationNumber applicationNumber) { ScoringResultEntity scoringResultEntity = scoringResultDAO.findByApplicationNumber(applicationNumber.toString()); return new ScoringResultAggregate.Builder(applicationNumber) .agencyScoring(scoringResultEntity.getDetailedScoringResults().getAgencyScoringResult()) .applicantScoring(scoringResultEntity.getDetailedScoringResults().getApplicantScoringResult()) .financialSituationScoring(scoringResultEntity.getDetailedScoringResults().getFinancialSituationScoringResult()) .noGoCriteria(scoringResultEntity.getDetailedScoringResults().isNoGoCriteriaPresent()) .build(); } }