public PersonId build() { return new PersonId(this); } }
private PersonId(PersonIdBuilder builder) { try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); byte[] shaHash = messageDigest.digest(builder.toString().getBytes()); this.personId = convertByteArrayToHexString(shaHash); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }
@Override public ApplicantResultProjection retrieve(PersonId personId) { return dao.findByPersonId(personId.toString()); } }
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 AgencyResultProjection retrieve(PersonId personId) { return dao.findByPersonId(personId.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 void save(AgencyResultAggregate agencyResultAggregate) { AgencyResultProjection agencyResultProjection = new AgencyResultProjection(); agencyResultProjection.setNoGoPresent(!agencyResultAggregate.isAcceptable()); agencyResultProjection.setPersonId(agencyResultAggregate.getAgencyResultRootEntity().id.toString()); agencyResultProjection.setPoints(agencyResultAggregate.calculateScoringPoints()); dao.save(agencyResultProjection); }