use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewWithSameExtIdValueButDifferentExtIdType.
@Test
public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
PeerReview peerReview1 = new PeerReview();
ExternalIDs weis1 = new ExternalIDs();
ExternalID wei1 = new ExternalID();
wei1.setRelationship(null);
wei1.setValue("same_but_different_type");
wei1.setType(WorkExternalIdentifierType.DOI.value());
weis1.getExternalIdentifier().add(wei1);
peerReview1.setExternalIdentifiers(weis1);
peerReview1.setGroupId("issn:0000003");
peerReview1.setOrganization(Utils.getOrganization());
peerReview1.setRole(Role.CHAIR);
peerReview1.setSubjectContainerName(new Title("subject-container-name"));
peerReview1.setSubjectExternalIdentifier(wei1);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("work-title"));
peerReview1.setSubjectName(workTitle1);
peerReview1.setSubjectType(WorkType.DATA_SET);
peerReview1.setType(PeerReviewType.EVALUATION);
Response response1 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview1);
assertNotNull(response1);
assertEquals(Response.Status.CREATED.getStatusCode(), response1.getStatus());
Map<?, ?> map = response1.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
PeerReview peerReview2 = new PeerReview();
ExternalIDs weis2 = new ExternalIDs();
ExternalID wei2 = new ExternalID();
wei2.setRelationship(null);
// Same value
wei2.setValue("same_but_different_type");
// But different
wei2.setType(WorkExternalIdentifierType.ARXIV.value());
// type
weis2.getExternalIdentifier().add(wei2);
peerReview2.setExternalIdentifiers(weis2);
peerReview2.setGroupId("issn:0000003");
peerReview2.setOrganization(Utils.getOrganization());
peerReview2.setRole(Role.CHAIR);
peerReview2.setSubjectContainerName(new Title("subject-container-name"));
peerReview2.setSubjectExternalIdentifier(wei2);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("work-title"));
peerReview2.setSubjectName(workTitle2);
peerReview2.setSubjectType(WorkType.DATA_SET);
peerReview2.setType(PeerReviewType.EVALUATION);
Response response2 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview2);
assertNotNull(response2);
assertEquals(Response.Status.CREATED.getStatusCode(), response2.getStatus());
map = response2.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
resultWithPutCode = (List<?>) map.get("Location");
Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
// Delete new peer reviews so they don't affect other tests
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode1);
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode2);
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class ActivityCacheManagerImpl method pubPeerReviewsMap.
@Cacheable(value = "pub-peer-reviews-maps", key = "#orcid.concat('-').concat(#lastModified)")
public LinkedHashMap<Long, PeerReview> pubPeerReviewsMap(String orcid, long lastModified) {
List<PeerReview> peerReviews = peerReviewManager.findPeerReviews(orcid, lastModified);
LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
if (peerReviews != null) {
if (!peerReviews.isEmpty()) {
for (PeerReview peerReview : peerReviews) {
if (peerReview.getVisibility().equals(Visibility.PUBLIC)) {
peerReviewMap.put(peerReview.getPutCode(), peerReview);
}
}
}
}
return peerReviewMap;
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getPeerReview.
private PeerReview getPeerReview(String userOrcid) {
PeerReview peerReview = new PeerReview();
peerReview.setOrganization(getOrganization());
peerReview.setType(PeerReviewType.EVALUATION);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Title " + System.currentTimeMillis()));
ExternalIDs workExtIds = new ExternalIDs();
ExternalID workExtId = new ExternalID();
workExtId.setValue("ID");
workExtId.setType(WorkExternalIdentifierType.AGR.value());
workExtIds.getExternalIdentifier().add(workExtId);
peerReview.setSubjectName(workTitle);
peerReview.setSubjectExternalIdentifier(workExtId);
peerReview.setSubjectType(WorkType.ARTISTIC_PERFORMANCE);
peerReview.setExternalIdentifiers(workExtIds);
peerReview.setRole(Role.CHAIR);
peerReview = peerReviewManager.createPeerReview(userOrcid, peerReview, false);
return peerReviewManager.getPeerReview(userOrcid, peerReview.getPutCode());
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method testAddPeerReviewToClaimedRecordPreserveUserDefaultVisibility.
@Test
public void testAddPeerReviewToClaimedRecordPreserveUserDefaultVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PeerReview peer = getPeerReview(null);
peer = peerReviewManager.createPeerReview(claimedOrcid, peer, true);
peer = peerReviewManager.getPeerReview(claimedOrcid, peer.getPutCode());
assertNotNull(peer);
assertEquals(Visibility.LIMITED, peer.getVisibility());
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method testAddPeerReviewToUnclaimedRecordPreservePeerReviewVisibility.
@Test
public void testAddPeerReviewToUnclaimedRecordPreservePeerReviewVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PeerReview peer = getPeerReview(null);
peer = peerReviewManager.createPeerReview(unclaimedOrcid, peer, true);
peer = peerReviewManager.getPeerReview(unclaimedOrcid, peer.getPutCode());
assertNotNull(peer);
assertEquals(Visibility.PUBLIC, peer.getVisibility());
}
Aggregations