From 17ea543bbf5767c0abee3774dd6a5faa747b567f Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Tue, 3 Oct 2023 14:26:07 -0500 Subject: [PATCH] fix: Update isSelfAsserted method in funding and fix NPE in peer review --- .../v3/read_only/impl/PeerReviewManagerReadOnlyImpl.java | 8 ++++---- .../main/java/org/orcid/core/utils/v3/SourceUtils.java | 5 +++-- .../core/utils/v3/activities/FundingComparators.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/PeerReviewManagerReadOnlyImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/PeerReviewManagerReadOnlyImpl.java index 2649d563c9f..ef33f24cd87 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/PeerReviewManagerReadOnlyImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/PeerReviewManagerReadOnlyImpl.java @@ -91,9 +91,9 @@ public List getPeerReviewMinimizedSummaryList(String BigInteger putCode = (BigInteger) q1[2]; String visibility = q1[3].toString(); String groupName = q1[4].toString(); - String sourceId = q1[5].toString(); - String clientSourceId = q1[6].toString(); - String assertionOriginSourceId = q1[7].toString(); + String sourceId = q1[5] != null ? q1[5].toString() : null; + String clientSourceId = q1[6] != null ? q1[6].toString() : null; + String assertionOriginSourceId = q1[7] != null ? q1[7].toString() : null; if (peerReviewMinimizedSummaryList.size() > 0) { List peerReviews = peerReviewMinimizedSummaryList .stream() @@ -230,4 +230,4 @@ public Boolean hasPublicPeerReviews(String orcid) { return peerReviewDao.hasPublicPeerReviews(orcid); } -} \ No newline at end of file +} diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/SourceUtils.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/SourceUtils.java index 99f95e4bd85..a2eeb5af8f1 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/SourceUtils.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/SourceUtils.java @@ -43,6 +43,7 @@ import org.orcid.jaxb.model.v3.release.record.summary.WorkSummary; import org.orcid.jaxb.model.v3.release.record.summary.Works; import org.orcid.pojo.ajaxForm.AffiliationForm; +import org.orcid.pojo.ajaxForm.FundingForm; import org.orcid.pojo.ajaxForm.PojoUtil; import java.util.List; @@ -323,7 +324,7 @@ public static boolean isSelfAsserted(AffiliationForm af, String orcid) { return (orcid.equals(af.getSource()) || orcid.equals(af.getAssertionOriginOrcid())); } - public static boolean isSelfAsserted(String source, String orcid) { - return !orcid.equals(source); + public static boolean isSelfAsserted(FundingForm ff, String orcid) { + return (orcid.equals(ff.getSource()) || orcid.equals(ff.getAssertionOriginOrcid())); } } diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java index 89a4a2217e6..3f24dce975d 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java @@ -110,6 +110,6 @@ public Comparator getInstance(String key, boolean sortAsc, String public Comparator SOURCE_COMPARATOR = (g1, g2) -> Boolean.compare(isSelfAsserted(g1), isSelfAsserted(g2)); private boolean isSelfAsserted(FundingGroup fundingGroup) { - return SourceUtils.isSelfAsserted(fundingGroup.getSource(), orcid); + return SourceUtils.isSelfAsserted(fundingGroup.getDefaultFunding(), orcid); } }