Ejemplo n.º 1
0
 public EmailAddress addEmailAddress(EmailAddress sorEmailAddress) {
   MockEmailAddress ea = new MockEmailAddress();
   ea.setAddress(sorEmailAddress.getAddress());
   ea.setAddressType(sorEmailAddress.getAddressType());
   emailAddresses.add(ea);
   return ea;
 }
Ejemplo n.º 2
0
 public Phone addPhone(Phone sorPhone) {
   MockPhoneNumber phone = new MockPhoneNumber();
   phone.setCountryCode(sorPhone.getCountryCode());
   phone.setAreaCode(sorPhone.getAreaCode());
   phone.setNumber(sorPhone.getNumber());
   phone.setExtension(sorPhone.getExtension());
   phones.add(phone);
   return phone;
 }
  /**
   * This does not explicitly delete the names because its assumed the recalculation will clean it
   * up.
   */
  public boolean deleteSystemOfRecordPerson(
      final SorPerson sorPerson, final boolean mistake, final String terminationTypes) {
    Assert.notNull(sorPerson, "sorPerson cannot be null.");
    final String terminationTypeToUse =
        terminationTypes != null ? terminationTypes : Type.TerminationTypes.UNSPECIFIED.name();

    final Person person = this.personRepository.findByInternalId(sorPerson.getPersonId());
    Assert.notNull(person, "person cannot be null.");

    if (mistake) {
      Set<Role> rolesToDelete = new HashSet<Role>();

      for (final SorRole sorRole : sorPerson.getRoles()) {
        for (final Role role : person.getRoles()) {
          if (sorRole.getId().equals(role.getSorRoleId())) {
            rolesToDelete.add(role);
          }
        }
      }

      for (final Role role : rolesToDelete) {
        // let sorRoleElector delete the role and add another role if required
        sorRoleElector.removeCalculatedRole(
            person, role, this.personRepository.getSoRRecordsForPerson(person));
      }

      final Number number = this.personRepository.getCountOfSoRRecordsForPerson(person);

      if (number.intValue() == 1) {
        this.personRepository.deletePerson(person);
      }

      this.personRepository.deleteSorPerson(sorPerson);
      return true;
    }

    // we do this explicitly here because once they're gone we can't re-calculate?  We might move to
    // this to the recalculateCalculatedPerson method.
    final Type terminationReason =
        this.referenceRepository.findType(Type.DataTypes.TERMINATION, terminationTypeToUse);

    for (final SorRole sorRole : sorPerson.getRoles()) {
      for (final Role role : person.getRoles()) {
        if (!role.isTerminated() && sorRole.getId().equals(role.getSorRoleId())) {
          role.expireNow(terminationReason, true);
        }
      }
    }

    this.personRepository.deleteSorPerson(sorPerson);
    this.personRepository.savePerson(person);

    Person p = recalculatePersonBiodemInfo(person, sorPerson, RecalculationType.DELETE, mistake);
    this.personRepository.savePerson(p);
    return true;
  }