Skip to content

Commit

Permalink
Added support for a default social security number that skips duplica…
Browse files Browse the repository at this point in the history
…te validation.
  • Loading branch information
JoaoRoxo committed Dec 9, 2015
1 parent 70230a5 commit f62c5bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
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

0 comments on commit f62c5bd

Please sign in to comment.