From bdb6d1cef23534333a69e1cd59304e431b93700f Mon Sep 17 00:00:00 2001 From: amontenegro Date: Wed, 26 Jun 2024 11:38:49 -0600 Subject: [PATCH] When a peer review is created, add the ext id to the notification --- .../manager/impl/PeerReviewManagerImpl.java | 16 +++++++++++++++- .../manager/v3/impl/PeerReviewManagerImpl.java | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/manager/impl/PeerReviewManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/impl/PeerReviewManagerImpl.java index 886de385bcf..eb61fcf3a4f 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/impl/PeerReviewManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/impl/PeerReviewManagerImpl.java @@ -33,6 +33,8 @@ import org.orcid.jaxb.model.notification.amended_v2.AmendedSection; import org.orcid.jaxb.model.notification.permission_v2.Item; import org.orcid.jaxb.model.notification.permission_v2.ItemType; +import org.orcid.jaxb.model.record_v2.ExternalID; +import org.orcid.jaxb.model.record_v2.ExternalIDs; import org.orcid.jaxb.model.record_v2.PeerReview; import org.orcid.persistence.jpa.entities.OrgEntity; import org.orcid.persistence.jpa.entities.PeerReviewEntity; @@ -127,7 +129,7 @@ public PeerReview createPeerReview(String orcid, PeerReview peerReview, boolean peerReviewDao.persist(entity); peerReviewDao.flush(); - notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity, ActionType.CREATE)); + notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity, ActionType.CREATE, peerReview.getExternalIdentifiers(), peerReview.getSubjectExternalIdentifier())); return jpaJaxbPeerReviewAdapter.toPeerReview(entity); } @@ -236,6 +238,10 @@ private void validateGroupId(PeerReview peerReview) { } private List createItemList(PeerReviewEntity peerReviewEntity, ActionType type) { + return createItemList(peerReviewEntity, type, null, null); + } + + private List createItemList(PeerReviewEntity peerReviewEntity, ActionType type, ExternalIDs extIds, ExternalID subjectExtId) { Item item = new Item(); item.setItemType(ItemType.PEER_REVIEW); item.setPutCode(String.valueOf(peerReviewEntity.getId())); @@ -254,6 +260,14 @@ private List createItemList(PeerReviewEntity peerReviewEntity, ActionType } } + if(extIds != null) { + additionalInfo.put("external_identifiers", extIds); + } + + if(subjectExtId != null) { + additionalInfo.put("subject_external_identifiers", subjectExtId); + } + item.setItemName(itemName); item.setAdditionalInfo(additionalInfo); return Arrays.asList(item); diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/PeerReviewManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/PeerReviewManagerImpl.java index ef3aa3fba55..42345b38493 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/PeerReviewManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/PeerReviewManagerImpl.java @@ -35,6 +35,8 @@ import org.orcid.jaxb.model.v3.release.notification.amended.AmendedSection; import org.orcid.jaxb.model.v3.release.notification.permission.Item; import org.orcid.jaxb.model.v3.release.notification.permission.ItemType; +import org.orcid.jaxb.model.v3.release.record.ExternalID; +import org.orcid.jaxb.model.v3.release.record.ExternalIDs; import org.orcid.jaxb.model.v3.release.record.PeerReview; import org.orcid.persistence.jpa.entities.OrgEntity; import org.orcid.persistence.jpa.entities.PeerReviewEntity; @@ -123,7 +125,8 @@ public PeerReview createPeerReview(String orcid, PeerReview peerReview, boolean peerReviewDao.persist(entity); peerReviewDao.flush(); - notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity, ActionType.CREATE)); + + notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity, ActionType.CREATE, peerReview.getExternalIdentifiers(), peerReview.getSubjectExternalIdentifier())); return jpaJaxbPeerReviewAdapter.toPeerReview(entity); } @@ -171,7 +174,7 @@ public PeerReview updatePeerReview(String orcid, PeerReview peerReview, boolean existingEntity = peerReviewDao.merge(existingEntity); peerReviewDao.flush(); - notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(existingEntity, ActionType.UPDATE)); + notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(existingEntity, ActionType.UPDATE, peerReview.getExternalIdentifiers(), peerReview.getSubjectExternalIdentifier())); return jpaJaxbPeerReviewAdapter.toPeerReview(existingEntity); } @@ -223,6 +226,9 @@ private void validateGroupId(PeerReview peerReview) { } private List createItemList(PeerReviewEntity peerReviewEntity, ActionType type) { + return createItemList(peerReviewEntity, type, null, null); + } + private List createItemList(PeerReviewEntity peerReviewEntity, ActionType type, ExternalIDs extIds, ExternalID subjectExtId) { Item item = new Item(); item.setItemType(ItemType.PEER_REVIEW); item.setPutCode(String.valueOf(peerReviewEntity.getId())); @@ -231,7 +237,6 @@ private List createItemList(PeerReviewEntity peerReviewEntity, ActionType additionalInfo.put("subject_container_name", peerReviewEntity.getSubjectContainerName()); String itemName = null; - Optional optional = groupIdRecordManager.findByGroupId(peerReviewEntity.getGroupId()); if (optional.isPresent()) { GroupIdRecord groupId = optional.get(); @@ -240,6 +245,13 @@ private List createItemList(PeerReviewEntity peerReviewEntity, ActionType itemName = optional.get().getName(); } } + if(extIds != null) { + additionalInfo.put("external_identifiers", extIds); + } + + if(subjectExtId != null) { + additionalInfo.put("subject_external_identifiers", subjectExtId); + } item.setItemName(itemName); item.setAdditionalInfo(additionalInfo);