Skip to content

Commit

Permalink
Allow filtering by visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Feb 16, 2024
1 parent a438bee commit eebe81b
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface PeerReviewManagerReadOnly {
List<PeerReviewMinimizedSummary> getPeerReviewMinimizedSummaryList(String orcid, boolean justPublic);


List<PeerReviewSummary> getPeerReviewSummaryListByGroupId(String orcid, String groupId);
List<PeerReviewSummary> getPeerReviewSummaryListByGroupId(String orcid, String groupId, boolean justPublic);

/**
* Generate a grouped list of peer reviews with the given list of peer reviews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public List<PeerReviewMinimizedSummary> getPeerReviewMinimizedSummaryList(String
* @return the list of peer reviews that belongs to this user
*/
@Override
public List<PeerReviewSummary> getPeerReviewSummaryListByGroupId(String orcid, String groupId) {
List<PeerReviewEntity> peerReviewEntities = peerReviewDao.getPeerReviewsByOrcidAndGroupId(orcid, groupId);
public List<PeerReviewSummary> getPeerReviewSummaryListByGroupId(String orcid, String groupId, boolean justPublic) {
List<PeerReviewEntity> peerReviewEntities = peerReviewDao.getPeerReviewsByOrcidAndGroupId(orcid, groupId, justPublic);
return jpaJaxbPeerReviewAdapter.toPeerReviewSummary(peerReviewEntities);
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,4 +737,24 @@ private PeerReview getPeerReview(String extIdValue) {

return peerReview;
}

@Test
public void testGetPeerReviewSummaryListByGroupId() {
List<PeerReviewSummary> all = peerReviewManager.getPeerReviewSummaryListByGroupId(claimedOrcid, "issn:shared", false);
assertNotNull(all);
assertEquals(3, all.size());
assertEquals(Long.valueOf(14), all.get(0).getPutCode());
assertEquals(Visibility.PRIVATE, all.get(0).getVisibility());
assertEquals(Long.valueOf(15), all.get(1).getPutCode());
assertEquals(Visibility.LIMITED, all.get(1).getVisibility());
assertEquals(Long.valueOf(16), all.get(2).getPutCode());
assertEquals(Visibility.PUBLIC, all.get(2).getVisibility());

List<PeerReviewSummary> onlyPublic = peerReviewManager.getPeerReviewSummaryListByGroupId(claimedOrcid, "issn:shared", true);
assertNotNull(onlyPublic);
assertEquals(1, onlyPublic.size());
assertEquals(Long.valueOf(16), onlyPublic.get(0).getPutCode());
assertEquals(Visibility.PUBLIC, onlyPublic.get(0).getVisibility());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface PeerReviewDao extends GenericDao<PeerReviewEntity, Long> {

List<Object[]> getPeerReviewsByOrcid(String orcid, boolean justPublic);

List<PeerReviewEntity> getPeerReviewsByOrcidAndGroupId(String orcid, String groupId);
List<PeerReviewEntity> getPeerReviewsByOrcidAndGroupId(String orcid, String groupId, boolean justPublic);

boolean updateToMaxDisplay(String orcid, Long peerReviewId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ public List<Object[]> getPeerReviewsByOrcid(String orcid, boolean justPublic) {
}

@Override
public List<PeerReviewEntity> getPeerReviewsByOrcidAndGroupId(String orcid, String groupId) {
TypedQuery<PeerReviewEntity> query = entityManager.createQuery("from PeerReviewEntity where orcid=:orcid and groupId=:groupId order by completionDate.year desc, completionDate.month desc, completionDate.day desc", PeerReviewEntity.class);
public List<PeerReviewEntity> getPeerReviewsByOrcidAndGroupId(String orcid, String groupId, boolean justPublic) {
String sqlString = null;
if(justPublic) {
sqlString = "from PeerReviewEntity where orcid=:orcid and groupId=:groupId and visibility='PUBLIC' order by completionDate.year desc, completionDate.month desc, completionDate.day desc";
} else {
sqlString = "from PeerReviewEntity where orcid=:orcid and groupId=:groupId order by completionDate.year desc, completionDate.month desc, completionDate.day desc";
}
TypedQuery<PeerReviewEntity> query = entityManager.createQuery(sqlString, PeerReviewEntity.class);
query.setParameter("orcid", orcid);
query.setParameter("groupId", groupId);
return query.getResultList();
Expand Down
54 changes: 52 additions & 2 deletions orcid-test/src/main/resources/data/PeerReviewEntityData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@
completion_day="2"
completion_month="2"
completion_year="2016"
url="http://peer_review.com/13"
url="http://peer_review.com/14"
visibility="PRIVATE"
group_id="issn:0000-0013"
group_id="issn:shared"
subject_external_identifiers_json="{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;peer-review:subject-external-identifier-id#5&quot;}}"
subject_name="SELF PRIVATE Peer Review"
subject_type="ARTISTIC_PERFORMANCE"
Expand All @@ -355,4 +355,54 @@
last_modified="2015-01-01 00:00:00.00"
display_index="4"
/>
<peer_review
id="15"
orcid="0000-0000-0000-0002"
external_identifiers_json="{&quot;workExternalIdentifier&quot;:[{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;work:external-identifier-id#5&quot;}}]}"
org_id="2"
peer_review_role="REVIEWER"
peer_review_type="REVIEW"
completion_day="2"
completion_month="2"
completion_year="2016"
url="http://peer_review.com/15"
visibility="LIMITED"
group_id="issn:shared"
subject_external_identifiers_json="{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;peer-review:subject-external-identifier-id#5&quot;}}"
subject_name="SELF PRIVATE Peer Review"
subject_type="ARTISTIC_PERFORMANCE"
subject_translated_name="SELF PRIVATE Peer Review"
subject_translated_name_language_code="es"
subject_url="http://work.com/self/private"
subject_container_name="SELF PRIVATE Peer Review"
client_source_id="APP-5555555555555555"
date_created="2015-01-01 00:00:00.00"
last_modified="2015-01-01 00:00:00.00"
display_index="5"
/>
<peer_review
id="16"
orcid="0000-0000-0000-0002"
external_identifiers_json="{&quot;workExternalIdentifier&quot;:[{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;work:external-identifier-id#5&quot;}}]}"
org_id="2"
peer_review_role="REVIEWER"
peer_review_type="REVIEW"
completion_day="2"
completion_month="2"
completion_year="2016"
url="http://peer_review.com/16"
visibility="PUBLIC"
group_id="issn:shared"
subject_external_identifiers_json="{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;peer-review:subject-external-identifier-id#5&quot;}}"
subject_name="SELF PRIVATE Peer Review"
subject_type="ARTISTIC_PERFORMANCE"
subject_translated_name="SELF PRIVATE Peer Review"
subject_translated_name_language_code="es"
subject_url="http://work.com/self/private"
subject_container_name="SELF PRIVATE Peer Review"
client_source_id="APP-5555555555555556"
date_created="2015-01-01 00:00:00.00"
last_modified="2015-01-01 00:00:00.00"
display_index="6"
/>
</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void setLocaleManager(LocaleManager localeManager) {

@RequestMapping(value = "/peer-reviews-by-group-id.json", method = RequestMethod.GET)
public @ResponseBody List<PeerReviewGroup> getPeerReviewsJsonByGroupId(@RequestParam("groupId") String groupId, @RequestParam("sortAsc") boolean sortAsc) {
List<PeerReviewGroup> peerReviewGroups = getPeerReviewsGrouped(peerReviewManager.getPeerReviewSummaryListByGroupId(getEffectiveUserOrcid(), groupId));
List<PeerReviewGroup> peerReviewGroups = getPeerReviewsGrouped(peerReviewManager.getPeerReviewSummaryListByGroupId(getEffectiveUserOrcid(), groupId, false));
peerReviewGroups.sort(new PeerReviewGroupComparator(!sortAsc));
return peerReviewGroups;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ private boolean isRecordReadyForIndexing(ProfileEntity profile) {
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/peer-reviews-by-group-id.json", method = RequestMethod.GET)
public @ResponseBody List<PeerReviewGroup> getPeerReviewsJsonByGroupId(@PathVariable("orcid") String orcid, @RequestParam("groupId") String groupId, @RequestParam("sortAsc") boolean sortAsc) {
List<PeerReviewGroup> peerReviewGroups = new ArrayList<>();
List<PeerReviewSummary> summaries = peerReviewManagerReadOnly.getPeerReviewSummaryListByGroupId(orcid, groupId);
List<PeerReviewSummary> summaries = peerReviewManagerReadOnly.getPeerReviewSummaryListByGroupId(orcid, groupId, true);
PeerReviews peerReviews = peerReviewManagerReadOnly.groupPeerReviews(summaries, false);
for (org.orcid.jaxb.model.v3.release.record.summary.PeerReviewGroup group : peerReviews.getPeerReviewGroup()) {
Optional<GroupIdRecord> groupIdRecord = groupIdRecordManagerReadOnly.findByGroupId(group.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
Expand Down

0 comments on commit eebe81b

Please sign in to comment.