diff --git a/orcid-core/src/main/java/org/orcid/core/manager/impl/InstitutionalSignInManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/impl/InstitutionalSignInManagerImpl.java index 9e4f3a66a9c..eedd84844d3 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/impl/InstitutionalSignInManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/impl/InstitutionalSignInManagerImpl.java @@ -152,29 +152,7 @@ public String retrieveDisplayName(Map headers) { String eppn = extractFirst(headers.get(InstitutionalSignInManager.EPPN_HEADER)); if (StringUtils.isNotBlank(eppn)) { return eppn; - } - String displayName = extractFirst(headers.get(InstitutionalSignInManager.DISPLAY_NAME_HEADER)); - if (StringUtils.isNotBlank(displayName)) { - return displayName; - } - String givenName = extractFirst(headers.get(InstitutionalSignInManager.GIVEN_NAME_HEADER)); - String sn = extractFirst(headers.get(InstitutionalSignInManager.SN_HEADER)); - String combinedNames = StringUtils.join(new String[] { givenName, sn }, ' '); - if (StringUtils.isNotBlank(combinedNames)) { - return combinedNames; - } - RemoteUser remoteUser = retrieveRemoteUser(headers); - if (remoteUser != null) { - String remoteUserId = remoteUser.getUserId(); - if (StringUtils.isNotBlank(remoteUserId)) { - int indexOfBang = remoteUserId.lastIndexOf("!"); - if (indexOfBang != -1) { - return remoteUserId.substring(indexOfBang); - } else { - return remoteUserId; - } - } - } + } return null; } 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/core/utils/v3/SourceUtils.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/SourceUtils.java index 6ded41e7837..d93db88fcb3 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 @@ -42,6 +42,7 @@ import org.orcid.jaxb.model.v3.release.record.summary.WorkGroup; 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.PojoUtil; import java.util.List; @@ -318,7 +319,7 @@ public static boolean isSelfAsserted(Source source, String orcid) { } } - public static boolean isSelfAsserted(String source, String orcid) { - return !orcid.equals(source); + public static boolean isSelfAsserted(AffiliationForm af, String orcid) { + return (orcid.equals(af.getSource()) || orcid.equals(af.getAssertionOriginOrcid())); } } 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/ajaxForm/WorkForm.java b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/WorkForm.java index e9ca4a36392..9c6f8b87b60 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/WorkForm.java +++ b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/WorkForm.java @@ -67,7 +67,7 @@ public class WorkForm extends VisibilityForm implements ErrorsInterface, Seriali private String assertionOriginClientId; private String assertionOriginName; - + private Text title; private Text subtitle; @@ -84,9 +84,7 @@ public class WorkForm extends VisibilityForm implements ErrorsInterface, Seriali private Date createdDate; - private Date lastModified; - - private boolean userSource; + private Date lastModified; public static WorkForm valueOf(Work work, int maxContributorsForUI) { if (work == null) @@ -1029,16 +1027,8 @@ public TranslatedTitleForm getTranslatedTitle() { public void setTranslatedTitle(TranslatedTitleForm translatedTitle) { this.translatedTitle = translatedTitle; - } + } - public boolean isUserSource() { - return userSource; - } - - public void setUserSource(boolean userSource) { - this.userSource = userSource; - } - @Override public int hashCode() { final int prime = 31; @@ -1204,7 +1194,7 @@ public boolean equals(Object obj) { if (other.workType != null) return false; } else if (!workType.equals(other.workType)) - return false; + return false; return true; } diff --git a/orcid-core/src/main/java/org/orcid/pojo/grouping/WorkGroup.java b/orcid-core/src/main/java/org/orcid/pojo/grouping/WorkGroup.java index a055480ad67..1bbfa1e2b30 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/grouping/WorkGroup.java +++ b/orcid-core/src/main/java/org/orcid/pojo/grouping/WorkGroup.java @@ -37,7 +37,6 @@ public static WorkGroup valueOf(org.orcid.jaxb.model.v3.release.record.summary.W Long maxDisplayIndex = null; for (WorkSummary workSummary : workGroup.getWorkSummary()) { WorkForm workForm = getWorkForm(workSummary); - workForm.setUserSource(workSummary.getSource().retrieveSourcePath() != null && workSummary.getSource().retrieveSourcePath().equals(orcid)); group.getWorks().add(workForm); Long displayIndex = Long.parseLong(workSummary.getDisplayIndex()); @@ -93,7 +92,6 @@ public static WorkGroup valueOf(WorkGroupExtended workGroup, int id, String orci Long maxDisplayIndex = null; for (WorkSummaryExtended workSummary : workGroup.getWorkSummary()) { WorkForm workForm = getWorkForm(workSummary); - workForm.setUserSource(workSummary.getSource().retrieveSourcePath() != null && workSummary.getSource().retrieveSourcePath().equals(orcid)); group.getWorks().add(workForm); Long displayIndex = Long.parseLong(workSummary.getDisplayIndex()); diff --git a/orcid-core/src/main/java/org/orcid/pojo/summary/AffiliationSummary.java b/orcid-core/src/main/java/org/orcid/pojo/summary/AffiliationSummary.java index 9995a412c38..14ed5f3594d 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/summary/AffiliationSummary.java +++ b/orcid-core/src/main/java/org/orcid/pojo/summary/AffiliationSummary.java @@ -97,7 +97,7 @@ public static AffiliationSummary valueOf(AffiliationForm as, String orcid, Strin form.setType(type); if (as.getSource() != null) { - form.setValidated(SourceUtils.isSelfAsserted(as.getSource(), orcid)); + form.setValidated(!SourceUtils.isSelfAsserted(as, orcid)); } } return form; 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 36732f9cc10..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 @@ -21,6 +21,7 @@ import org.orcid.core.manager.v3.read_only.ProfileFundingManagerReadOnly; import org.orcid.core.manager.v3.read_only.ProfileKeywordManagerReadOnly; import org.orcid.core.manager.v3.read_only.RecordManagerReadOnly; +import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly; import org.orcid.core.manager.v3.read_only.ResearchResourceManagerReadOnly; import org.orcid.core.manager.v3.read_only.ResearcherUrlManagerReadOnly; import org.orcid.core.manager.v3.read_only.WorkManagerReadOnly; @@ -164,6 +165,9 @@ public class PublicRecordController extends BaseWorkspaceController { @Resource private WorksCacheManager worksCacheManager; + + @Resource(name = "recordNameManagerReadOnlyV3") + private RecordNameManagerReadOnly recordNameManagerReadOnly; public static int ORCID_HASH_LENGTH = 8; private static final String PAGE_SIZE_DEFAULT = "50"; @@ -346,11 +350,9 @@ PublicRecord getRecord(String orcid) { RecordSummary getSummary(String orcid) { RecordSummary recordSummary = new RecordSummary(); - Record record = recordManagerReadOnly.getPublicRecord(orcid, false); - Person person = record.getPerson(); - if (person != null) { - String displayName = null; - Name name = person.getName(); + Name name = recordNameManagerReadOnly.getRecordName(orcid); + if(name != null) { + String displayName = null; if (name != null) { if (name.getVisibility().equals(org.orcid.jaxb.model.v3.release.common.Visibility.PUBLIC)) { displayName = getDisplayName(name); @@ -400,11 +402,11 @@ RecordSummary getSummary(String orcid) { if (workGroups != null) { workGroups.forEach(work -> work.getWorks().forEach(w -> { if (work.getDefaultPutCode().equals(Long.valueOf(w.getPutCode().getValue()))) { - if (!orcid.equals(w.getSource())) { - validatedWorks.getAndIncrement(); - } else { + if(orcid.equals(w.getSource()) || orcid.equals(w.getAssertionOriginOrcid())) { selfAssertedWorks.getAndIncrement(); - } + } else { + validatedWorks.getAndIncrement(); + } } })); } @@ -419,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(); + } }); } @@ -433,21 +435,28 @@ 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); } ProfileEntity profileEntity = profileEntityManager.findByOrcid(orcid); - recordSummary.setLastModified(formatDate(record.getHistory().getLastModifiedDate().getValue())); + recordSummary.setLastModified(formatDate(DateUtils.convertToXMLGregorianCalendar(profileEntity.getLastModified()))); recordSummary.setCreation(formatDate(DateUtils.convertToXMLGregorianCalendar(profileEntity.getDateCreated()))); recordSummary.setOrcid(recordManagerReadOnly.getOrcidIdentifier(orcid).getUri());