use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method displayIndexIsSetTo_0_FromAPI.
@Test
public void displayIndexIsSetTo_0_FromAPI() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PeerReview p1 = getPeerReview("fromAPI-1");
p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true);
PeerReviewEntity p = peerReviewDao.find(p1.getPutCode());
assertNotNull(91);
assertEquals(Long.valueOf(0), p.getDisplayIndex());
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_invalidPeerReviewTypeTest.
@Test(expected = ActivityTypeValidationException.class)
public void validatePeerReview_invalidPeerReviewTypeTest() {
PeerReview pr = getPeerReview();
pr.setType(null);
activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_validPeerReviewTest.
/**
* VALIDATE PEER REVIEW
*/
@Test
public void validatePeerReview_validPeerReviewTest() {
PeerReview pr = getPeerReview();
activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewManagerImpl method createPeerReview.
@Override
public PeerReview createPeerReview(String orcid, PeerReview peerReview, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
// If request comes from the API, perform the validations
if (isApiRequest) {
// Validate it have at least one ext id
activityValidator.validatePeerReview(peerReview, sourceEntity, true, isApiRequest, null);
List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid, getLastModified(orcid));
// duplicates
if (!sourceEntity.getSourceId().equals(orcid)) {
if (peerReviews != null) {
for (PeerReviewEntity entity : peerReviews) {
PeerReview existing = jpaJaxbPeerReviewAdapter.toPeerReview(entity);
activityValidator.checkExternalIdentifiersForDuplicates(peerReview.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), sourceEntity);
}
}
} else {
// check vocab of external identifiers
externalIDValidator.validateWorkOrPeerReview(peerReview.getExternalIdentifiers());
externalIDValidator.validateWorkOrPeerReview(peerReview.getSubjectExternalIdentifier());
}
validateGroupId(peerReview);
}
PeerReviewEntity entity = jpaJaxbPeerReviewAdapter.toPeerReviewEntity(peerReview);
// Updates the give organization with the latest organization from
// database
OrgEntity updatedOrganization = orgManager.getOrgEntity(peerReview);
entity.setOrg(updatedOrganization);
// Set the source
if (sourceEntity.getSourceProfile() != null) {
entity.setSourceId(sourceEntity.getSourceProfile().getId());
}
if (sourceEntity.getSourceClient() != null) {
entity.setClientSourceId(sourceEntity.getSourceClient().getId());
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
entity.setProfile(profile);
setIncomingPrivacy(entity, profile);
DisplayIndexCalculatorHelper.setDisplayIndexOnNewEntity(entity, isApiRequest);
peerReviewDao.persist(entity);
peerReviewDao.flush();
notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity));
return jpaJaxbPeerReviewAdapter.toPeerReview(entity);
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewPeerReview.
@Override
public Response viewPeerReview(String orcid, Long putCode) {
PeerReview peerReview = peerReviewManagerReadOnly.getPeerReview(orcid, putCode);
publicAPISecurityManagerV3.checkIsPublic(peerReview);
ActivityUtils.setPathToActivity(peerReview, orcid);
sourceUtilsReadOnly.setSourceName(peerReview);
return Response.ok(peerReview).build();
}
Aggregations