Пример #1
0
  public void removeAsGuarantor(Investorindividual oldGuarantor) {
    if (oldGuarantor.getRole().equals(Constants.GUARANTOR)) {
      if (logger.isDebugEnabled()) {
        logger.debug("Guarantor to remove is external, so deleting ...");
      }

      Individual individual = oldGuarantor.getIndividual();
      individual.getInvestorindividuals().remove(oldGuarantor); // throws lazy error.
      oldGuarantor.setIndividual(null);
      this.individualDAO.delete(individual);

      FinancialInformation financialInformation = oldGuarantor.getFinancialInformation();
      financialInformation.setInvestorindividual(null);
      oldGuarantor.setFinancialInformation(null);
      this.financialInformationDao.delete(financialInformation);

      Application application = oldGuarantor.getApplication();
      oldGuarantor.setApplication(null);
      application.getInvestorindividuals().remove(oldGuarantor);
      this.investorindividualDAO.delete(oldGuarantor);

      this.applicationDAO.update(application);
    } else {
      if (logger.isDebugEnabled()) {
        logger.debug("Guarantor to remove is internal, so updating flags ...");
      }
      oldGuarantor.setIsguarantor(Constants.FALSE);
      this.investorindividualDAO.update(oldGuarantor);

      FinancialInformation financialInformation = oldGuarantor.getFinancialInformation();
      financialInformation.setInvestorindividual(null);
      oldGuarantor.setFinancialInformation(null);
      this.financialInformationDao.delete(financialInformation);
    }
  }
Пример #2
0
  public Investorindividual createExternalGuarantor(
      Application application,
      Investorindividual transientInvestorindividual,
      Individual transientIndividual) {
    if (logger.isDebugEnabled()) {
      logger.debug("Creating new external guarantor individual ...");
    }

    Individual individual = new Individual();

    // Column 1:
    individual.setTitle(transientIndividual.getTitle());
    individual.setFirstname(transientIndividual.getFirstname());
    individual.setMiddlename(transientIndividual.getMiddlename());
    individual.setLastname(transientIndividual.getLastname());
    individual.setAddress1(transientIndividual.getAddress1());
    individual.setSuburb(transientIndividual.getSuburb());
    individual.setState(transientIndividual.getState());
    individual.setPostcode(transientIndividual.getPostcode());
    individual.setCountry(transientIndividual.getCountry());

    // Column 2:
    individual.setPassportno(transientIndividual.getPassportno());
    individual.setNationality(transientIndividual.getNationality());
    individual.setDriverslicenceno(transientIndividual.getDriverslicenceno());
    individual.setOccupation(transientIndividual.getOccupation());
    individual.setEmployer(transientIndividual.getEmployer());
    individual.setDateofbirth(transientIndividual.getDateofbirth());
    individual.setTownofbirth(transientIndividual.getTownofbirth());
    individual.setCountryofbirth(transientIndividual.getCountryofbirth());
    individual.setTfn(transientIndividual.getTfn());

    this.individualDAO.save(individual);

    if (logger.isDebugEnabled()) {
      logger.debug("Linking new external guarantor individual to application ...");
    }

    Investorindividual investorindividual = new Investorindividual();

    investorindividual.setApplication(application);
    application.getInvestorindividuals().add(investorindividual);

    investorindividual.setIndividual(individual);
    individual.getInvestorindividuals().add(investorindividual);

    investorindividual.setRole(Constants.GUARANTOR);
    investorindividual.setIsguarantor(Constants.TRUE);

    investorindividual.setWealthbyemployment(transientInvestorindividual.getWealthbyemployment());
    investorindividual.setWealthbyinvestments(transientInvestorindividual.getWealthbyinvestments());
    investorindividual.setWealthbyother(transientInvestorindividual.getWealthbyother());
    investorindividual.setWealthbyotherinfo(transientInvestorindividual.getWealthbyotherinfo());

    this.investorindividualDAO.save(investorindividual);

    return investorindividual;
  }