From 17e3052374b490d5efaa28175b63110405623c16 Mon Sep 17 00:00:00 2001 From: amontenegro Date: Mon, 2 Oct 2023 14:13:50 -0600 Subject: [PATCH] Peer reviews and funding done --- .../impl/PeerReviewManagerReadOnlyImpl.java | 15 +++++++- .../pojo/PeerReviewMinimizedSummary.java | 37 +++++++++++++++++-- .../org/orcid/pojo/summary/RecordSummary.java | 9 +++++ .../dao/impl/PeerReviewDaoImpl.java | 4 +- .../controllers/PublicRecordController.java | 17 ++++++--- 5 files changed, 70 insertions(+), 12 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 ba3de16b8c6..2649d563c9f 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,6 +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(); if (peerReviewMinimizedSummaryList.size() > 0) { List peerReviews = peerReviewMinimizedSummaryList .stream() @@ -103,10 +106,18 @@ public List getPeerReviewMinimizedSummaryList(String peerReviews.get(0).setVisibilityError(true); } } else { - peerReviewMinimizedSummaryList.add(new PeerReviewMinimizedSummary(orcid, groupId, groupIdValue, putCode, Visibility.fromValue(visibility), groupName, 1)); + PeerReviewMinimizedSummary ps = new PeerReviewMinimizedSummary(orcid, groupId, groupIdValue, putCode, Visibility.fromValue(visibility), groupName, 1); + ps.setAssertionOriginSourceId(assertionOriginSourceId); + ps.setClientSourceId(clientSourceId); + ps.setSourceId(sourceId); + peerReviewMinimizedSummaryList.add(ps); } } else { - peerReviewMinimizedSummaryList.add(new PeerReviewMinimizedSummary(orcid, groupId, groupIdValue, putCode, Visibility.fromValue(visibility), groupName, 1)); + PeerReviewMinimizedSummary ps = new PeerReviewMinimizedSummary(orcid, groupId, groupIdValue, putCode, Visibility.fromValue(visibility), groupName, 1); + ps.setAssertionOriginSourceId(assertionOriginSourceId); + ps.setClientSourceId(clientSourceId); + ps.setSourceId(sourceId); + peerReviewMinimizedSummaryList.add(ps); } } return peerReviewMinimizedSummaryList; diff --git a/orcid-core/src/main/java/org/orcid/pojo/PeerReviewMinimizedSummary.java b/orcid-core/src/main/java/org/orcid/pojo/PeerReviewMinimizedSummary.java index 1a0152c0d23..0eefba59321 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/PeerReviewMinimizedSummary.java +++ b/orcid-core/src/main/java/org/orcid/pojo/PeerReviewMinimizedSummary.java @@ -9,6 +9,7 @@ import java.util.Objects; public class PeerReviewMinimizedSummary implements Serializable { + private static final long serialVersionUID = 5900200502612060021L; private String orcid; private BigInteger groupId; @@ -18,7 +19,10 @@ public class PeerReviewMinimizedSummary implements Serializable { private boolean visibilityError; private String name; private int duplicated; - + private String sourceId; + private String clientSourceId; + private String assertionOriginSourceId; + public PeerReviewMinimizedSummary(String orcid, BigInteger groupId, String groupIdValue, BigInteger putCode, Visibility visibility, String name, int duplicated) { this.orcid = orcid; this.groupId = groupId; @@ -97,6 +101,30 @@ public void addPutCode(BigInteger putCode) { this.putCodes.add(putCode); } + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getClientSourceId() { + return clientSourceId; + } + + public void setClientSourceId(String clientSourceId) { + this.clientSourceId = clientSourceId; + } + + public String getAssertionOriginSourceId() { + return assertionOriginSourceId; + } + + public void setAssertionOriginSourceId(String assertionOriginSourceId) { + this.assertionOriginSourceId = assertionOriginSourceId; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -107,11 +135,14 @@ public boolean equals(Object o) { Objects.equals(getGroupId(), that.getGroupId()) && Objects.equals(getGroupIdValue(), that.getGroupIdValue()) && getVisibility() == that.getVisibility() && - Objects.equals(getName(), that.getName()); + Objects.equals(getName(), that.getName()) && + Objects.equals(getSourceId(), that.getSourceId()) && + Objects.equals(getClientSourceId(), that.getClientSourceId()) && + Objects.equals(getAssertionOriginSourceId(), that.getAssertionOriginSourceId()); } @Override public int hashCode() { - return Objects.hash(getOrcid(), getGroupId(), getGroupIdValue(), getVisibility(), getName(), getDuplicated()); + return Objects.hash(getOrcid(), getGroupId(), getGroupIdValue(), getVisibility(), getName(), getDuplicated(), getSourceId(), getClientSourceId(), getAssertionOriginSourceId()); } } diff --git a/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummary.java b/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummary.java index a0fbf020f42..6f9a20ec1d6 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummary.java +++ b/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummary.java @@ -16,6 +16,7 @@ public class RecordSummary { private String lastModified; private int validatedWorks; private int selfAssertedWorks; + private int selfAssertedPeerReviews; private int peerReviewsTotal; private int peerReviewPublicationGrants; private int validatedFunds; @@ -89,6 +90,14 @@ public void setSelfAssertedWorks(int selfAssertedWorks) { this.selfAssertedWorks = selfAssertedWorks; } + public int getSelfAssertedPeerReviews() { + return selfAssertedPeerReviews; + } + + public void setSelfAssertedPeerReviews(int selfAssertedPeerReviews) { + this.selfAssertedPeerReviews = selfAssertedPeerReviews; + } + public int getPeerReviewsTotal() { return peerReviewsTotal; } diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PeerReviewDaoImpl.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PeerReviewDaoImpl.java index c1c209c6d04..14778272624 100644 --- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PeerReviewDaoImpl.java +++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PeerReviewDaoImpl.java @@ -50,9 +50,9 @@ public List getByUser(String userOrcid, long lastModified) { public List getPeerReviewsByOrcid(String orcid, boolean justPublic) { String sqlString = null; if (justPublic) { - sqlString = "SELECT g.id, p.group_id, p.id as put_code, p.visibility, g.group_name FROM peer_review p, group_id_record g WHERE p.orcid=:orcid AND p.visibility='PUBLIC' AND lower(p.group_id)=lower(g.group_id) ORDER BY p.group_id, p.display_index, p.date_created"; + sqlString = "SELECT g.id, p.group_id, p.id as put_code, p.visibility, g.group_name, p.source_id, p.client_source_id, p.assertion_origin_source_id FROM peer_review p, group_id_record g WHERE p.orcid=:orcid AND p.visibility='PUBLIC' AND lower(p.group_id)=lower(g.group_id) ORDER BY p.group_id, p.display_index, p.date_created"; } else { - sqlString = "SELECT g.id, p.group_id, p.id as put_code, p.visibility, g.group_name FROM peer_review p, group_id_record g WHERE p.orcid=:orcid AND lower(p.group_id)=lower(g.group_id) ORDER BY p.group_id, p.display_index, p.date_created"; + sqlString = "SELECT g.id, p.group_id, p.id as put_code, p.visibility, g.group_name, p.source_id, p.client_source_id, p.assertion_origin_source_id FROM peer_review p, group_id_record g WHERE p.orcid=:orcid AND lower(p.group_id)=lower(g.group_id) ORDER BY p.group_id, p.display_index, p.date_created"; } Query query = entityManager.createNativeQuery(sqlString); query.setParameter("orcid", orcid); diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java index 941ee89a19b..f0b9d6e2ff5 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java @@ -421,11 +421,11 @@ RecordSummary getSummary(String orcid) { if (fundingGroups != null) { fundingGroups.forEach(fundingGroup -> { - if (!orcid.equals(fundingGroup.getDefaultFunding().getSource())) { - validatedFunds.getAndIncrement(); - } else { + if(orcid.equals(fundingGroup.getDefaultFunding().getSource()) || orcid.equals(fundingGroup.getDefaultFunding().getAssertionOriginOrcid())) { selfAssertedFunds.getAndIncrement(); - } + } else { + validatedFunds.getAndIncrement(); + } }); } @@ -435,15 +435,22 @@ RecordSummary getSummary(String orcid) { List peerReviewMinimizedSummaryList = peerReviewManagerReadOnly.getPeerReviewMinimizedSummaryList(orcid, true); AtomicInteger totalReviewsCount = new AtomicInteger(); - + AtomicInteger selfAssertedPeerReviews = new AtomicInteger(); + + if (peerReviewMinimizedSummaryList != null) { peerReviewMinimizedSummaryList.forEach(peerReviewMinimizedSummary -> { totalReviewsCount.set(totalReviewsCount.intValue() + peerReviewMinimizedSummary.getPutCodes().size()); + if(orcid.equals(peerReviewMinimizedSummary.getSourceId()) || orcid.equals(peerReviewMinimizedSummary.getAssertionOriginSourceId())) { + selfAssertedPeerReviews.getAndIncrement(); + } }); + recordSummary.setSelfAssertedPeerReviews(selfAssertedPeerReviews.intValue()); recordSummary.setPeerReviewsTotal(totalReviewsCount.intValue()); recordSummary.setPeerReviewPublicationGrants(peerReviewMinimizedSummaryList.size()); } else { recordSummary.setPeerReviewsTotal(0); + recordSummary.setSelfAssertedPeerReviews(0); recordSummary.setPeerReviewPublicationGrants(0); }