Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions orcid-test/src/main/resources/data/OrgAffiliationEntityData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1152,10 +1152,10 @@
department="PUBLIC Department"
date_created="2023-01-05 15:31:00.00"
last_modified="2023-01-05 15:31:00.00"
start_year="2023"
start_year="1999"
start_month="01"
start_day="05"
end_year="2030"
end_year="2000"
end_month="01"
end_day="01"
visibility="PUBLIC"
Expand All @@ -1172,12 +1172,8 @@
department="PUBLIC Department"
date_created="2023-01-04 15:31:00.00"
last_modified="2023-01-04 15:31:00.00"
start_year="2023"
start_month="01"
start_day="04"
end_year="2030"
end_month="01"
end_day="03"
start_year="2014"
end_year="2017"
visibility="PUBLIC"
client_source_id="APP-5555555555555555"
display_index="1"
Expand All @@ -1187,17 +1183,14 @@
id="1009"
org_id="2"
orcid="0000-0000-0000-0008"
org_affiliation_relation_role="INVITED_POSITION"
org_affiliation_relation_role="DISTINCTION"
org_affiliation_relation_title="PUBLIC"
department="PUBLIC Department"
date_created="2023-01-03 15:31:00.00"
last_modified="2023-01-03 15:31:00.00"
start_year="2023"
start_month="01"
start_day="03"
end_year="2023"
end_month="05"
end_day="01"
start_year="2021"
start_month="12"
start_day="05"
visibility="PUBLIC"
client_source_id="APP-5555555555555555"
display_index="1"
Expand All @@ -1212,8 +1205,11 @@
department="PUBLIC Department"
date_created="2023-01-02 15:31:00.00"
last_modified="2023-01-02 15:31:00.00"
start_year="2023"
start_year="2022"
start_month="01"
start_day="01"
end_year="2023"
end_month="01"
end_day="01"
visibility="PUBLIC"
client_source_id="APP-5555555555555555"
Expand All @@ -1228,9 +1224,6 @@
department="SELF PUBLIC Department"
date_created="2023-01-01 15:31:00.00"
last_modified="2023-01-01 15:31:00.00"
start_year="2023"
start_month="01"
start_day="01"
visibility="PUBLIC"
source_id="0000-0000-0000-0003"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.orcid.jaxb.model.v3.release.record.PersonalDetails;
import org.orcid.jaxb.model.v3.release.record.Record;
import org.orcid.jaxb.model.v3.release.record.ResearcherUrls;
import org.orcid.jaxb.model.v3.release.record.summary.ActivitiesSummary;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.pojo.PeerReviewMinimizedSummary;
import org.orcid.pojo.PublicRecord;
Expand Down Expand Up @@ -173,7 +172,7 @@ public class PublicRecordController extends BaseWorkspaceController {
public @ResponseBody
PublicRecord getPublicRecord(@PathVariable("orcid") String orcid) {
PublicRecord publicRecord = new PublicRecord();
Boolean isDeprecated = false;
boolean isDeprecated = false;

try {
// Check if the profile is deprecated or locked
Expand Down Expand Up @@ -224,16 +223,7 @@ PublicRecord getRecord(String orcid) {
if (publicPersonalDetails.getName() != null) {
Name name = publicPersonalDetails.getName();
if (name.getVisibility().equals(org.orcid.jaxb.model.v3.release.common.Visibility.PUBLIC)) {
if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
displayName = name.getCreditName().getContent();
} else {
if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
displayName = name.getGivenNames().getContent() + " ";
}
if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
displayName += name.getFamilyName().getContent();
}
}
displayName = getDisplayName(name);
publicRecord.setNames(NamesForm.valueOf(name));
}
}
Expand All @@ -256,13 +246,7 @@ PublicRecord getRecord(String orcid) {
// Fill other names
OtherNames publicOtherNames = publicPersonalDetails.getOtherNames();
if (publicOtherNames != null && publicOtherNames.getOtherNames() != null) {
Iterator<OtherName> it = publicOtherNames.getOtherNames().iterator();
while (it.hasNext()) {
OtherName otherName = it.next();
if (!org.orcid.jaxb.model.v3.release.common.Visibility.PUBLIC.equals(otherName.getVisibility())) {
it.remove();
}
}
publicOtherNames.getOtherNames().removeIf(otherName -> !org.orcid.jaxb.model.v3.release.common.Visibility.PUBLIC.equals(otherName.getVisibility()));
}
publicRecord.setOtherNames(OtherNamesForm.valueOf(publicOtherNames));
}
Expand Down Expand Up @@ -299,9 +283,9 @@ PublicRecord getRecord(String orcid) {

Emails filteredEmails = new Emails();
if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) {
filteredEmails.setEmails(new ArrayList<Email>(publicEmails.getEmails().stream().filter(e -> e.isVerified()).collect(Collectors.toList())));
filteredEmails.setEmails(new ArrayList<>(publicEmails.getEmails().stream().filter(Email::isVerified).collect(Collectors.toList())));
} else {
filteredEmails.setEmails(new ArrayList<Email>(publicEmails.getEmails()));
filteredEmails.setEmails(new ArrayList<>(publicEmails.getEmails()));
}

publicRecord.setEmails(org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails));
Expand All @@ -322,7 +306,7 @@ PublicRecord getRecord(String orcid) {
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/summary.json", method = RequestMethod.GET)
public @ResponseBody RecordSummary getSummaryRecord(@PathVariable("orcid") String orcid) {
RecordSummary recordSummary = new RecordSummary();
Boolean isDeprecated = false;
boolean isDeprecated = false;

try {
// Check if the profile is deprecated or locked
Expand Down Expand Up @@ -351,12 +335,11 @@ PublicRecord getRecord(String orcid) {
recordSummary.setProfessionalActivities(null);
recordSummary.setExternalIdentifiers(null);

return recordSummary;
} else {
recordSummary = getSummary(orcid);
recordSummary.setStatus("active");
return recordSummary;
}
return recordSummary;
}

public @ResponseBody
Expand All @@ -370,16 +353,7 @@ RecordSummary getSummary(String orcid) {
Name name = person.getName();
if (name != null) {
if (name.getVisibility().equals(org.orcid.jaxb.model.v3.release.common.Visibility.PUBLIC)) {
if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
displayName = name.getCreditName().getContent();
} else {
if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
displayName = name.getGivenNames().getContent() + " ";
}
if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
displayName += name.getFamilyName().getContent();
}
}
displayName = getDisplayName(name);
}
}
recordSummary.setName(displayName);
Expand Down Expand Up @@ -481,6 +455,21 @@ RecordSummary getSummary(String orcid) {
return recordSummary;
}

private String getDisplayName(Name name) {
String displayName = null;
if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
displayName = name.getCreditName().getContent();
} else {
if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
displayName = name.getGivenNames().getContent() + " ";
}
if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
displayName += name.getFamilyName().getContent();
}
}
return displayName;
}

private List<AffiliationSummary> retrieveProfessionalActivities(AffiliationGroupContainer groupedAffiliations, String orcid) {
List<AffiliationSummary> professionalActivities = new ArrayList<>();

Expand Down Expand Up @@ -512,7 +501,14 @@ private void sortAffiliationsByCreatedDate(List<AffiliationGroupForm> affiliatio
List<Long> activePutCodesWithOutDate = new ArrayList<>();

affiliationGroupForms.forEach(affiliationGroupForm -> {
if (affiliationGroupForm.getDefaultAffiliation().getEndDate().getYear() == null || "".equals(affiliationGroupForm.getDefaultAffiliation().getEndDate().getYear())) {
if ("distinction".equals(affiliationGroupForm.getDefaultAffiliation().getAffiliationType().getValue()) &&
affiliationGroupForm.getDefaultAffiliation().getStartDate().getYear() != null
) {
affiliationGroupForm.getDefaultAffiliation().setEndDate(affiliationGroupForm.getDefaultAffiliation().getStartDate());
}

if (affiliationGroupForm.getDefaultAffiliation().getEndDate().getYear() == null ||
"".equals(affiliationGroupForm.getDefaultAffiliation().getEndDate().getYear())) {
activePutCodesWithOutDate.add(affiliationGroupForm.getActivePutCode());
affiliationGroupForm.getDefaultAffiliation().setEndDate(Date.valueOf(new java.util.Date()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ public void testGetRecordSummaryProfessionalActivitiesSortedByEndDate() {
RecordSummary record = publicRecordController.getSummaryRecord("0000-0000-0000-0008");

assertEquals(5, record.getProfessionalActivitiesCount());
assertEquals("2030-01-03", record.getProfessionalActivities().get(0).getEndDate());
assertEquals("2030-01-01", record.getProfessionalActivities().get(1).getEndDate());
assertNull(record.getProfessionalActivities().get(2).getEndDate());
assertNull(record.getProfessionalActivities().get(0).getEndDate());
assertEquals("2023-01-01", record.getProfessionalActivities().get(1).getEndDate());
assertEquals("2021-12-05", record.getProfessionalActivities().get(2).getEndDate());
}
}