Skip to content

Commit

Permalink
Working on model object
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Apr 24, 2024
1 parent 06854bc commit df77595
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
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;
import org.orcid.core.model.RecordSummary;
import org.orcid.core.utils.SourceEntityUtils;
import org.orcid.core.utils.v3.ContributorUtils;
import org.orcid.core.utils.v3.SourceUtils;
Expand Down Expand Up @@ -127,7 +128,7 @@
import org.orcid.jaxb.model.v3.release.record.summary.Works;
import org.orcid.jaxb.model.v3.release.search.Search;
import org.orcid.jaxb.model.v3.release.search.expanded.ExpandedSearch;
import org.orcid.pojo.summary.RecordSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.orcid.core.common.manager;

import org.orcid.pojo.summary.RecordSummary;
import org.orcid.core.model.RecordSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;

public interface SummaryManager {
RecordSummary getRecordSummary(String orcid);

RecordSummaryPojo getRecordSummaryPojo(String orcid);
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import javax.xml.bind.annotation.XmlRootElement;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import java.util.Objects;

import javax.annotation.Resource;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;

import org.orcid.core.manager.impl.OrcidUrlManager;
import org.orcid.jaxb.model.common_v2.SourceClientId;
import org.orcid.jaxb.model.v3.release.common.CreatedDate;
import org.orcid.jaxb.model.v3.release.common.LastModifiedDate;
import org.orcid.jaxb.model.v3.release.common.OrcidIdentifier;
import org.orcid.pojo.summary.AffiliationSummary;
import org.orcid.utils.DateUtils;

import io.swagger.v3.oas.annotations.media.Schema;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "createdDate", "lastModifiedDate", "creditName", "orcidIdentifier", "externalIdentifiers", "employments", "profilessionalActivities", "fundings",
@XmlType(propOrder = { "createdDate", "lastModifiedDate", "creditName", "orcidIdentifier", "orcidIdentifier", "externalIdentifiers", "employments", "profilessionalActivities", "fundings",
"works", "peerReviews" })
@XmlRootElement(name = "work-summary", namespace = "http://www.orcid.org/ns/work")
@Schema(description = "Record summary")
public class RecordSummary {

@Resource
private OrcidUrlManager orcidUrlManager;
@XmlElement(name = "last-modified-date", namespace = "http://www.orcid.org/ns/common")
private LastModifiedDate lastModifiedDate;
@XmlElement(name = "created-date", namespace = "http://www.orcid.org/ns/common")
private CreatedDate createdDate;
@XmlElement(name = "credit-name", namespace = "http://www.orcid.org/ns/summary")
private String creditName;
@XmlElement(name = "orcid-identifier", namespace = "http://www.orcid.org/ns/common")
protected OrcidIdentifier orcidIdentifier;
@XmlElement(name = "external-identifiers", namespace = "http://www.orcid.org/ns/summary")
private ExternalIdentifiers externalIdentifiers;
@XmlElement(name = "employments", namespace = "http://www.orcid.org/ns/summary")
Expand All @@ -39,6 +49,14 @@ public class RecordSummary {
@XmlElement(name = "peer-reviews", namespace = "http://www.orcid.org/ns/summary")
private PeerReviews peerReviews;

public OrcidIdentifier getOrcidIdentifier() {
return orcidIdentifier;
}

public void setOrcidIdentifier(OrcidIdentifier orcidIdentifier) {
this.orcidIdentifier = orcidIdentifier;
}

public LastModifiedDate getLastModifiedDate() {
return lastModifiedDate;
}
Expand Down Expand Up @@ -113,7 +131,8 @@ public void setPeerReviews(PeerReviews peerReviews) {

@Override
public int hashCode() {
return Objects.hash(createdDate, creditName, employments, externalIdentifiers, fundings, lastModifiedDate, peerReviews, professionalActivities, works);
return Objects.hash(createdDate, creditName, employments, externalIdentifiers, fundings, lastModifiedDate, orcidIdentifier, orcidUrlManager, peerReviews,
professionalActivities, works);
}

@Override
Expand All @@ -127,12 +146,8 @@ public boolean equals(Object obj) {
RecordSummary other = (RecordSummary) obj;
return Objects.equals(createdDate, other.createdDate) && Objects.equals(creditName, other.creditName) && Objects.equals(employments, other.employments)
&& Objects.equals(externalIdentifiers, other.externalIdentifiers) && Objects.equals(fundings, other.fundings)
&& Objects.equals(lastModifiedDate, other.lastModifiedDate) && Objects.equals(peerReviews, other.peerReviews)
&& Objects.equals(lastModifiedDate, other.lastModifiedDate) && Objects.equals(orcidIdentifier, other.orcidIdentifier)
&& Objects.equals(orcidUrlManager, other.orcidUrlManager) && Objects.equals(peerReviews, other.peerReviews)
&& Objects.equals(professionalActivities, other.professionalActivities) && Objects.equals(works, other.works);
}

public RecordSummary valueOf(org.orcid.pojo.summary.RecordSummary coreSummaryObject) {
RecordSummary summary = new RecordSummary();
return summary;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orcid.api.member.model;
package org.orcid.core.model;

import javax.xml.bind.annotation.XmlRootElement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@XmlRootElement
public class RecordSummary {
public class RecordSummaryPojo {
@JsonInclude(Include.NON_NULL)
private String name;
private String orcid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.orcid.core.manager.v3.read_only.ProfileFundingManagerReadOnly;
import org.orcid.core.manager.v3.read_only.RecordManagerReadOnly;
import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly;
import org.orcid.core.model.RecordSummary;
import org.orcid.jaxb.model.v3.release.common.CreatedDate;
import org.orcid.jaxb.model.v3.release.common.CreditName;
import org.orcid.jaxb.model.v3.release.common.FuzzyDate;
Expand Down Expand Up @@ -62,7 +63,6 @@
import org.orcid.jaxb.model.v3.release.record.summary.Works;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.pojo.PeerReviewMinimizedSummary;
import org.orcid.pojo.summary.RecordSummary;
import org.orcid.utils.DateUtils;
import org.springframework.test.util.ReflectionTestUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.orcid.pojo.ajaxForm.OtherNamesForm;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.pojo.ajaxForm.WebsitesForm;
import org.orcid.pojo.summary.RecordSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -212,8 +212,8 @@ PublicRecord getRecord(String orcid) {
}

@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/summary.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody RecordSummary getSummaryRecord(@PathVariable("orcid") String orcid) {
RecordSummary recordSummary = new RecordSummary();
public @ResponseBody RecordSummaryPojo getSummaryRecord(@PathVariable("orcid") String orcid) {
RecordSummaryPojo recordSummary = new RecordSummaryPojo();
try {
// Check if the profile is deprecated or locked
orcidSecurityManager.checkProfile(orcid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.orcid.jaxb.model.common.Iso3166Country;
import org.orcid.jaxb.model.v3.release.common.Visibility;
import org.orcid.pojo.PublicRecord;
import org.orcid.pojo.summary.RecordSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;
import org.orcid.test.DBUnitTest;
import org.orcid.test.OrcidJUnit4ClassRunner;
import org.springframework.test.context.ContextConfiguration;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void testGetPublicRecord() {

@Test
public void testGetRecordSummary() {
RecordSummary record = publicRecordController.getSummaryRecord(userOrcid);
RecordSummaryPojo record = publicRecordController.getSummaryRecord(userOrcid);

assertEquals("active", record.getStatus());
assertNotNull(record.getName());
Expand Down Expand Up @@ -191,7 +191,7 @@ public void testGetRecordSummary() {

@Test
public void testGetRecordSummaryDeactivated() {
RecordSummary record = publicRecordController.getSummaryRecord(deactivatedUserOrcid);
RecordSummaryPojo record = publicRecordController.getSummaryRecord(deactivatedUserOrcid);

assertEquals("Given Names Deactivated Family Name Deactivated", record.getName());

Expand All @@ -200,7 +200,7 @@ public void testGetRecordSummaryDeactivated() {

@Test
public void testGetRecordSummaryLocked() {
RecordSummary record = publicRecordController.getSummaryRecord(lockedUserOrcid);
RecordSummaryPojo record = publicRecordController.getSummaryRecord(lockedUserOrcid);

assertNotNull(record.getName());
assertEquals("Given Names Deactivated Family Name Deactivated", record.getName());
Expand All @@ -210,7 +210,7 @@ public void testGetRecordSummaryLocked() {

@Test
public void testGetRecordSummaryDeprecated() {
RecordSummary record = publicRecordController.getSummaryRecord(deprecatedUserOrcid);
RecordSummaryPojo record = publicRecordController.getSummaryRecord(deprecatedUserOrcid);

assertNull(record.getName());

Expand All @@ -219,14 +219,14 @@ public void testGetRecordSummaryDeprecated() {

@Test
public void testGetRecordSummaryPrivateName() {
RecordSummary record = publicRecordController.getSummaryRecord(unclaimedUserOrcid);
RecordSummaryPojo record = publicRecordController.getSummaryRecord(unclaimedUserOrcid);

assertNull(record.getName());
}

@Test
public void testGetRecordSummaryProfessionalActivitiesSortedByEndDate() {
RecordSummary record = publicRecordController.getSummaryRecord("0000-0000-0000-0008");
RecordSummaryPojo record = publicRecordController.getSummaryRecord("0000-0000-0000-0008");

assertEquals(5, record.getProfessionalActivitiesCount());
assertNull(record.getProfessionalActivities().get(0).getEndDate());
Expand Down

0 comments on commit df77595

Please sign in to comment.