Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for a default social security number that skips duplicate validation. #914

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public interface ConfigurationProperties {
@ConfigurationProperty(key = "ciist.sms.shouldRun")
public Boolean getCIISTSMSShouldRun();

@ConfigurationProperty(
key = "default.social.security.number",
description = "Identifies the default social security number to be used in the country (e.g. for Portugal it is 999999990)")
public String getDefaultSocialSecurityNumber();

@ConfigurationProperty(key = "generic.application.email.confirmation.link",
defaultValue = "http://localhost:8080/fenix/publico/genericApplications.do?method=confirmEmail&confirmationCode=")
public String getGenericApplicationEmailConfirmationLink();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.lang.StringUtils;
import org.fenixedu.academic.FenixEduAcademicConfiguration;
import org.fenixedu.academic.domain.CompetenceCourse;
import org.fenixedu.academic.domain.Country;
import org.fenixedu.academic.domain.DomainObjectUtil;
Expand Down Expand Up @@ -462,16 +463,20 @@ public void setSocialSecurityNumber(String socialSecurityNumber) {
return;
}

final Party party = PartySocialSecurityNumber.readPartyBySocialSecurityNumber(socialSecurityNumber);
if (party != null && party != this) {
throw new DomainException("error.party.existing.contributor.number");
} else {
if (getPartySocialSecurityNumber() != null) {
getPartySocialSecurityNumber().setSocialSecurityNumber(socialSecurityNumber);
} else {
new PartySocialSecurityNumber(this, socialSecurityNumber);
String defaultSocialSecurityNumber =
FenixEduAcademicConfiguration.getConfiguration().getDefaultSocialSecurityNumber();
if (defaultSocialSecurityNumber == null || !defaultSocialSecurityNumber.equals(socialSecurityNumber)) {
final Party party = PartySocialSecurityNumber.readPartyBySocialSecurityNumber(socialSecurityNumber);
if (party != null && party != this) {
throw new DomainException("error.party.existing.contributor.number");
}
}

if (getPartySocialSecurityNumber() != null) {
getPartySocialSecurityNumber().setSocialSecurityNumber(socialSecurityNumber);
} else {
new PartySocialSecurityNumber(this, socialSecurityNumber);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.fenixedu.academic.domain.organizationalStructure;

import org.fenixedu.academic.FenixEduAcademicConfiguration;
import org.fenixedu.academic.domain.exceptions.DomainException;
import org.fenixedu.bennu.core.domain.Bennu;

Expand All @@ -43,9 +44,12 @@ private void checkParameters(final Party party, final String socialSecurityNumbe
throw new DomainException("error.PartySocialSecurityNumber.invalid.socialSecurityNumber");
}

for (final PartySocialSecurityNumber securityNumber : Bennu.getInstance().getPartySocialSecurityNumbersSet()) {
if (securityNumber != this && securityNumber.hasSocialSecurityNumber(socialSecurityNumber)) {
throw new DomainException("error.PartySocialSecurityNumber.number.already.exists");
String defaultSocialSecurityNumber = FenixEduAcademicConfiguration.getConfiguration().getDefaultSocialSecurityNumber();
if (defaultSocialSecurityNumber == null || !defaultSocialSecurityNumber.equals(socialSecurityNumber)) {
for (final PartySocialSecurityNumber securityNumber : Bennu.getInstance().getPartySocialSecurityNumbersSet()) {
if (securityNumber != this && securityNumber.hasSocialSecurityNumber(socialSecurityNumber)) {
throw new DomainException("error.PartySocialSecurityNumber.number.already.exists");
}
}
}
}
Expand Down