Skip to content

Commit

Permalink
Works and affiliations should be working now
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Oct 2, 2023
1 parent a642e6f commit 0db12b5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 52 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 @@ -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()));
}
}
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 @@ -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 Down Expand Up @@ -447,7 +449,7 @@ RecordSummary getSummary(String orcid) {

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 0db12b5

Please sign in to comment.