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

IQSS/9185-improve parsing for given/family name #9643

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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