@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); }
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()); } }
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()))); }