Skip to content

Commit

Permalink
Merge pull request #9643 from QualitativeDataRepository/IQSS/9185-con…
Browse files Browse the repository at this point in the history
…tact_email_updates

IQSS/9185-improve parsing for given/family name
  • Loading branch information
kcondon committed Jul 12, 2023
2 parents 33fb3a2 + f392122 commit dae1484
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Expand Up @@ -118,6 +118,15 @@ public static JsonObject getPersonOrOrganization(String name, boolean organizati
}
}
}
if(!isOrganization && givenName == null && name.contains(",")) {
//If we still think this is a person and there's only one comma, assume we can extract the given name and family name
if (!name.replaceFirst(",", "").contains(",")) {
// contributorName=<FamilyName>, <FirstName>
String[] fullName = name.split(", ");
givenName = fullName[1];
familyName = fullName[0];
}
}
JsonObjectBuilder job = new NullSafeJsonBuilder();
job.add("fullName", name);
job.add("givenName", givenName);
Expand Down
Expand Up @@ -460,23 +460,29 @@ public void testWriteContributorsElementComplete() throws XMLStreamException, IO
+ "<affiliation>ContactAffiliation3</affiliation>"
+ "</contributor>"
+ "<contributor contributorType=\"Producer\">"
+ "<contributorName>LastProducer1, FirstProducer1</contributorName>"
+ "<contributorName nameType=\"Personal\">LastProducer1, FirstProducer1</contributorName>"
+ "<givenName>FirstProducer1</givenName><familyName>LastProducer1</familyName>"
+ "<affiliation>ProducerAffiliation1</affiliation>"
+ "</contributor><contributor contributorType=\"Producer\">"
+ "<contributorName>LastProducer2, FirstProducer2</contributorName>"
+ "<contributorName nameType=\"Personal\">LastProducer2, FirstProducer2</contributorName>"
+ "<givenName>FirstProducer2</givenName><familyName>LastProducer2</familyName>"
+ "<affiliation>ProducerAffiliation2</affiliation>"
+ "</contributor>"
+ "<contributor contributorType=\"DataCollector\">"
+ "<contributorName>LastContributor1, FirstContributor1</contributorName>"
+ "<contributorName nameType=\"Personal\">LastContributor1, FirstContributor1</contributorName>"
+ "<givenName>FirstContributor1</givenName><familyName>LastContributor1</familyName>"
+ "</contributor>"
+ "<contributor contributorType=\"DataCurator\">"
+ "<contributorName>LastContributor2, FirstContributor2</contributorName>"
+ "<contributorName nameType=\"Personal\">LastContributor2, FirstContributor2</contributorName>"
+ "<givenName>FirstContributor2</givenName><familyName>LastContributor2</familyName>"
+ "</contributor><contributor contributorType=\"Distributor\">"
+ "<contributorName>LastDistributor1, FirstDistributor1</contributorName>"
+ "<contributorName nameType=\"Personal\">LastDistributor1, FirstDistributor1</contributorName>"
+ "<givenName>FirstDistributor1</givenName><familyName>LastDistributor1</familyName>"
+ "<affiliation>DistributorAffiliation1</affiliation>"
+ "</contributor>"
+ "<contributor contributorType=\"Distributor\">"
+ "<contributorName>LastDistributor2, FirstDistributor2</contributorName>"
+ "<contributorName nameType=\"Personal\">LastDistributor2, FirstDistributor2</contributorName>"
+ "<givenName>FirstDistributor2</givenName><familyName>LastDistributor2</familyName>"
+ "<affiliation>DistributorAffiliation2</affiliation>"
+ "</contributor>"
+ "</contributors>",
Expand Down
Expand Up @@ -86,7 +86,7 @@ public void testName() {
// test only family name
verifyIsPerson("Cadili", null, null);

verifyIsPerson("kcjim11, kcjim11", null, null);
verifyIsPerson("kcjim11, kcjim11", "kcjim11", "kcjim11");

verifyIsPerson("Bartholomew 3, James", "James", "Bartholomew 3");
}
Expand Down

0 comments on commit dae1484

Please sign in to comment.