Exemple #1
0
 public void removeAdditionalGuarantor(Application application) {
   this.applicationDAO.refresh(application);
   if (application.getExternalGuarantor() != null) {
     this.removeAsGuarantor(application.getExternalGuarantor());
   } else if (application.getInternalGuarantor() != null) {
     this.removeAsGuarantor(application.getInternalGuarantor());
   }
 }
Exemple #2
0
  public void associateAsGuarantor(
      Application application,
      Investorindividual transientGuarantor,
      Individual transientIndividual,
      FinancialInformation transientFinancialInformation) {
    Investorindividual chosenGuarantor;

    this.applicationDAO.refresh(application);

    if (application.getExternalGuarantor() != null) {
      // external guarantor exists.

      if (transientGuarantor.getId().longValue()
          == application.getExternalGuarantor().getId().longValue()) {
        // updating existing exernal guarantor
        chosenGuarantor = application.getExternalGuarantor();
        this.updateGuarantorDetails(
            chosenGuarantor, transientGuarantor, transientGuarantor.getIndividual());
      } else {
        // switched to internal guarantor - delete external guarantor
        Investorindividual oldGuarantor = application.getExternalGuarantor();
        this.removeAsGuarantor(oldGuarantor);
        chosenGuarantor = application.findInvestorIndividualById(transientGuarantor.getId());
        this.setAsInternalGuarantor(application, chosenGuarantor);
      }
    } else if (application.getInternalGuarantor() != null) {
      // internal guarantor exists.

      Investorindividual oldGuarantor = application.getInternalGuarantor();
      chosenGuarantor = application.findInvestorIndividualById(transientGuarantor.getId());

      if (chosenGuarantor == null) {
        // switching to new external guarantor.
        this.removeAsGuarantor(oldGuarantor);
        chosenGuarantor =
            this.createExternalGuarantor(
                application, transientGuarantor, transientGuarantor.getIndividual());
      } else if (oldGuarantor.getId().equals(chosenGuarantor.getId())) {
        // same internal guarantor - update
        // nothing to update here ...
      } else {
        // different internal guarantor - remove old associationship and create new one
        this.removeAsGuarantor(oldGuarantor);
        this.setAsInternalGuarantor(application, chosenGuarantor);
      }
    } else {
      // assume new external guarantor.
      chosenGuarantor =
          this.createExternalGuarantor(
              application, transientGuarantor, transientGuarantor.getIndividual());
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Saving guarantor's finaicial information ...");
    }

    this.updateGuarantorFinancialInformation(chosenGuarantor, transientFinancialInformation);
  }