Skip to content

Commit

Permalink
Using group id for updating peer review visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Dec 24, 2024
1 parent fefdfb7 commit 66b74b6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@ public interface PeerReviewManager extends PeerReviewManagerReadOnly {
* @return true if the relationship was updated
* */
public boolean updateVisibilities(String orcid, ArrayList<Long> peerReviewIds, Visibility visibility);


/**
* Updates the visibility of a list of existing peer review based on the group id
*
* @param groupId
* The group id of the peerReview that will be updated
* @param visibility
* The new visibility value for the peer review
* @return true if the relationship was updated
* */
public boolean updateVisibilitiesByGroupId(String orcid, String groupId, Visibility visibility);

/**
* Removes all peer reviews that belongs to a given record. Careful!
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ public boolean updateVisibilities(String orcid, ArrayList<Long> peerReviewIds, V
return peerReviewDao.updateVisibilities(orcid, peerReviewIds, visibility.name());
}

@Override
public boolean updateVisibilitiesByGroupId(String orcid, String groupId, Visibility visibility) {
return peerReviewDao.updateVisibilityByGroupId(orcid, groupId, visibility.name());
}

private void validateGroupId(PeerReview peerReview) {
if (!PojoUtil.isEmpty(peerReview.getGroupId())) {
if (!groupIdRecordManager.exists(peerReview.getGroupId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public interface PeerReviewDao extends GenericDao<PeerReviewEntity, Long> {
boolean updateToMaxDisplay(String orcid, Long peerReviewId);

boolean updateVisibilities(String orcid, ArrayList<Long> peerReviewIds, String visibility);

boolean updateVisibilityByGroupId(String orcid, String groupId, String visibility);

/**
* Returns a list of ids of peer reviews that still have old external identifiers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ public boolean updateVisibilities(String orcid, ArrayList<Long> peerReviewIds, S
query.setParameter("orcid", orcid);
return query.executeUpdate() > 0 ? true : false;
}

@Override
@Transactional
@UpdateProfileLastModifiedAndIndexingStatus
public boolean updateVisibilityByGroupId(String orcid, String groupId, String visibility) {
Query query = entityManager
.createQuery("update PeerReviewEntity set visibility=:visibility, lastModified=now() where groupId=:groupId and orcid=:orcid");
query.setParameter("groupId", groupId);
query.setParameter("visibility", visibility);
query.setParameter("orcid", orcid);
return query.executeUpdate() > 0 ? true : false;
}

/**
* Returns a list of ids of peer reviews that still have old external identifiers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,15 @@ public Locale getUserLocale() {
/**
* updates visibility of a peer review
*/
@RequestMapping(value = "/{peerReviewIdsStr}/visibility/{visibilityStr}", method = RequestMethod.GET)
public @ResponseBody ArrayList<Long> updateVisibilitys(@PathVariable("peerReviewIdsStr") String peerReviewIdsStr,
@RequestMapping(value = "/{groupIdValue}/visibility/{visibilityStr}", method = RequestMethod.POST)
public @ResponseBody boolean updateVisibilitys(@PathVariable("groupIdValue") String groupIdValue,
@PathVariable("visibilityStr") String visibilityStr) {
ArrayList<Long> peerReviewIds = new ArrayList<Long>();
if (PojoUtil.isEmpty(peerReviewIdsStr)) {
return peerReviewIds;
if (PojoUtil.isEmpty(groupIdValue)) {
return false;
}
// make sure this is a users work
String orcid = getEffectiveUserOrcid();
for (String peerReviewId : peerReviewIdsStr.split(","))
peerReviewIds.add(new Long(peerReviewId));
peerReviewManager.updateVisibilities(orcid, peerReviewIds, Visibility.fromValue(visibilityStr));
return peerReviewIds;
return peerReviewManager.updateVisibilitiesByGroupId(orcid, groupIdValue, Visibility.fromValue(visibilityStr));
}

private List<PeerReviewGroup> getPeerReviewsGrouped(List<PeerReviewSummary> summaries) {
Expand Down

0 comments on commit 66b74b6

Please sign in to comment.