int calculateScoringPoints() { int result = 0; result += balance.calculateScoringPoints(); result += address.calculateScoringPoints(); return result; } }
public int calculateScoringPoints() { return applicantRootEntity.calculateScoringPoints(); }
@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); }
private void scoreApplicant(ApplicationNumber applicationNumber, Applicant applicant) { ApplicantAggregate applicantAggregate = new ApplicantAggregate.ApplicantAggregateBuilder(applicationNumber) .city(applicant.getCity()) .postCode(applicant.getPostCode()) .firstName(applicant.getFirstName()) .lastName(applicant.getLastName()) .street(applicant.getStreet()) .build(); applicantResultRepository.save(applicantAggregate); }
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 ApplicantAggregate build() { if(this.accountBalance == null) { this.accountBalance = new AccountBalance(new Money()); } return new ApplicantAggregate(this); } }
private ApplicantAggregate(ApplicantAggregateBuilder builder) { PersonId personId = new PersonId.PersonIdBuilder(builder.firstName, builder.lastName) .postCode(builder.postCode) .city(builder.city) .street(builder.street) .build(); Address address = new Address(builder.street, builder.postCode, builder.city); this.applicantRootEntity = new ApplicantRootEntity(personId, builder.applicationNumber, builder.firstName, builder.lastName, address, builder.accountBalance); }
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 ApplicantResultProjection retrieve(PersonId personId) { return dao.findByPersonId(personId.toString()); } }
@Override public ApplicantResultProjection retrieve(ApplicationNumber applicationNumber) { return dao.findByApplicationNumber(applicationNumber.toString()); }
public ApplicantAggregateBuilder accountBalance(int balance) { this.accountBalance = new AccountBalance(new Money(balance)); return this; }