Ejemplo n.º 1
0
  protected boolean isPersonProtected(Person person) {
    if (person.getNavnebeskyttelsestartdato() == null) return false;

    // We have to make the guard above to avoid null being passed into the
    // Instant
    // it is converted to the beginning of the era.

    Preconditions.checkState(
        person.getNavnebeskyttelseslettedato() != null,
        "The protection end date was not present. This is most unexpected and a programming error.");

    Instant protectionStart = new Instant(person.getNavnebeskyttelsestartdato());
    Instant protectionEnd = new Instant(person.getNavnebeskyttelseslettedato());

    return protectionStart.isEqualNow()
        || (protectionStart.isBeforeNow() && protectionEnd.isAfterNow());
  }
Ejemplo n.º 2
0
  protected RegularCPRPersonType createRegularPerson(Person person) {
    RegularCPRPersonType regularCprPerson = new RegularCPRPersonType();
    SimpleCPRPersonType simpleCprPerson = new SimpleCPRPersonType();
    regularCprPerson.setSimpleCPRPerson(simpleCprPerson);

    // PERSON NAME STRUCTURE SECTION
    //
    // Many of these values might not be present in the database
    // this is because that 'Such is life' and sometimes we simply
    // don't know a person's first name, address or birthday.
    PersonNameStructureType personName = new PersonNameStructureType();
    simpleCprPerson.setPersonNameStructure(personName);
    personName.setPersonGivenName(actualOrUnknown(person.fornavn));

    // Middle name is optional.
    personName.setPersonMiddleName(actualOrNull(person.mellemnavn));
    personName.setPersonSurnameName(actualOrUnknown(person.efternavn));
    simpleCprPerson.setPersonCivilRegistrationIdentifier(person.cpr);

    regularCprPerson.setPersonNameForAddressingName(
        actualOrUnknown(person.getNavnTilAdressering()));
    regularCprPerson.setPersonGenderCode(mapGenderToGenderCode(person.koen));
    regularCprPerson.setPersonInformationProtectionIndicator(false);

    // BIRTH DATE
    PersonBirthDateStructureType personBirthDate = new PersonBirthDateStructureType();

    personBirthDate.setBirthDate(newXMLGregorianCalendar(person.foedselsdato));
    personBirthDate.setBirthDateUncertaintyIndicator(person.getFoedselsdatoMarkering());
    regularCprPerson.setPersonBirthDateStructure(personBirthDate);

    // CIVIL STATUS
    PersonCivilRegistrationStatusStructureType personCivil =
        new PersonCivilRegistrationStatusStructureType();
    personCivil.setPersonCivilRegistrationStatusCode(new BigInteger(person.getStatus()));
    personCivil.setPersonCivilRegistrationStatusStartDate(
        newXMLGregorianCalendar(person.getStatusDato()));

    regularCprPerson.setPersonCivilRegistrationStatusStructure(personCivil);
    return regularCprPerson;
  }