예제 #1
0
  public PersonIdentifier getGlobalIdentifierById(PersonIdentifier personIdentifier) {

    ValidationService validationService = Context.getValidationService();
    validationService.validate(personIdentifier);

    GlobalIdentifier globalIdentifier = Context.getConfiguration().getGlobalIdentifier();
    if (!globalIdentifier.isAssignGlobalIdentifier()) {
      log.warn("The system is not configured to assign global identifiers.");
      return null;
    }

    IdentifierDomain globalDomain = globalIdentifier.getIdentifierDomain();
    // Check to see if the person already has a global identifier
    Person person = personDao.getPersonById(personIdentifier);
    if (person != null) {
      for (PersonIdentifier identifier : person.getPersonIdentifiers()) {
        IdentifierDomain identifierDomain = identifier.getIdentifierDomain();
        if (identifierDomain != null && identifierDomain.equals(globalDomain)) {
          if (log.isTraceEnabled()) {
            log.trace("Person has a global identifier assigned: " + identifier);
          }
          return identifier;
        }
      }
    }
    return null;
  }