Skip to content

Commit

Permalink
Merge pull request #6896 from ORCID/OBOSelfAssertedActivities
Browse files Browse the repository at this point in the history
Self asserted activities should not have the green check on the summary
  • Loading branch information
amontenegro authored Oct 2, 2023
2 parents a642e6f + 17e3052 commit e4a0c5f
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,29 +152,7 @@ public String retrieveDisplayName(Map<String, String> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public List<PeerReviewMinimizedSummary> 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<PeerReviewMinimizedSummary> peerReviews = peerReviewMinimizedSummaryList
.stream()
Expand All @@ -103,10 +106,18 @@ public List<PeerReviewMinimizedSummary> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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());
}
}
18 changes: 4 additions & 14 deletions orcid-core/src/main/java/org/orcid/pojo/ajaxForm/WorkForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class WorkForm extends VisibilityForm implements ErrorsInterface, Seriali
private String assertionOriginClientId;

private String assertionOriginName;

private Text title;

private Text subtitle;
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public List<PeerReviewEntity> getByUser(String userOrcid, long lastModified) {
public List<Object[]> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}
}));
}
Expand All @@ -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();
}
});
}

Expand All @@ -433,21 +435,28 @@ RecordSummary getSummary(String orcid) {
List<PeerReviewMinimizedSummary> 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());
Expand Down

0 comments on commit e4a0c5f

Please sign in to comment.