class LecturerMappingByPersonalNumber extends AbstractMappingByInstitutionalIdentifier {

    public Identity tryToMap(Long personalNr) {
        // append '%' because personal-number starts with 0 e.g. 012345
        Identity mappedIdentity = tryToMap(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER, "%" + personalNr.toString());
        if (mappedIdentity != null) {
            String personalNumber = mappedIdentity.getUser().getRawUserProperty(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER);
            try {
                Long personalNumberAsLong = Long.valueOf(personalNumber);
                if (personalNumberAsLong.equals(personalNr)) {
                    return mappedIdentity;
                }
                log.warn("User-Property as Long (" + personalNumberAsLong + ") has not the same value as lecturer personal-number=" + personalNr);
            } catch (NumberFormatException ex) {
                log.warn("Could not convert personal-number to Long");
            }
        }
        return null;

    }

}